Skip to content

Commit 8006beb

Browse files
committed
disable cache flag and cleanup
1 parent 9463861 commit 8006beb

File tree

6 files changed

+36
-7
lines changed

6 files changed

+36
-7
lines changed

bin/commands/runs.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ module.exports = function run(args) {
9999
markBlockEnd('checkAlreadyUploaded');
100100

101101
markBlockStart('packageInstaller');
102-
return packageInstaller.packageWrappper(bsConfig, config.packageDirName, config.packageFileName, md5data, {markBlockStart, markBlockEnd}).then(function (packageData) {
102+
return packageInstaller.packageWrapper(bsConfig, config.packageDirName, config.packageFileName, md5data, {markBlockStart, markBlockEnd}).then(function (packageData) {
103103
markBlockEnd('packageInstaller');
104104

105105
// Archive the spec files
@@ -206,6 +206,11 @@ module.exports = function run(args) {
206206
logger.error(Constants.userMessages.ZIP_UPLOAD_FAILED);
207207
fileHelpers.deleteZip();
208208
utils.sendUsageReport(bsConfig, args, `${err}\n${Constants.userMessages.ZIP_UPLOAD_FAILED}`, Constants.messageTypes.ERROR, 'zip_upload_failed');
209+
try {
210+
fileHelpers.deletePackageArchieve();
211+
} catch (err) {
212+
utils.sendUsageReport(bsConfig, args, Constants.userMessages.NPM_DELETE_FAILED, Constants.messageTypes.ERROR, 'npm_deletion_failed');
213+
}
209214
}
210215
});
211216
}).catch(function (err) {
@@ -218,12 +223,22 @@ module.exports = function run(args) {
218223
} catch (err) {
219224
utils.sendUsageReport(bsConfig, args, Constants.userMessages.ZIP_DELETE_FAILED, Constants.messageTypes.ERROR, 'zip_deletion_failed');
220225
}
226+
try {
227+
fileHelpers.deletePackageArchieve();
228+
} catch (err) {
229+
utils.sendUsageReport(bsConfig, args, Constants.userMessages.NPM_DELETE_FAILED, Constants.messageTypes.ERROR, 'npm_deletion_failed');
230+
}
221231
});
222232
}).catch(function (err) {
223233
// package installer failed
224234
logger.error(err);
225235
logger.error(Constants.userMessages.FAILED_CREATE_NPM_ARCHIVE);
226236
utils.sendUsageReport(bsConfig, args, Constants.userMessages.FAILED_CREATE_NPM_ARCHIVE, Constants.messageTypes.ERROR, 'npm_package_archive_failed');
237+
try {
238+
fileHelpers.deletePackageArchieve();
239+
} catch (err) {
240+
utils.sendUsageReport(bsConfig, args, Constants.userMessages.NPM_DELETE_FAILED, Constants.messageTypes.ERROR, 'npm_deletion_failed');
241+
}
227242
});
228243
}).catch(function (err) {
229244
// md5 check failed

bin/helpers/checkUploaded.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@ const checkUploadedMd5 = (bsConfig, args, instrumentBlocks) => {
130130
Object.assign(obj, zipData, {packageUrlPresent: true});
131131
}
132132
}
133+
if (utils.isTrueString(zipData.disableNpmSuiteCache)) {
134+
bsConfig.run_settings.cache_dependencies = false;
135+
Object.assign(obj, {packageUrlPresent: false});
136+
}
137+
if (utils.isTrueString(zipData.disableTestSuiteCache)) {
138+
args["force-upload"] = true;
139+
Object.assign(obj, {zipUrlPresent: false});
140+
}
133141
instrumentBlocks.markBlockEnd("checkAlreadyUploaded.railsCheck");
134142
resolve(obj);
135143
}

bin/helpers/constants.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ const userMessages = {
3838
NO_NPM_DEPENDENCIES_READ_MORE: "Read more about npm dependencies here: https://www.browserstack.com/docs/automate/cypress/npm-packages. You can suppress this warning by using --disable-npm-warning flag.",
3939
VALIDATING_CONFIG: "Validating the config",
4040
UPLOADING_TESTS: "Uploading the tests to BrowserStack",
41+
UPLOADING_TESTS_SUCCESS: "Uploaded tests successfully",
4142
UPLOADING_NPM_PACKAGES: "Uploading required node_modules to BrowserStack",
43+
UPLOADING_NPM_PACKAGES_SUCCESS: "Uploaded node_modules successfully",
4244
LOCAL_TRUE: "you will now be able to test localhost / private URLs",
4345
LOCAL_FALSE: "you won't be able to test localhost / private URLs",
4446
EXIT_SYNC_CLI_MESSAGE: "Exiting the CLI, but your build is still running. You can use the --sync option to keep getting test updates. You can also use the build-info <build-id> command now.",
@@ -160,6 +162,8 @@ const filesToIgnoreWhileUploading = [
160162
'.idea/**',
161163
'.vscode/**',
162164
'.npm/**',
165+
'bstackPackages.tar.gz',
166+
'tmpBstackPackages/**',
163167
'.yarn/**',
164168
'build_artifacts/**'
165169
];

bin/helpers/packageInstaller.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ const packageArchiver = (packageDir, packageFile) => {
105105
})
106106
}
107107

108-
const packageWrappper = (bsConfig, packageDir, packageFile, md5data, instrumentBlocks) => {
108+
const packageWrapper = (bsConfig, packageDir, packageFile, md5data, instrumentBlocks) => {
109109
return new Promise(function (resolve) {
110110
let obj = {
111111
packageArchieveCreated: false
@@ -129,10 +129,10 @@ const packageWrappper = (bsConfig, packageDir, packageFile, md5data, instrumentB
129129
Object.assign(obj, { packageArchieveCreated: true });
130130
return resolve(obj);
131131
}).catch((err) => {
132-
obj.error = err.stack.substring(0,100)
132+
obj.error = err.stack.substring(0,100);
133133
return resolve(obj);
134134
})
135135
})
136136
}
137137

138-
exports.packageWrappper = packageWrappper;
138+
exports.packageWrapper = packageWrapper;

bin/helpers/utils.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,8 @@ exports.generateUploadOptions = (type, md5data, packageData) => {
459459
filename: "tests"
460460
},
461461
messages: {
462-
uploading: Constants.userMessages.UPLOADING_TESTS
462+
uploading: Constants.userMessages.UPLOADING_TESTS,
463+
uploadingSuccess: Constants.userMessages.UPLOADING_TESTS_SUCCESS
463464
},
464465
cleanupMethod: fileHelpers.deleteZip,
465466
}
@@ -477,7 +478,8 @@ exports.generateUploadOptions = (type, md5data, packageData) => {
477478
filename: "bstackPackages"
478479
},
479480
messages: {
480-
uploading: Constants.userMessages.UPLOADING_NPM_PACKAGES
481+
uploading: Constants.userMessages.UPLOADING_NPM_PACKAGES,
482+
uploadingSuccess: Constants.userMessages.UPLOADING_NPM_PACKAGES_SUCCESS
481483
},
482484
cleanupMethod: fileHelpers.deletePackageArchieve,
483485
}

bin/helpers/zipUpload.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const uploadSuits = (bsConfig, filePath, opts) => {
4848
}
4949
}
5050
} else {
51-
logger.info(`Uploaded tests successfully (${responseData[opts.md5ReturnKey]})`);
51+
logger.info(`${opts.messages.uploadingSuccess} (${responseData[opts.md5ReturnKey]})`);
5252
opts.cleanupMethod();
5353
resolve(responseData);
5454
}

0 commit comments

Comments
 (0)