Skip to content

Commit 8390b0e

Browse files
author
Archish Thakkar
authored
Merge pull request #626 from browserstack/revert-597-OBS_1292_observability_cypress_support
Revert "Add Cypress support for Browserstack Test Observability"
2 parents bf8af65 + d88f6ae commit 8390b0e

File tree

12 files changed

+45
-2312
lines changed

12 files changed

+45
-2312
lines changed

bin/commands/runs.js

Lines changed: 41 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@ const archiver = require("../helpers/archiver"),
2323
packageDiff = require('../helpers/package-diff');
2424
const { getStackTraceUrl } = require('../helpers/sync/syncSpecsLogs');
2525

26-
const {
27-
launchTestSession,
28-
setTestObservabilityFlags,
29-
runCypressTestsLocally,
30-
printBuildLink
31-
} = require('../testObservability/helper/helper');
32-
3326
module.exports = function run(args, rawArgs) {
3427

3528
markBlockStart('preBuild');
@@ -52,12 +45,6 @@ module.exports = function run(args, rawArgs) {
5245
logger.debug('Completed browserstack.json validation');
5346
markBlockStart('setConfig');
5447
logger.debug('Started setting the configs');
55-
56-
/*
57-
Set testObservability & browserstackAutomation flags
58-
*/
59-
const [isTestObservabilitySession, isBrowserstackInfra] = setTestObservabilityFlags(bsConfig);
60-
6148
utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting);
6249

6350
utils.setDefaults(bsConfig, args);
@@ -68,97 +55,80 @@ module.exports = function run(args, rawArgs) {
6855
// accept the access key from command line or env variable if provided
6956
utils.setAccessKey(bsConfig, args);
7057

71-
let buildReportData = !isBrowserstackInfra ? null : await getInitialDetails(bsConfig, args, rawArgs);
58+
let buildReportData = await getInitialDetails(bsConfig, args, rawArgs);
7259

7360
// accept the build name from command line if provided
7461
utils.setBuildName(bsConfig, args);
7562

7663
// set cypress config filename
7764
utils.setCypressConfigFilename(bsConfig, args);
78-
79-
if(isBrowserstackInfra) {
80-
// set cypress test suite type
81-
utils.setCypressTestSuiteType(bsConfig);
8265

83-
// set cypress geo location
84-
utils.setGeolocation(bsConfig, args);
66+
// set cypress test suite type
67+
utils.setCypressTestSuiteType(bsConfig);
8568

86-
// set timezone
87-
utils.setTimezone(bsConfig, args);
69+
// set cypress geo location
70+
utils.setGeolocation(bsConfig, args);
71+
72+
// set timezone
73+
utils.setTimezone(bsConfig, args);
74+
75+
// set spec timeout
76+
utils.setSpecTimeout(bsConfig, args);
8877

89-
// set spec timeout
90-
utils.setSpecTimeout(bsConfig, args);
91-
}
92-
9378
// accept the specs list from command line if provided
9479
utils.setUserSpecs(bsConfig, args);
9580

9681
// accept the env list from command line and set it
9782
utils.setTestEnvs(bsConfig, args);
9883

99-
// set build tag caps
100-
utils.setBuildTags(bsConfig, args);
101-
102-
/*
103-
Send build start to Observability
104-
*/
105-
if(isTestObservabilitySession) await launchTestSession(bsConfig, bsConfigPath);
106-
10784
// accept the system env list from bsconf and set it
10885
utils.setSystemEnvs(bsConfig);
10986

110-
if(isBrowserstackInfra) {
111-
//accept the local from env variable if provided
112-
utils.setLocal(bsConfig, args);
87+
//accept the local from env variable if provided
88+
utils.setLocal(bsConfig, args);
11389

114-
//set network logs
115-
utils.setNetworkLogs(bsConfig);
90+
//set network logs
91+
utils.setNetworkLogs(bsConfig);
11692

117-
// set Local Mode (on-demand/ always-on)
118-
utils.setLocalMode(bsConfig, args);
93+
// set Local Mode (on-demand/ always-on)
94+
utils.setLocalMode(bsConfig, args);
11995

120-
//accept the local identifier from env variable if provided
121-
utils.setLocalIdentifier(bsConfig, args);
96+
//accept the local identifier from env variable if provided
97+
utils.setLocalIdentifier(bsConfig, args);
12298

123-
// set Local Config File
124-
utils.setLocalConfigFile(bsConfig, args);
99+
// set Local Config File
100+
utils.setLocalConfigFile(bsConfig, args);
125101

126-
// run test in headed mode
127-
utils.setHeaded(bsConfig, args);
102+
// run test in headed mode
103+
utils.setHeaded(bsConfig, args);
128104

129-
// set the no-wrap
130-
utils.setNoWrap(bsConfig, args);
105+
// set the no-wrap
106+
utils.setNoWrap(bsConfig, args);
131107

132-
// add cypress dependency if missing
133-
utils.setCypressNpmDependency(bsConfig);
134-
}
135-
136-
const { packagesInstalled } = !isBrowserstackInfra ? false : await packageInstaller.packageSetupAndInstaller(bsConfig, config.packageDirName, {markBlockStart, markBlockEnd});
108+
// add cypress dependency if missing
109+
utils.setCypressNpmDependency(bsConfig);
137110

138-
if(isBrowserstackInfra) {
139-
// set node version
140-
utils.setNodeVersion(bsConfig, args);
111+
const { packagesInstalled } = await packageInstaller.packageSetupAndInstaller(bsConfig, config.packageDirName, {markBlockStart, markBlockEnd});
141112

142-
//set browsers
143-
await utils.setBrowsers(bsConfig, args);
113+
// set build tag caps
114+
utils.setBuildTags(bsConfig, args);
115+
// set node version
116+
utils.setNodeVersion(bsConfig, args);
144117

145-
//set config (--config)
146-
utils.setConfig(bsConfig, args);
118+
//set browsers
119+
await utils.setBrowsers(bsConfig, args);
147120

148-
// set sync/async mode (--async/--sync)
149-
utils.setCLIMode(bsConfig, args);
121+
//set config (--config)
122+
utils.setConfig(bsConfig, args);
150123

151-
// set other cypress configs e.g. reporter and reporter-options
152-
utils.setOtherConfigs(bsConfig, args);
153-
}
124+
// set sync/async mode (--async/--sync)
125+
utils.setCLIMode(bsConfig, args);
154126

127+
// set other cypress configs e.g. reporter and reporter-options
128+
utils.setOtherConfigs(bsConfig, args);
155129
markBlockEnd('setConfig');
156130
logger.debug("Completed setting the configs");
157131

158-
if(!isBrowserstackInfra) {
159-
return runCypressTestsLocally(bsConfig, args, rawArgs);
160-
}
161-
162132
// Validate browserstack.json values and parallels specified via arguments
163133
markBlockStart('validateConfig');
164134
logger.debug("Started configs validation");
@@ -317,10 +287,7 @@ module.exports = function run(args, rawArgs) {
317287

318288
logger.info(message);
319289
logger.info(dashboardLink);
320-
if(!args.sync) {
321-
logger.info(Constants.userMessages.EXIT_SYNC_CLI_MESSAGE.replace("<build-id>",data.build_id));
322-
printBuildLink(false);
323-
}
290+
if(!args.sync) logger.info(Constants.userMessages.EXIT_SYNC_CLI_MESSAGE.replace("<build-id>",data.build_id));
324291
let dataToSend = {
325292
time_components: getTimeComponents(),
326293
unique_id: utils.generateUniqueHash(),

bin/helpers/utils.js

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ const usageReporting = require("./usageReporting"),
2121
fileHelpers = require("./fileHelpers"),
2222
config = require("../helpers/config"),
2323
pkg = require('../../package.json'),
24-
transports = require('./logger').transports,
25-
{ findGitConfig, printBuildLink, isTestObservabilitySession, isBrowserstackInfra, shouldReRunObservabilityTests } = require('../testObservability/helper/helper'),
26-
{ OBSERVABILITY_ENV_VARS, TEST_OBSERVABILITY_REPORTER } = require('../testObservability/helper/constants');
24+
transports = require('./logger').transports;
2725

2826
const request = require('request');
2927

@@ -228,7 +226,7 @@ exports.setDefaults = (bsConfig, args) => {
228226
}
229227

230228
// setting cache_dependencies to true if not present
231-
if (bsConfig.run_settings && this.isUndefined(bsConfig.run_settings.cache_dependencies)) {
229+
if (this.isUndefined(bsConfig.run_settings.cache_dependencies)) {
232230
bsConfig.run_settings.cache_dependencies = true;
233231
}
234232

@@ -480,11 +478,6 @@ exports.setNodeVersion = (bsConfig, args) => {
480478
// specs can be passed via command line args as a string
481479
// command line args takes precedence over config
482480
exports.setUserSpecs = (bsConfig, args) => {
483-
if(isBrowserstackInfra() && isTestObservabilitySession() && shouldReRunObservabilityTests()) {
484-
bsConfig.run_settings.specs = process.env.BROWSERSTACK_RERUN_TESTS;
485-
return;
486-
}
487-
488481
let bsConfigSpecs = bsConfig.run_settings.specs;
489482

490483
if (!this.isUndefined(args.specs)) {
@@ -558,19 +551,6 @@ exports.setSystemEnvs = (bsConfig) => {
558551
});
559552
}
560553

561-
try {
562-
OBSERVABILITY_ENV_VARS.forEach(key => {
563-
envKeys[key] = process.env[key];
564-
});
565-
566-
let gitConfigPath = findGitConfig(process.cwd());
567-
if(!isBrowserstackInfra()) process.env.OBSERVABILITY_GIT_CONFIG_PATH_LOCAL = gitConfigPath;
568-
if(gitConfigPath) {
569-
const relativePathFromGitConfig = path.relative(gitConfigPath, process.cwd());
570-
envKeys["OBSERVABILITY_GIT_CONFIG_PATH"] = relativePathFromGitConfig ? relativePathFromGitConfig : 'DEFAULT';
571-
}
572-
} catch(e){}
573-
574554
if (Object.keys(envKeys).length === 0) {
575555
bsConfig.run_settings.system_env_vars = null;
576556
} else {
@@ -1143,11 +1123,7 @@ exports.handleSyncExit = (exitCode, dashboard_url) => {
11431123
syncCliLogger.info(Constants.userMessages.BUILD_REPORT_MESSAGE);
11441124
syncCliLogger.info(dashboard_url);
11451125
}
1146-
if(isTestObservabilitySession()) {
1147-
printBuildLink(true, exitCode);
1148-
} else {
1149-
process.exit(exitCode);
1150-
}
1126+
process.exit(exitCode);
11511127
}
11521128

11531129
exports.getNetworkErrorMessage = (dashboard_url) => {
@@ -1247,12 +1223,6 @@ exports.setConfig = (bsConfig, args) => {
12471223

12481224
// blindly send other passed configs with run_settings and handle at backend
12491225
exports.setOtherConfigs = (bsConfig, args) => {
1250-
if(isTestObservabilitySession() && process.env.BS_TESTOPS_JWT) {
1251-
bsConfig["run_settings"]["reporter"] = TEST_OBSERVABILITY_REPORTER;
1252-
return;
1253-
}
1254-
1255-
/* Non Observability use-case */
12561226
if (!this.isUndefined(args.reporter)) {
12571227
bsConfig["run_settings"]["reporter"] = args.reporter;
12581228
logger.debug(`reporter set to ${args.reporter}`);
@@ -1412,7 +1382,6 @@ async function processExitHandler(exitData){
14121382
logger.warn(Constants.userMessages.PROCESS_KILL_MESSAGE);
14131383
await this.stopBrowserStackBuild(exitData.bsConfig, exitData.args, exitData.buildId, null, exitData.buildReportData);
14141384
await this.stopLocalBinary(exitData.bsConfig, exitData.bsLocalInstance, exitData.args, null, exitData.buildReportData);
1415-
await printBuildLink(true);
14161385
process.exit(0);
14171386
}
14181387

0 commit comments

Comments
 (0)