@@ -36,6 +36,7 @@ const {
36
36
checkAccessibilityPlatform,
37
37
supportFileCleanup
38
38
} = require ( '../accessibility-automation/helper' ) ;
39
+ const { isTurboScaleSession, getTurboScaleGridDetails, patchCypressConfigFileContent, atsFileCleanup } = require ( '../helpers/atsHelper' ) ;
39
40
40
41
module . exports = function run ( args , rawArgs ) {
41
42
@@ -66,6 +67,8 @@ module.exports = function run(args, rawArgs) {
66
67
const [ isTestObservabilitySession , isBrowserstackInfra ] = setTestObservabilityFlags ( bsConfig ) ;
67
68
const checkAccessibility = checkAccessibilityPlatform ( bsConfig ) ;
68
69
const isAccessibilitySession = bsConfig . run_settings . accessibility || checkAccessibility ;
70
+ const turboScaleSession = isTurboScaleSession ( bsConfig ) ;
71
+ Constants . turboScaleObj . enabled = turboScaleSession ;
69
72
70
73
utils . setUsageReportingFlag ( bsConfig , args . disableUsageReporting ) ;
71
74
@@ -77,7 +80,7 @@ module.exports = function run(args, rawArgs) {
77
80
// accept the access key from command line or env variable if provided
78
81
utils . setAccessKey ( bsConfig , args ) ;
79
82
80
- let buildReportData = ! isBrowserstackInfra ? null : await getInitialDetails ( bsConfig , args , rawArgs ) ;
83
+ let buildReportData = ( turboScaleSession || ! isBrowserstackInfra ) ? null : await getInitialDetails ( bsConfig , args , rawArgs ) ;
81
84
82
85
// accept the build name from command line if provided
83
86
utils . setBuildName ( bsConfig , args ) ;
@@ -147,6 +150,29 @@ module.exports = function run(args, rawArgs) {
147
150
if ( isAccessibilitySession && isBrowserstackInfra ) {
148
151
await createAccessibilityTestRun ( bsConfig ) ;
149
152
}
153
+
154
+ if ( turboScaleSession ) {
155
+ // Local is only required in case user is running on trial grid and wants to access private website.
156
+ // Even then, it will be spawned separately via browserstack-cli ats connect-grid command and not via browserstack-cypress-cli
157
+ // Hence whenever running on ATS, need to make local as false
158
+ bsConfig . connection_settings . local = false ;
159
+
160
+ const gridDetails = await getTurboScaleGridDetails ( bsConfig , args , rawArgs ) ;
161
+
162
+ if ( gridDetails && Object . keys ( gridDetails ) . length > 0 ) {
163
+ Constants . turboScaleObj . gridDetails = gridDetails ;
164
+ Constants . turboScaleObj . gridUrl = gridDetails . cypressUrl ;
165
+ Constants . turboScaleObj . uploadUrl = gridDetails . cypressUrl + '/upload' ;
166
+ Constants . turboScaleObj . buildUrl = gridDetails . cypressUrl + '/build' ;
167
+
168
+ logger . debug ( `Automate TurboScale Grid URL set to ${ gridDetails . url } ` ) ;
169
+
170
+ patchCypressConfigFileContent ( bsConfig ) ;
171
+ } else {
172
+ process . exitCode = Constants . ERROR_EXIT_CODE ;
173
+ return ;
174
+ }
175
+ }
150
176
}
151
177
152
178
const { packagesInstalled } = ! isBrowserstackInfra ? false : await packageInstaller . packageSetupAndInstaller ( bsConfig , config . packageDirName , { markBlockStart, markBlockEnd} ) ;
@@ -186,7 +212,7 @@ module.exports = function run(args, rawArgs) {
186
212
187
213
//get the number of spec files
188
214
markBlockStart ( 'getNumberOfSpecFiles' ) ;
189
- let specFiles = utils . getNumberOfSpecFiles ( bsConfig , args , cypressConfigFile ) ;
215
+ let specFiles = utils . getNumberOfSpecFiles ( bsConfig , args , cypressConfigFile , turboScaleSession ) ;
190
216
markBlockEnd ( 'getNumberOfSpecFiles' ) ;
191
217
192
218
bsConfig [ 'run_settings' ] [ 'video_config' ] = utils . getVideoConfig ( cypressConfigFile , bsConfig ) ;
@@ -251,6 +277,11 @@ module.exports = function run(args, rawArgs) {
251
277
if ( process . env . BROWSERSTACK_TEST_ACCESSIBILITY === 'true' ) {
252
278
supportFileCleanup ( ) ;
253
279
}
280
+
281
+ if ( turboScaleSession ) {
282
+ atsFileCleanup ( bsConfig ) ;
283
+ }
284
+
254
285
// Set config args for enforce_settings
255
286
if ( ! utils . isUndefinedOrFalse ( bsConfig . run_settings . enforce_settings ) ) {
256
287
markBlockStart ( 'setEnforceSettingsConfig' ) ;
@@ -310,13 +341,13 @@ module.exports = function run(args, rawArgs) {
310
341
logger . debug ( "Completed polling of build status" ) ;
311
342
312
343
// stop the Local instance
313
- await utils . stopLocalBinary ( bsConfig , bs_local , args , rawArgs , buildReportData ) ;
344
+ if ( ! turboScaleSession ) await utils . stopLocalBinary ( bsConfig , bs_local , args , rawArgs , buildReportData ) ;
314
345
315
346
// waiting for 5 secs for upload to complete (as a safety measure)
316
347
await new Promise ( resolve => setTimeout ( resolve , 5000 ) ) ;
317
348
318
349
// download build artifacts
319
- if ( exitCode != Constants . BUILD_FAILED_EXIT_CODE ) {
350
+ if ( exitCode != Constants . BUILD_FAILED_EXIT_CODE && ! turboScaleSession ) {
320
351
if ( utils . nonEmptyArray ( bsConfig . run_settings . downloads ) ) {
321
352
logger . debug ( "Downloading build artifacts" ) ;
322
353
await downloadBuildArtifacts ( bsConfig , data . build_id , args , rawArgs , buildReportData ) ;
@@ -328,7 +359,7 @@ module.exports = function run(args, rawArgs) {
328
359
markBlockEnd ( 'postBuild' ) ;
329
360
utils . handleSyncExit ( exitCode , data . dashboard_url ) ;
330
361
} ) ;
331
- } else {
362
+ } else if ( ! turboScaleSession ) {
332
363
let stacktraceUrl = getStackTraceUrl ( ) ;
333
364
downloadBuildStacktrace ( stacktraceUrl ) . then ( ( message ) => {
334
365
utils . sendUsageReport ( bsConfig , args , message , Constants . messageTypes . SUCCESS , null , buildReportData , rawArgs ) ;
@@ -344,7 +375,7 @@ module.exports = function run(args, rawArgs) {
344
375
} ) ;
345
376
}
346
377
} ) ;
347
- } else if ( utils . nonEmptyArray ( bsConfig . run_settings . downloads ) ) {
378
+ } else if ( utils . nonEmptyArray ( bsConfig . run_settings . downloads && ! turboScaleSession ) ) {
348
379
logger . info ( Constants . userMessages . ASYNC_DOWNLOADS . replace ( '<build-id>' , data . build_id ) ) ;
349
380
}
350
381
0 commit comments