Skip to content

Commit b2a638b

Browse files
committed
added browserstackinfra
1 parent 68e7c6a commit b2a638b

File tree

4 files changed

+59
-172
lines changed

4 files changed

+59
-172
lines changed

bin/commands/runs.js

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ module.exports = function run(args, rawArgs) {
5050
utils.setCypressConfigFilename(bsConfig, args);
5151

5252
const turboScaleSession = false;
53-
// Constants.turboScaleObj.enabled = turboScaleSession;
5453

5554
utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting);
5655

@@ -62,11 +61,26 @@ module.exports = function run(args, rawArgs) {
6261
// accept the access key from command line or env variable if provided
6362
utils.setAccessKey(bsConfig, args);
6463

64+
const isBrowserstackInfra = true
6565
let buildReportData = await getInitialDetails(bsConfig, args, rawArgs);
6666

6767
// accept the build name from command line if provided
6868
utils.setBuildName(bsConfig, args);
6969

70+
if(isBrowserstackInfra) {
71+
// set cypress test suite type
72+
utils.setCypressTestSuiteType(bsConfig);
73+
74+
// set cypress geo location
75+
utils.setGeolocation(bsConfig, args);
76+
77+
// set timezone
78+
utils.setTimezone(bsConfig, args);
79+
80+
// set spec timeout
81+
utils.setSpecTimeout(bsConfig, args);
82+
}
83+
7084

7185
// accept the specs list from command line if provided
7286
utils.setUserSpecs(bsConfig, args);
@@ -80,8 +94,51 @@ module.exports = function run(args, rawArgs) {
8094
// accept the system env list from bsconf and set it
8195
utils.setSystemEnvs(bsConfig);
8296

97+
if(isBrowserstackInfra) {
98+
//accept the local from env variable if provided
99+
utils.setLocal(bsConfig, args);
100+
101+
//set network logs
102+
utils.setNetworkLogs(bsConfig);
103+
104+
// set Local Mode (on-demand/ always-on)
105+
utils.setLocalMode(bsConfig, args);
106+
107+
//accept the local identifier from env variable if provided
108+
utils.setLocalIdentifier(bsConfig, args);
109+
110+
// set Local Config File
111+
utils.setLocalConfigFile(bsConfig, args);
112+
113+
// run test in headed mode
114+
utils.setHeaded(bsConfig, args);
115+
116+
// set the no-wrap
117+
utils.setNoWrap(bsConfig, args);
118+
119+
// add cypress dependency if missing
120+
utils.setCypressNpmDependency(bsConfig);
121+
}
122+
83123
const { packagesInstalled } = await packageInstaller.packageSetupAndInstaller(bsConfig, config.packageDirName, {markBlockStart, markBlockEnd});
84124

125+
if(isBrowserstackInfra) {
126+
// set node version
127+
utils.setNodeVersion(bsConfig, args);
128+
129+
//set browsers
130+
await utils.setBrowsers(bsConfig, args);
131+
132+
//set config (--config)
133+
utils.setConfig(bsConfig, args);
134+
135+
// set sync/async mode (--async/--sync)
136+
utils.setCLIMode(bsConfig, args);
137+
138+
// set other cypress configs e.g. reporter and reporter-options
139+
utils.setOtherConfigs(bsConfig, args);
140+
}
141+
85142
markBlockEnd('setConfig');
86143
logger.debug("Completed setting the configs");
87144

bin/helpers/atsHelper.js

Lines changed: 0 additions & 119 deletions
This file was deleted.

bin/helpers/capabilityHelper.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ const validate = (bsConfig, args) => {
262262
if (!Utils.isUndefined(bsConfig.run_settings.integrationFolder) && !Utils.isCypressProjDirValid(bsConfig.run_settings.cypressProjectDir,bsConfig.run_settings.integrationFolder)) reject(Constants.validationMessages.INCORRECT_DIRECTORY_STRUCTURE);
263263
}
264264
} catch(error){
265+
logger.debug(error)
265266
reject(Constants.validationMessages.INVALID_CYPRESS_JSON)
266267
}
267268

bin/helpers/usageReporting.js

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const config = require('./config'),
1111
const { AUTH_REGEX, REDACTED_AUTH, REDACTED, CLI_ARGS_REGEX, RAW_ARGS_REGEX } = require("./constants");
1212
const { default: axios } = require("axios");
1313
const axiosRetry = require("axios-retry");
14-
const { isTurboScaleSession } = require('../helpers/atsHelper');
1514

1615
function get_version(package_name) {
1716
try {
@@ -199,56 +198,9 @@ function redactKeys(str, regex, redact) {
199198
return str.replace(regex, redact);
200199
}
201200

202-
function sendTurboscaleErrorLogs(args) {
203-
let bsConfig = JSON.parse(JSON.stringify(args.bstack_config));
204-
let data = utils.isUndefined(args.data) ? {} : args.data;
205-
const turboscaleErrorPayload = {
206-
kind: 'hst-cypress-cli-error',
207-
data: data,
208-
error: args.message
209-
}
210-
211-
const options = {
212-
headers: {
213-
'User-Agent': utils.getUserAgent()
214-
},
215-
method: "POST",
216-
auth: {
217-
username: bsConfig.auth.username,
218-
password: bsConfig.auth.access_key,
219-
},
220-
url: `${config.turboScaleAPIUrl}/send-instrumentation`,
221-
body: turboscaleErrorPayload,
222-
json: true,
223-
maxAttempts: 10, // (default) try 3 times
224-
retryDelay: 2000, // (default) wait for 2s before trying again
225-
retrySrategy: request.RetryStrategies.HTTPOrNetworkError, // (default) retry on 5xx or network errors
226-
};
227-
228-
fileLogger.info(`Sending ${JSON.stringify(turboscaleErrorPayload)} to ${config.turboScaleAPIUrl}/send-instrumentation`);
229-
request(options, function (error, res, body) {
230-
if (error) {
231-
//write err response to file
232-
fileLogger.error(JSON.stringify(error));
233-
return;
234-
}
235-
// write response file
236-
let response = {
237-
attempts: res.attempts,
238-
statusCode: res.statusCode,
239-
body: body
240-
};
241-
fileLogger.info(`${JSON.stringify(response)}`);
242-
});
243-
}
244-
245201
async function send(args) {
246202
let bsConfig = JSON.parse(JSON.stringify(args.bstack_config));
247203

248-
if (isTurboScaleSession(bsConfig) && args.message_type === 'error') {
249-
sendTurboscaleErrorLogs(args);
250-
}
251-
252204
if (isUsageReportingEnabled() === "true") return;
253205

254206
let runSettings = "";
@@ -308,10 +260,6 @@ async function send(args) {
308260
},
309261
};
310262

311-
if (isTurboScaleSession(bsConfig)) {
312-
payload.event_type = 'hst_cypress_cli_stats';
313-
}
314-
315263
const options = {
316264
headers: {
317265
"Content-Type": "text/json",

0 commit comments

Comments
 (0)