browserstack-cypress-cli 1.10.1 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/commands/generateDownloads.js +5 -4
- package/bin/commands/generateReport.js +5 -4
- package/bin/commands/info.js +4 -3
- package/bin/commands/init.js +6 -6
- package/bin/commands/runs.js +224 -98
- package/bin/commands/stop.js +5 -65
- package/bin/helpers/archiver.js +16 -6
- package/bin/helpers/buildArtifacts.js +117 -85
- package/bin/helpers/capabilityHelper.js +46 -3
- package/bin/helpers/checkUploaded.js +54 -15
- package/bin/helpers/config.js +2 -0
- package/bin/helpers/constants.js +56 -6
- package/bin/helpers/downloadBuildStacktrace.js +29 -0
- package/bin/helpers/fileHelpers.js +14 -0
- package/bin/helpers/packageInstaller.js +134 -0
- package/bin/helpers/reporterHTML.js +78 -22
- package/bin/helpers/sync/syncSpecsLogs.js +28 -7
- package/bin/helpers/usageReporting.js +30 -2
- package/bin/helpers/utils.js +294 -13
- package/bin/helpers/zipUpload.js +123 -31
- package/bin/runner.js +24 -7
- package/package.json +6 -5
- package/.nyc_output/8250a512-572d-46ce-b8a0-1994c1cafa91.json +0 -1
- package/.nyc_output/c4d99e47-3a09-4e3a-9b8d-5fd3063b36ae.json +0 -1
- package/.nyc_output/processinfo/8250a512-572d-46ce-b8a0-1994c1cafa91.json +0 -1
- package/.nyc_output/processinfo/c4d99e47-3a09-4e3a-9b8d-5fd3063b36ae.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
- package/log/usage.log +0 -16
package/bin/helpers/archiver.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
const fs = require("fs")
|
|
2
|
+
const fs = require("fs"),
|
|
3
|
+
path = require("path");
|
|
3
4
|
|
|
4
5
|
const archiver = require("archiver"),
|
|
5
6
|
Constants = require('../helpers/constants'),
|
|
6
7
|
logger = require("./logger").winstonLogger,
|
|
7
|
-
utils = require('../helpers/utils')
|
|
8
|
-
path = require('path');
|
|
8
|
+
utils = require('../helpers/utils');
|
|
9
9
|
|
|
10
10
|
const archiveSpecs = (runSettings, filePath, excludeFiles, md5data) => {
|
|
11
11
|
return new Promise(function (resolve, reject) {
|
|
@@ -14,7 +14,17 @@ const archiveSpecs = (runSettings, filePath, excludeFiles, md5data) => {
|
|
|
14
14
|
}
|
|
15
15
|
var output = fs.createWriteStream(filePath);
|
|
16
16
|
|
|
17
|
-
var cypressFolderPath =
|
|
17
|
+
var cypressFolderPath = '';
|
|
18
|
+
let cypressAppendFilesZipLocation = '';
|
|
19
|
+
if (runSettings.home_directory) {
|
|
20
|
+
cypressFolderPath = runSettings.home_directory;
|
|
21
|
+
cypressAppendFilesZipLocation = runSettings.cypressZipStartLocation;
|
|
22
|
+
if (cypressAppendFilesZipLocation !== '') {
|
|
23
|
+
cypressAppendFilesZipLocation += '/';
|
|
24
|
+
}
|
|
25
|
+
} else {
|
|
26
|
+
cypressFolderPath = path.dirname(runSettings.cypressConfigFilePath);
|
|
27
|
+
}
|
|
18
28
|
|
|
19
29
|
logger.info(`Creating tests.zip with files in ${cypressFolderPath}`);
|
|
20
30
|
|
|
@@ -61,7 +71,7 @@ const archiveSpecs = (runSettings, filePath, excludeFiles, md5data) => {
|
|
|
61
71
|
|
|
62
72
|
if (Object.keys(packageJSON).length > 0) {
|
|
63
73
|
let packageJSONString = JSON.stringify(packageJSON, null, 4);
|
|
64
|
-
archive.append(packageJSONString, {name:
|
|
74
|
+
archive.append(packageJSONString, {name: `${cypressAppendFilesZipLocation}browserstack-package.json`});
|
|
65
75
|
}
|
|
66
76
|
|
|
67
77
|
// do not add cypress.json if arg provided is false
|
|
@@ -73,7 +83,7 @@ const archiveSpecs = (runSettings, filePath, excludeFiles, md5data) => {
|
|
|
73
83
|
fs.readFileSync(runSettings.cypressConfigFilePath)
|
|
74
84
|
);
|
|
75
85
|
let cypressJSONString = JSON.stringify(cypressJSON, null, 4);
|
|
76
|
-
archive.append(cypressJSONString, {name:
|
|
86
|
+
archive.append(cypressJSONString, {name: `${cypressAppendFilesZipLocation}cypress.json`});
|
|
77
87
|
}
|
|
78
88
|
|
|
79
89
|
archive.finalize();
|
|
@@ -3,14 +3,15 @@
|
|
|
3
3
|
const fs = require('fs'),
|
|
4
4
|
path = require('path');
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
unzipper = require('unzipper');
|
|
6
|
+
const unzipper = require('unzipper');
|
|
8
7
|
|
|
9
8
|
const logger = require('./logger').winstonLogger,
|
|
10
9
|
utils = require("./utils"),
|
|
11
10
|
Constants = require("./constants"),
|
|
12
11
|
config = require("./config");
|
|
13
12
|
|
|
13
|
+
const request = require('request');
|
|
14
|
+
|
|
14
15
|
|
|
15
16
|
let BUILD_ARTIFACTS_TOTAL_COUNT = 0;
|
|
16
17
|
let BUILD_ARTIFACTS_FAIL_COUNT = 0;
|
|
@@ -95,32 +96,31 @@ const downloadAndUnzip = async (filePath, fileName, url) => {
|
|
|
95
96
|
let tmpFilePath = path.join(filePath, fileName);
|
|
96
97
|
const writer = fs.createWriteStream(tmpFilePath);
|
|
97
98
|
|
|
98
|
-
return
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
});
|
|
99
|
+
return new Promise(async (resolve, reject) => {
|
|
100
|
+
request.get(url).on('response', function(response) {
|
|
101
|
+
|
|
102
|
+
if(response.statusCode != 200) {
|
|
103
|
+
reject();
|
|
104
|
+
} else {
|
|
105
|
+
//ensure that the user can call `then()` only when the file has
|
|
106
|
+
//been downloaded entirely.
|
|
107
|
+
response.pipe(writer);
|
|
108
|
+
let error = null;
|
|
109
|
+
writer.on('error', err => {
|
|
110
|
+
error = err;
|
|
111
|
+
writer.close();
|
|
112
|
+
reject(err);
|
|
113
|
+
});
|
|
114
|
+
writer.on('close', async () => {
|
|
115
|
+
if (!error) {
|
|
116
|
+
await unzipFile(filePath, fileName);
|
|
117
|
+
fs.unlinkSync(tmpFilePath);
|
|
118
|
+
resolve(true);
|
|
119
|
+
}
|
|
120
|
+
//no need to call the reject here, as it will have been called in the
|
|
121
|
+
//'error' stream;
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
124
|
});
|
|
125
125
|
});
|
|
126
126
|
}
|
|
@@ -134,8 +134,8 @@ const unzipFile = async (filePath, fileName) => {
|
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
const sendUpdatesToBstack = async (bsConfig, buildId, args, options) => {
|
|
138
|
-
|
|
137
|
+
const sendUpdatesToBstack = async (bsConfig, buildId, args, options, rawArgs) => {
|
|
138
|
+
options.url = `${config.buildUrl}${buildId}/build_artifacts/status`;
|
|
139
139
|
|
|
140
140
|
let cypressJSON = utils.getCypressJSON(bsConfig);
|
|
141
141
|
|
|
@@ -156,63 +156,95 @@ const sendUpdatesToBstack = async (bsConfig, buildId, args, options) => {
|
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
exports.downloadBuildArtifacts = async (bsConfig, buildId, args) => {
|
|
167
|
-
BUILD_ARTIFACTS_FAIL_COUNT = 0;
|
|
168
|
-
BUILD_ARTIFACTS_TOTAL_COUNT = 0;
|
|
169
|
-
|
|
170
|
-
let url = `${config.buildUrl}${buildId}/build_artifacts`;
|
|
171
|
-
let options = {
|
|
172
|
-
auth: {
|
|
173
|
-
username: bsConfig.auth.username,
|
|
174
|
-
password: bsConfig.auth.access_key,
|
|
175
|
-
},
|
|
176
|
-
headers: {
|
|
177
|
-
'User-Agent': utils.getUserAgent(),
|
|
178
|
-
},
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
let message = null;
|
|
182
|
-
let messageType = null;
|
|
183
|
-
let errorCode = null;
|
|
184
|
-
|
|
185
|
-
try {
|
|
186
|
-
const res = await axios.get(url, options);
|
|
187
|
-
let buildDetails = res.data;
|
|
188
|
-
|
|
189
|
-
await createDirectories(buildId, buildDetails);
|
|
190
|
-
await parseAndDownloadArtifacts(buildId, buildDetails);
|
|
191
|
-
|
|
192
|
-
if (BUILD_ARTIFACTS_FAIL_COUNT > 0) {
|
|
193
|
-
messageType = Constants.messageTypes.ERROR;
|
|
194
|
-
message = Constants.userMessages.DOWNLOAD_BUILD_ARTIFACTS_FAILED.replace('<build-id>', buildId).replace('<machine-count>', BUILD_ARTIFACTS_FAIL_COUNT);
|
|
195
|
-
logger.error(message);
|
|
159
|
+
options.formData = data.toString();
|
|
160
|
+
let responseData = null;
|
|
161
|
+
return new Promise (async (resolve, reject) => {
|
|
162
|
+
request.post(options, function (err, resp, data) {
|
|
163
|
+
if(err) {
|
|
164
|
+
utils.sendUsageReport(bsConfig, args, err, Constants.messageTypes.ERROR, 'api_failed_build_artifacts_status_update', null, rawArgs);
|
|
165
|
+
reject(err);
|
|
196
166
|
} else {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
167
|
+
try {
|
|
168
|
+
responseData = JSON.parse(data);
|
|
169
|
+
} catch(e) {
|
|
170
|
+
responseData = {};
|
|
171
|
+
}
|
|
172
|
+
if (resp.statusCode != 200) {
|
|
173
|
+
if (responseData && responseData["error"]) {
|
|
174
|
+
utils.sendUsageReport(bsConfig, args, responseData["error"], Constants.messageTypes.ERROR, 'api_failed_build_artifacts_status_update', null, rawArgs);
|
|
175
|
+
reject(responseData["error"])
|
|
176
|
+
}
|
|
177
|
+
}
|
|
200
178
|
}
|
|
179
|
+
resolve()
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
}
|
|
201
183
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
errorCode = 'api_failed_build_artifacts';
|
|
207
|
-
|
|
208
|
-
if (BUILD_ARTIFACTS_FAIL_COUNT > 0) {
|
|
209
|
-
messageType = Constants.messageTypes.ERROR;
|
|
210
|
-
message = Constants.userMessages.DOWNLOAD_BUILD_ARTIFACTS_FAILED.replace('<build-id>', buildId).replace('<machine-count>', BUILD_ARTIFACTS_FAIL_COUNT);
|
|
211
|
-
logger.error(message);
|
|
212
|
-
} else {
|
|
213
|
-
logger.error('Downloading the build artifacts failed.');
|
|
214
|
-
}
|
|
184
|
+
exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs) => {
|
|
185
|
+
return new Promise ( async (resolve, reject) => {
|
|
186
|
+
BUILD_ARTIFACTS_FAIL_COUNT = 0;
|
|
187
|
+
BUILD_ARTIFACTS_TOTAL_COUNT = 0;
|
|
215
188
|
|
|
216
|
-
|
|
217
|
-
|
|
189
|
+
let options = {
|
|
190
|
+
url: `${config.buildUrl}${buildId}/build_artifacts`,
|
|
191
|
+
auth: {
|
|
192
|
+
username: bsConfig.auth.username,
|
|
193
|
+
password: bsConfig.auth.access_key,
|
|
194
|
+
},
|
|
195
|
+
headers: {
|
|
196
|
+
'User-Agent': utils.getUserAgent(),
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
let message = null;
|
|
201
|
+
let messageType = null;
|
|
202
|
+
let errorCode = null;
|
|
203
|
+
let buildDetails = null;
|
|
204
|
+
request.get(options, async function (err, resp, body) {
|
|
205
|
+
if(err) {
|
|
206
|
+
utils.sendUsageReport(bsConfig, args, err, Constants.messageTypes.ERROR, 'api_failed_build_artifacts', null, rawArgs);
|
|
207
|
+
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
208
|
+
} else {
|
|
209
|
+
try {
|
|
210
|
+
buildDetails = JSON.parse(body);
|
|
211
|
+
if(resp.statusCode != 200) {
|
|
212
|
+
logger.error('Downloading the build artifacts failed.');
|
|
213
|
+
logger.error(`Error: Request failed with status code ${resp.statusCode}`)
|
|
214
|
+
utils.sendUsageReport(bsConfig, args, buildDetails, Constants.messageTypes.ERROR, 'api_failed_build_artifacts', null, rawArgs);
|
|
215
|
+
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
216
|
+
} else {
|
|
217
|
+
await createDirectories(buildId, buildDetails);
|
|
218
|
+
await parseAndDownloadArtifacts(buildId, buildDetails);
|
|
219
|
+
if (BUILD_ARTIFACTS_FAIL_COUNT > 0) {
|
|
220
|
+
messageType = Constants.messageTypes.ERROR;
|
|
221
|
+
message = Constants.userMessages.DOWNLOAD_BUILD_ARTIFACTS_FAILED.replace('<build-id>', buildId).replace('<machine-count>', BUILD_ARTIFACTS_FAIL_COUNT);
|
|
222
|
+
logger.error(message);
|
|
223
|
+
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
224
|
+
} else {
|
|
225
|
+
messageType = Constants.messageTypes.SUCCESS;
|
|
226
|
+
message = Constants.userMessages.DOWNLOAD_BUILD_ARTIFACTS_SUCCESS.replace('<build-id>', buildId).replace('<user-path>', process.cwd());
|
|
227
|
+
logger.info(message);
|
|
228
|
+
}
|
|
229
|
+
await sendUpdatesToBstack(bsConfig, buildId, args, options, rawArgs)
|
|
230
|
+
utils.sendUsageReport(bsConfig, args, message, messageType, null, null, rawArgs);
|
|
231
|
+
}
|
|
232
|
+
} catch (err) {
|
|
233
|
+
messageType = Constants.messageTypes.ERROR;
|
|
234
|
+
errorCode = 'api_failed_build_artifacts';
|
|
235
|
+
if (BUILD_ARTIFACTS_FAIL_COUNT > 0) {
|
|
236
|
+
messageType = Constants.messageTypes.ERROR;
|
|
237
|
+
message = Constants.userMessages.DOWNLOAD_BUILD_ARTIFACTS_FAILED.replace('<build-id>', buildId).replace('<machine-count>', BUILD_ARTIFACTS_FAIL_COUNT);
|
|
238
|
+
logger.error(message);
|
|
239
|
+
} else {
|
|
240
|
+
logger.error('Downloading the build artifacts failed.');
|
|
241
|
+
}
|
|
242
|
+
utils.sendUsageReport(bsConfig, args, err, messageType, errorCode, null, rawArgs);
|
|
243
|
+
logger.error(`Error: Request failed with status code ${resp.statusCode}`)
|
|
244
|
+
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
resolve();
|
|
248
|
+
});
|
|
249
|
+
});
|
|
218
250
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
const fs = require('fs'),
|
|
2
|
+
path = require('path');
|
|
3
|
+
|
|
1
4
|
const logger = require("./logger").winstonLogger,
|
|
2
5
|
Constants = require("./constants"),
|
|
3
|
-
Utils = require("./utils")
|
|
4
|
-
fs = require('fs');
|
|
6
|
+
Utils = require("./utils");
|
|
5
7
|
|
|
6
8
|
const caps = (bsConfig, zip) => {
|
|
7
9
|
return new Promise(function (resolve, reject) {
|
|
@@ -23,7 +25,7 @@ const caps = (bsConfig, zip) => {
|
|
|
23
25
|
if (bsConfig.browsers) {
|
|
24
26
|
bsConfig.browsers.forEach((element) => {
|
|
25
27
|
osBrowser = element.os + "-" + element.browser;
|
|
26
|
-
osAndBrowser = element.os + " / " + Utils.capitalizeFirstLetter(element.browser);
|
|
28
|
+
osAndBrowser = (element.os) ? element.os : "Any OS" + " / " + Utils.capitalizeFirstLetter(element.browser);
|
|
27
29
|
element.versions.forEach((version) => {
|
|
28
30
|
osBrowserArray.push(osBrowser + version);
|
|
29
31
|
browsersList.push(`${osAndBrowser} (${version})`);
|
|
@@ -41,6 +43,12 @@ const caps = (bsConfig, zip) => {
|
|
|
41
43
|
reject("Test suite is empty");
|
|
42
44
|
}
|
|
43
45
|
|
|
46
|
+
// Npm package
|
|
47
|
+
if (zip.npm_package_url && zip.npm_package_url.split("://")[1].length !== 0) {
|
|
48
|
+
obj.npm_package_suite = zip.npm_package_url.split("://")[1];
|
|
49
|
+
}
|
|
50
|
+
obj.cache_dependencies = bsConfig.run_settings.cache_dependencies;
|
|
51
|
+
|
|
44
52
|
// Inferred settings
|
|
45
53
|
if(bsConfig.connection_settings){
|
|
46
54
|
if (bsConfig.connection_settings.local_mode_inferred) {
|
|
@@ -123,6 +131,13 @@ const caps = (bsConfig, zip) => {
|
|
|
123
131
|
})
|
|
124
132
|
}
|
|
125
133
|
|
|
134
|
+
const addCypressZipStartLocation = (runSettings) => {
|
|
135
|
+
let resolvedHomeDirectoryPath = path.resolve(runSettings.home_directory);
|
|
136
|
+
let resolvedCypressConfigFilePath = path.resolve(runSettings.cypressConfigFilePath);
|
|
137
|
+
runSettings.cypressZipStartLocation = path.dirname(resolvedCypressConfigFilePath.split(resolvedHomeDirectoryPath)[1]);
|
|
138
|
+
runSettings.cypressZipStartLocation = runSettings.cypressZipStartLocation.substring(1);
|
|
139
|
+
}
|
|
140
|
+
|
|
126
141
|
const validate = (bsConfig, args) => {
|
|
127
142
|
return new Promise(function (resolve, reject) {
|
|
128
143
|
logger.info(Constants.userMessages.VALIDATING_CONFIG);
|
|
@@ -156,6 +171,12 @@ const validate = (bsConfig, args) => {
|
|
|
156
171
|
|
|
157
172
|
if( Utils.searchForOption('--local-config-file') && ( Utils.isUndefined(args.localConfigFile) || (!Utils.isUndefined(args.localConfigFile) && !fs.existsSync(args.localConfigFile)))) reject(Constants.validationMessages.INVALID_LOCAL_CONFIG_FILE);
|
|
158
173
|
|
|
174
|
+
if( Utils.searchForOption('--async') && ( !Utils.isUndefined(args.async) && bsConfig["connection_settings"]["local"])) reject(Constants.validationMessages.INVALID_LOCAL_ASYNC_ARGS);
|
|
175
|
+
|
|
176
|
+
if (bsConfig.run_settings.userProvidedGeolocation && !bsConfig.run_settings.geolocation.match(/^[A-Z]{2}$/g)) reject(Constants.validationMessages.INVALID_GEO_LOCATION);
|
|
177
|
+
|
|
178
|
+
if (bsConfig["connection_settings"]["local"] && bsConfig.run_settings.userProvidedGeolocation) reject(Constants.validationMessages.NOT_ALLOWED_GEO_LOCATION_AND_LOCAL_MODE);
|
|
179
|
+
|
|
159
180
|
// validate if config file provided exists or not when cypress_config_file provided
|
|
160
181
|
// validate the cypressProjectDir key otherwise.
|
|
161
182
|
let cypressConfigFilePath = bsConfig.run_settings.cypressConfigFilePath;
|
|
@@ -177,11 +198,33 @@ const validate = (bsConfig, args) => {
|
|
|
177
198
|
} catch(error){
|
|
178
199
|
reject(Constants.validationMessages.INVALID_CYPRESS_JSON)
|
|
179
200
|
}
|
|
201
|
+
|
|
202
|
+
//check if home_directory is present or not in user run_settings
|
|
203
|
+
if (!Utils.isUndefined(bsConfig.run_settings.home_directory)) {
|
|
204
|
+
// check if home_directory exists or not
|
|
205
|
+
if (!fs.existsSync(bsConfig.run_settings.home_directory)) {
|
|
206
|
+
reject(Constants.validationMessages.HOME_DIRECTORY_NOT_FOUND);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// check if home_directory is a directory or not
|
|
210
|
+
if (!fs.statSync(bsConfig.run_settings.home_directory).isDirectory()) {
|
|
211
|
+
reject(Constants.validationMessages.HOME_DIRECTORY_NOT_A_DIRECTORY);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// check if cypress config file (cypress.json) is a part of home_directory or not
|
|
215
|
+
if (!path.resolve(bsConfig.run_settings.cypressConfigFilePath).includes(path.resolve(bsConfig.run_settings.home_directory))) {
|
|
216
|
+
reject(Constants.validationMessages.CYPRESS_CONFIG_FILE_NOT_PART_OF_HOME_DIRECTORY);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
addCypressZipStartLocation(bsConfig.run_settings);
|
|
220
|
+
}
|
|
221
|
+
|
|
180
222
|
resolve(cypressJson);
|
|
181
223
|
});
|
|
182
224
|
}
|
|
183
225
|
|
|
184
226
|
module.exports = {
|
|
185
227
|
caps,
|
|
228
|
+
addCypressZipStartLocation,
|
|
186
229
|
validate
|
|
187
230
|
}
|
|
@@ -10,10 +10,18 @@ const crypto = require('crypto'),
|
|
|
10
10
|
utils = require('./utils');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
const checkSpecsMd5 = (runSettings,
|
|
13
|
+
const checkSpecsMd5 = (runSettings, args, instrumentBlocks) => {
|
|
14
14
|
return new Promise(function (resolve, reject) {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
if (args["force-upload"]) {
|
|
16
|
+
return resolve("force-upload");
|
|
17
|
+
}
|
|
18
|
+
let cypressFolderPath = undefined;
|
|
19
|
+
if (runSettings.home_directory) {
|
|
20
|
+
cypressFolderPath = runSettings.home_directory;
|
|
21
|
+
} else {
|
|
22
|
+
cypressFolderPath = path.dirname(runSettings.cypressConfigFilePath);
|
|
23
|
+
}
|
|
24
|
+
let ignoreFiles = utils.getFilesToIgnore(runSettings, args.exclude, false);
|
|
17
25
|
let options = {
|
|
18
26
|
cwd: cypressFolderPath,
|
|
19
27
|
ignore: ignoreFiles,
|
|
@@ -45,12 +53,12 @@ const checkPackageMd5 = (runSettings) => {
|
|
|
45
53
|
const outputHash = crypto.createHash(Constants.hashingOptions.algo);
|
|
46
54
|
let packageJSON = {};
|
|
47
55
|
if (typeof runSettings.package_config_options === 'object') {
|
|
48
|
-
Object.assign(packageJSON, runSettings.package_config_options);
|
|
56
|
+
Object.assign(packageJSON, utils.sortJsonKeys(runSettings.package_config_options));
|
|
49
57
|
}
|
|
50
58
|
|
|
51
59
|
if (typeof runSettings.npm_dependencies === 'object') {
|
|
52
60
|
Object.assign(packageJSON, {
|
|
53
|
-
devDependencies: runSettings.npm_dependencies,
|
|
61
|
+
devDependencies: utils.sortJsonKeys(runSettings.npm_dependencies),
|
|
54
62
|
});
|
|
55
63
|
}
|
|
56
64
|
|
|
@@ -58,6 +66,12 @@ const checkPackageMd5 = (runSettings) => {
|
|
|
58
66
|
let packageJSONString = JSON.stringify(packageJSON);
|
|
59
67
|
outputHash.update(packageJSONString);
|
|
60
68
|
}
|
|
69
|
+
let cypressFolderPath = path.dirname(runSettings.cypressConfigFilePath);
|
|
70
|
+
let sourceNpmrc = path.join(cypressFolderPath, ".npmrc");
|
|
71
|
+
if (fs.existsSync(sourceNpmrc)) {
|
|
72
|
+
const npmrc = fs.readFileSync(sourceNpmrc, {encoding:'utf8', flag:'r'});
|
|
73
|
+
outputHash.update(npmrc);
|
|
74
|
+
}
|
|
61
75
|
|
|
62
76
|
return outputHash.digest(Constants.hashingOptions.encoding)
|
|
63
77
|
};
|
|
@@ -66,18 +80,27 @@ const checkUploadedMd5 = (bsConfig, args, instrumentBlocks) => {
|
|
|
66
80
|
return new Promise(function (resolve) {
|
|
67
81
|
let obj = {
|
|
68
82
|
zipUrlPresent: false,
|
|
83
|
+
packageUrlPresent: false,
|
|
69
84
|
};
|
|
70
|
-
if (args["force-upload"]) {
|
|
85
|
+
if (args["force-upload"] && !utils.isTrueString(bsConfig.run_settings.cache_dependencies)) {
|
|
71
86
|
return resolve(obj);
|
|
72
87
|
}
|
|
88
|
+
|
|
73
89
|
instrumentBlocks.markBlockStart("checkAlreadyUploaded.md5Total");
|
|
74
|
-
checkSpecsMd5(bsConfig.run_settings, args
|
|
75
|
-
Object.assign(obj, {md5sum: md5data});
|
|
90
|
+
checkSpecsMd5(bsConfig.run_settings, args, instrumentBlocks).then(function (zip_md5sum) {
|
|
76
91
|
instrumentBlocks.markBlockStart("checkAlreadyUploaded.md5Package");
|
|
77
|
-
let
|
|
92
|
+
let npm_package_md5sum = checkPackageMd5(bsConfig.run_settings);
|
|
78
93
|
instrumentBlocks.markBlockEnd("checkAlreadyUploaded.md5Package");
|
|
79
94
|
instrumentBlocks.markBlockEnd("checkAlreadyUploaded.md5Total");
|
|
80
|
-
let data =
|
|
95
|
+
let data = {};
|
|
96
|
+
if (!args["force-upload"]) {
|
|
97
|
+
Object.assign(data, { zip_md5sum });
|
|
98
|
+
Object.assign(obj, { zip_md5sum });
|
|
99
|
+
}
|
|
100
|
+
if (utils.isTrueString(bsConfig.run_settings.cache_dependencies)) {
|
|
101
|
+
Object.assign(data, { npm_package_md5sum });
|
|
102
|
+
Object.assign(obj, { npm_package_md5sum });
|
|
103
|
+
}
|
|
81
104
|
|
|
82
105
|
let options = {
|
|
83
106
|
url: config.checkMd5sum,
|
|
@@ -89,7 +112,7 @@ const checkUploadedMd5 = (bsConfig, args, instrumentBlocks) => {
|
|
|
89
112
|
'Content-Type': 'application/json',
|
|
90
113
|
"User-Agent": utils.getUserAgent(),
|
|
91
114
|
},
|
|
92
|
-
body: data
|
|
115
|
+
body: JSON.stringify(data)
|
|
93
116
|
};
|
|
94
117
|
|
|
95
118
|
instrumentBlocks.markBlockStart("checkAlreadyUploaded.railsCheck");
|
|
@@ -104,15 +127,31 @@ const checkUploadedMd5 = (bsConfig, args, instrumentBlocks) => {
|
|
|
104
127
|
} catch (error) {
|
|
105
128
|
zipData = {};
|
|
106
129
|
}
|
|
107
|
-
if (resp.statusCode === 200
|
|
108
|
-
|
|
130
|
+
if (resp.statusCode === 200) {
|
|
131
|
+
if (!utils.isUndefined(zipData.zipUrl)) {
|
|
132
|
+
Object.assign(obj, zipData, {zipUrlPresent: true});
|
|
133
|
+
}
|
|
134
|
+
if (!utils.isUndefined(zipData.npmPackageUrl)) {
|
|
135
|
+
Object.assign(obj, zipData, {packageUrlPresent: true});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (utils.isTrueString(zipData.disableNpmSuiteCache)) {
|
|
139
|
+
bsConfig.run_settings.cache_dependencies = false;
|
|
140
|
+
Object.assign(obj, {packageUrlPresent: false});
|
|
141
|
+
delete obj.npm_package_md5sum;
|
|
142
|
+
}
|
|
143
|
+
if (utils.isTrueString(zipData.disableTestSuiteCache)) {
|
|
144
|
+
args["force-upload"] = true;
|
|
145
|
+
Object.assign(obj, {zipUrlPresent: false});
|
|
146
|
+
delete obj.zip_md5sum;
|
|
109
147
|
}
|
|
110
148
|
instrumentBlocks.markBlockEnd("checkAlreadyUploaded.railsCheck");
|
|
111
149
|
resolve(obj);
|
|
112
150
|
}
|
|
113
151
|
});
|
|
114
|
-
}).catch((
|
|
115
|
-
|
|
152
|
+
}).catch((err) => {
|
|
153
|
+
let errString = err.stack ? err.stack.toString().substring(0,100) : err.toString().substring(0,100);
|
|
154
|
+
resolve({zipUrlPresent: false, packageUrlPresent: false, error: errString});
|
|
116
155
|
});
|
|
117
156
|
});
|
|
118
157
|
};
|
package/bin/helpers/config.js
CHANGED
|
@@ -17,6 +17,8 @@ config.buildUrl = `${config.cypress_v1}/builds/`;
|
|
|
17
17
|
config.buildStopUrl = `${config.cypress_v1}/builds/stop/`;
|
|
18
18
|
config.checkMd5sum = `${config.cypress_v1}/md5sumcheck/`;
|
|
19
19
|
config.fileName = "tests.zip";
|
|
20
|
+
config.packageFileName = "bstackPackages.tar.gz";
|
|
21
|
+
config.packageDirName = "tmpBstackPackages";
|
|
20
22
|
config.retries = 5;
|
|
21
23
|
config.networkErrorExitCode = 2;
|
|
22
24
|
|