From c0732de1ae7121af4f9d771a155500e33590ebf1 Mon Sep 17 00:00:00 2001 From: Jaydeep Dave Date: Sun, 20 Oct 2024 20:06:47 +0530 Subject: [PATCH 1/8] changes --- bin/commands/runs.js | 2 +- bin/helpers/config.js | 2 +- bin/helpers/reporterHTML.js | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/commands/runs.js b/bin/commands/runs.js index 57a6d0f9..f5bd9e24 100644 --- a/bin/commands/runs.js +++ b/bin/commands/runs.js @@ -365,7 +365,7 @@ module.exports = function run(args, rawArgs) { await new Promise(resolve => setTimeout(resolve, 5000)); // download build artifacts - if (exitCode != Constants.BUILD_FAILED_EXIT_CODE && !turboScaleSession) { + if (exitCode != Constants.BUILD_FAILED_EXIT_CODE) { if (utils.nonEmptyArray(bsConfig.run_settings.downloads)) { logger.debug("Downloading build artifacts"); await downloadBuildArtifacts(bsConfig, data.build_id, args, rawArgs, buildReportData); diff --git a/bin/helpers/config.js b/bin/helpers/config.js index e689a61c..5be6a339 100644 --- a/bin/helpers/config.js +++ b/bin/helpers/config.js @@ -29,6 +29,6 @@ config.configJsonFileName = 'tmpCypressConfig.json'; // turboScale config.turboScaleMd5Sum = `${config.turboScaleUrl}/md5sumcheck`; -config.turboScaleBuildsUrl = `${config.turboScaleUrl}/builds`; +config.turboScaleBuildsUrl = `${config.turboScaleAPIUrl}/builds`; module.exports = config; diff --git a/bin/helpers/reporterHTML.js b/bin/helpers/reporterHTML.js index 5859b103..beb087c7 100644 --- a/bin/helpers/reporterHTML.js +++ b/bin/helpers/reporterHTML.js @@ -19,6 +19,10 @@ let reportGenerator = (bsConfig, buildId, args, rawArgs, buildReportData, cb) => }, }; + if (Constants.turboScaleObj.enabled) { + options.url = `${config.turboScaleBuildsUrl}/${buildId}/custom_report`; + } + logger.debug('Started fetching the build json and html reports.'); return request.get(options, async function (err, resp, body) { From bb179a17e1b5e1258b492ffeb108060078c70297 Mon Sep 17 00:00:00 2001 From: Jaydeep Dave Date: Wed, 23 Oct 2024 14:45:24 +0530 Subject: [PATCH 2/8] changes --- bin/commands/generateReport.js | 16 ++++++++-------- bin/helpers/config.js | 2 +- bin/helpers/config.json | 4 ++-- bin/helpers/reporterHTML.js | 3 ++- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/bin/commands/generateReport.js b/bin/commands/generateReport.js index 81c6fab8..72e219f3 100644 --- a/bin/commands/generateReport.js +++ b/bin/commands/generateReport.js @@ -5,13 +5,13 @@ const logger = require("../helpers/logger").winstonLogger, utils = require("../helpers/utils"), reporterHTML = require('../helpers/reporterHTML'), getInitialDetails = require('../helpers/getInitialDetails').getInitialDetails; - - +const { isTurboScaleSession } = require('../helpers/atsHelper'); + module.exports = function generateReport(args, rawArgs) { let bsConfigPath = utils.getConfigPath(args.cf); let reportGenerator = reporterHTML.reportGenerator; - return utils.validateBstackJson(bsConfigPath).then(function (bsConfig) { + return utils.validateBstackJson(bsConfigPath).then(async function (bsConfig) { // setting setDefaults to {} if not present and set via env variables or via args. utils.setDefaults(bsConfig, args); @@ -21,9 +21,9 @@ module.exports = function generateReport(args, rawArgs) { // accept the access key from command line if provided utils.setAccessKey(bsConfig, args); - getInitialDetails(bsConfig, args, rawArgs).then((buildReportData) => { - - utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting); + try { + let buildReportData = isTurboScaleSession(bsConfig) ? null : await getInitialDetails(bsConfig, args, rawArgs); + utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting); // set cypress config filename utils.setCypressConfigFilename(bsConfig, args); @@ -34,9 +34,9 @@ module.exports = function generateReport(args, rawArgs) { reportGenerator(bsConfig, buildId, args, rawArgs, buildReportData); utils.sendUsageReport(bsConfig, args, 'generate-report called', messageType, errorCode, buildReportData, rawArgs); - }).catch((err) => { + } catch(err) { logger.warn(err); - }); + }; }).catch(function (err) { logger.error(err); utils.setUsageReportingFlag(null, args.disableUsageReporting); diff --git a/bin/helpers/config.js b/bin/helpers/config.js index 5be6a339..e689a61c 100644 --- a/bin/helpers/config.js +++ b/bin/helpers/config.js @@ -29,6 +29,6 @@ config.configJsonFileName = 'tmpCypressConfig.json'; // turboScale config.turboScaleMd5Sum = `${config.turboScaleUrl}/md5sumcheck`; -config.turboScaleBuildsUrl = `${config.turboScaleAPIUrl}/builds`; +config.turboScaleBuildsUrl = `${config.turboScaleUrl}/builds`; module.exports = config; diff --git a/bin/helpers/config.json b/bin/helpers/config.json index 0ad3ce93..011edf5c 100644 --- a/bin/helpers/config.json +++ b/bin/helpers/config.json @@ -4,6 +4,6 @@ "dashboardUrl": "https://automate.browserstack.com/dashboard/v2/builds/", "usageReportingUrl": "https://eds.browserstack.com:443/send_event_cy_internal", "localTestingListUrl": "https://www.browserstack.com/local/v1/list", - "turboScaleUrl": "https://grid.browserstack.com/packages/cypress", - "turboScaleAPIUrl": "https://api.browserstack.com/automate-turboscale/v1" + "turboScaleUrl": "http://grid-api-devhst.bsstag.com/packages/cypress", + "turboScaleAPIUrl": "http://grid-api-devhst.bsstag.com/automate-turboscale/v1" } diff --git a/bin/helpers/reporterHTML.js b/bin/helpers/reporterHTML.js index beb087c7..6cf2dfdc 100644 --- a/bin/helpers/reporterHTML.js +++ b/bin/helpers/reporterHTML.js @@ -6,6 +6,7 @@ const fs = require('fs'), Constants = require('./constants'), config = require("./config"), decompress = require('decompress'); +const { isTurboScaleSession } = require('../helpers/atsHelper'); let reportGenerator = (bsConfig, buildId, args, rawArgs, buildReportData, cb) => { let options = { @@ -19,7 +20,7 @@ let reportGenerator = (bsConfig, buildId, args, rawArgs, buildReportData, cb) => }, }; - if (Constants.turboScaleObj.enabled) { + if (isTurboScaleSession(bsConfig)) { options.url = `${config.turboScaleBuildsUrl}/${buildId}/custom_report`; } From fd6b752ab6d7bbdb785a495f1baf398d06ffe630 Mon Sep 17 00:00:00 2001 From: Jaydeep Dave Date: Wed, 23 Oct 2024 14:48:22 +0530 Subject: [PATCH 3/8] changes --- bin/helpers/config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/helpers/config.json b/bin/helpers/config.json index 011edf5c..0ad3ce93 100644 --- a/bin/helpers/config.json +++ b/bin/helpers/config.json @@ -4,6 +4,6 @@ "dashboardUrl": "https://automate.browserstack.com/dashboard/v2/builds/", "usageReportingUrl": "https://eds.browserstack.com:443/send_event_cy_internal", "localTestingListUrl": "https://www.browserstack.com/local/v1/list", - "turboScaleUrl": "http://grid-api-devhst.bsstag.com/packages/cypress", - "turboScaleAPIUrl": "http://grid-api-devhst.bsstag.com/automate-turboscale/v1" + "turboScaleUrl": "https://grid.browserstack.com/packages/cypress", + "turboScaleAPIUrl": "https://api.browserstack.com/automate-turboscale/v1" } From b13ee0459c5db6a5cbeedf58e79a2b60f5f7709b Mon Sep 17 00:00:00 2001 From: Jaydeep Dave Date: Wed, 23 Oct 2024 17:30:17 +0530 Subject: [PATCH 4/8] changes --- bin/commands/generateReport.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/commands/generateReport.js b/bin/commands/generateReport.js index 72e219f3..af375005 100644 --- a/bin/commands/generateReport.js +++ b/bin/commands/generateReport.js @@ -6,7 +6,7 @@ const logger = require("../helpers/logger").winstonLogger, reporterHTML = require('../helpers/reporterHTML'), getInitialDetails = require('../helpers/getInitialDetails').getInitialDetails; const { isTurboScaleSession } = require('../helpers/atsHelper'); - + module.exports = function generateReport(args, rawArgs) { let bsConfigPath = utils.getConfigPath(args.cf); let reportGenerator = reporterHTML.reportGenerator; From 7b3ad255e4a512bfc5d0d48bbaf0eff505334819 Mon Sep 17 00:00:00 2001 From: Jaydeep Dave Date: Fri, 25 Oct 2024 13:18:54 +0530 Subject: [PATCH 5/8] added user agent in caps --- bin/helpers/capabilityHelper.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/helpers/capabilityHelper.js b/bin/helpers/capabilityHelper.js index ae09e260..df0b2b05 100644 --- a/bin/helpers/capabilityHelper.js +++ b/bin/helpers/capabilityHelper.js @@ -131,6 +131,9 @@ const caps = (bsConfig, zip) => { obj.run_settings = JSON.stringify(bsConfig.run_settings); } + obj.cypress_cli_version = Utils.getUserAgent(); + logger.info(`Cypress CLI User Agent: ${obj.cypress_cli_version}`); + if(obj.parallels === Constants.cliMessages.RUN.DEFAULT_PARALLEL_MESSAGE) obj.parallels = undefined if (obj.project) logger.info(`Project name is: ${obj.project}`); From 4a702127c8167ddc660765d8ffa5aeae93ef872d Mon Sep 17 00:00:00 2001 From: Jaydeep Dave Date: Fri, 25 Oct 2024 16:42:48 +0530 Subject: [PATCH 6/8] changes --- bin/helpers/capabilityHelper.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/helpers/capabilityHelper.js b/bin/helpers/capabilityHelper.js index df0b2b05..0467c154 100644 --- a/bin/helpers/capabilityHelper.js +++ b/bin/helpers/capabilityHelper.js @@ -131,8 +131,8 @@ const caps = (bsConfig, zip) => { obj.run_settings = JSON.stringify(bsConfig.run_settings); } - obj.cypress_cli_version = Utils.getUserAgent(); - logger.info(`Cypress CLI User Agent: ${obj.cypress_cli_version}`); + obj.cypress_cli_user_agent = Utils.getUserAgent(); + logger.info(`Cypress CLI User Agent: ${obj.cypress_cli_user_agent}`); if(obj.parallels === Constants.cliMessages.RUN.DEFAULT_PARALLEL_MESSAGE) obj.parallels = undefined From 0e7da87398d2335ad378036e21660ecece86a4ab Mon Sep 17 00:00:00 2001 From: Jaydeep Dave Date: Mon, 28 Oct 2024 11:39:24 +0530 Subject: [PATCH 7/8] changes --- bin/commands/runs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/commands/runs.js b/bin/commands/runs.js index f5bd9e24..dc34df07 100644 --- a/bin/commands/runs.js +++ b/bin/commands/runs.js @@ -366,7 +366,7 @@ module.exports = function run(args, rawArgs) { // download build artifacts if (exitCode != Constants.BUILD_FAILED_EXIT_CODE) { - if (utils.nonEmptyArray(bsConfig.run_settings.downloads)) { + if (utils.nonEmptyArray(bsConfig.run_settings.downloads) && !turboScaleSession) { logger.debug("Downloading build artifacts"); await downloadBuildArtifacts(bsConfig, data.build_id, args, rawArgs, buildReportData); } From e3370e9474f977378490d118f20c937bd2a9c40b Mon Sep 17 00:00:00 2001 From: Ankit Singh <2501.ankit@gmail.com> Date: Mon, 28 Oct 2024 16:07:14 +0530 Subject: [PATCH 8/8] add: turboscale build_artifact url --- bin/commands/runs.js | 4 ++-- bin/helpers/buildArtifacts.js | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/bin/commands/runs.js b/bin/commands/runs.js index 57a6d0f9..baa04b12 100644 --- a/bin/commands/runs.js +++ b/bin/commands/runs.js @@ -365,10 +365,10 @@ module.exports = function run(args, rawArgs) { await new Promise(resolve => setTimeout(resolve, 5000)); // download build artifacts - if (exitCode != Constants.BUILD_FAILED_EXIT_CODE && !turboScaleSession) { + if (exitCode != Constants.BUILD_FAILED_EXIT_CODE) { if (utils.nonEmptyArray(bsConfig.run_settings.downloads)) { logger.debug("Downloading build artifacts"); - await downloadBuildArtifacts(bsConfig, data.build_id, args, rawArgs, buildReportData); + await downloadBuildArtifacts(bsConfig, data.build_id, args, rawArgs, buildReportData, turboScaleSession); } // Generate custom report! diff --git a/bin/helpers/buildArtifacts.js b/bin/helpers/buildArtifacts.js index 844ad3b6..cd064fa7 100644 --- a/bin/helpers/buildArtifacts.js +++ b/bin/helpers/buildArtifacts.js @@ -213,13 +213,15 @@ const sendUpdatesToBstack = async (bsConfig, buildId, args, options, rawArgs, bu }); } -exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs, buildReportData = null) => { +exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs, buildReportData = null, isTurboScaleSession = false) => { return new Promise ( async (resolve, reject) => { BUILD_ARTIFACTS_FAIL_COUNT = 0; BUILD_ARTIFACTS_TOTAL_COUNT = 0; let options = { - url: `${config.buildUrl}${buildId}/build_artifacts`, + url: isTurboScaleSession + ? `${config.turboScaleBuildsUrl}/${buildId}/build_artifacts` + : `${config.buildUrl}${buildId}/build_artifacts`, auth: { username: bsConfig.auth.username, password: bsConfig.auth.access_key,