browserstack-cypress-cli 1.23.0 → 1.24.1

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.
Files changed (40) hide show
  1. package/.github/workflows/Semgrep.yml +48 -0
  2. package/CODEOWNERS +1 -0
  3. package/bin/commands/runs.js +74 -38
  4. package/bin/helpers/constants.js +4 -1
  5. package/bin/helpers/timezone.json +1714 -0
  6. package/bin/helpers/utils.js +55 -3
  7. package/bin/testObservability/crashReporter/index.js +139 -0
  8. package/bin/testObservability/cypress/index.js +158 -0
  9. package/bin/testObservability/helper/constants.js +30 -0
  10. package/bin/testObservability/helper/helper.js +996 -0
  11. package/bin/testObservability/helper/requestQueueHandler.js +88 -0
  12. package/bin/testObservability/plugin/index.js +40 -0
  13. package/bin/testObservability/plugin/ipcClient.js +16 -0
  14. package/bin/testObservability/plugin/ipcServer.js +34 -0
  15. package/bin/testObservability/reporter/index.js +699 -0
  16. package/package.json +8 -2
  17. package/.nyc_output/2807648c-3b13-4cd1-b949-11ce1b846277.json +0 -1
  18. package/.nyc_output/48e04c5a-5723-4547-b9d6-20074786acab.json +0 -1
  19. package/.nyc_output/51e8de95-1005-492b-8e2f-d7c6fc9148e4.json +0 -1
  20. package/.nyc_output/577e3334-ad22-4b05-ac7f-e0038582bb25.json +0 -1
  21. package/.nyc_output/59cc8cf4-849a-4cb5-bc52-0133091e0584.json +0 -1
  22. package/.nyc_output/5fc28c76-8c92-44e9-9bae-ec2e85892509.json +0 -1
  23. package/.nyc_output/5fffbcf8-4572-45c7-948f-38aeb3421a3e.json +0 -1
  24. package/.nyc_output/6b02b68b-ad99-40ff-b34f-218d98a9c773.json +0 -1
  25. package/.nyc_output/6ec27c2e-3529-412c-a82b-d1b8970a52a5.json +0 -1
  26. package/.nyc_output/7540c691-20e7-4eb9-a21e-75f1b22fe6eb.json +0 -1
  27. package/.nyc_output/79dc2aeb-d682-45b3-8430-eea8b886e5ae.json +0 -1
  28. package/.nyc_output/processinfo/2807648c-3b13-4cd1-b949-11ce1b846277.json +0 -1
  29. package/.nyc_output/processinfo/48e04c5a-5723-4547-b9d6-20074786acab.json +0 -1
  30. package/.nyc_output/processinfo/51e8de95-1005-492b-8e2f-d7c6fc9148e4.json +0 -1
  31. package/.nyc_output/processinfo/577e3334-ad22-4b05-ac7f-e0038582bb25.json +0 -1
  32. package/.nyc_output/processinfo/59cc8cf4-849a-4cb5-bc52-0133091e0584.json +0 -1
  33. package/.nyc_output/processinfo/5fc28c76-8c92-44e9-9bae-ec2e85892509.json +0 -1
  34. package/.nyc_output/processinfo/5fffbcf8-4572-45c7-948f-38aeb3421a3e.json +0 -1
  35. package/.nyc_output/processinfo/6b02b68b-ad99-40ff-b34f-218d98a9c773.json +0 -1
  36. package/.nyc_output/processinfo/6ec27c2e-3529-412c-a82b-d1b8970a52a5.json +0 -1
  37. package/.nyc_output/processinfo/7540c691-20e7-4eb9-a21e-75f1b22fe6eb.json +0 -1
  38. package/.nyc_output/processinfo/79dc2aeb-d682-45b3-8430-eea8b886e5ae.json +0 -1
  39. package/.nyc_output/processinfo/index.json +0 -1
  40. package/log/usage.log +0 -15
@@ -0,0 +1,48 @@
1
+ # Name of this GitHub Actions workflow.
2
+ name: Semgrep
3
+
4
+ on:
5
+ # Scan changed files in PRs (diff-aware scanning):
6
+ # The branches below must be a subset of the branches above
7
+ pull_request:
8
+ branches: ["master", "main"]
9
+ push:
10
+ branches: ["master", "main"]
11
+ schedule:
12
+ - cron: '0 6 * * *'
13
+
14
+
15
+ permissions:
16
+ contents: read
17
+
18
+ jobs:
19
+ semgrep:
20
+ # User definable name of this GitHub Actions job.
21
+ permissions:
22
+ contents: read # for actions/checkout to fetch code
23
+ security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
24
+ name: semgrep/ci
25
+ # If you are self-hosting, change the following `runs-on` value:
26
+ runs-on: ubuntu-latest
27
+
28
+ container:
29
+ # A Docker image with Semgrep installed. Do not change this.
30
+ image: returntocorp/semgrep
31
+
32
+ # Skip any PR created by dependabot to avoid permission issues:
33
+ if: (github.actor != 'dependabot[bot]')
34
+
35
+ steps:
36
+ # Fetch project source with GitHub Actions Checkout.
37
+ - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
38
+ # Run the "semgrep ci" command on the command line of the docker image.
39
+ - run: semgrep ci --sarif --output=semgrep.sarif
40
+ env:
41
+ # Add the rules that Semgrep uses by setting the SEMGREP_RULES environment variable.
42
+ SEMGREP_RULES: p/default # more at semgrep.dev/explore
43
+
44
+ - name: Upload SARIF file for GitHub Advanced Security Dashboard
45
+ uses: github/codeql-action/upload-sarif@6c089f53dd51dc3fc7e599c3cb5356453a52ca9e # v2.20.0
46
+ with:
47
+ sarif_file: semgrep.sarif
48
+ if: always()
package/CODEOWNERS ADDED
@@ -0,0 +1 @@
1
+ * @browserstack/afd-dev
@@ -23,6 +23,13 @@ const archiver = require("../helpers/archiver"),
23
23
  packageDiff = require('../helpers/package-diff');
24
24
  const { getStackTraceUrl } = require('../helpers/sync/syncSpecsLogs');
25
25
 
26
+ const {
27
+ launchTestSession,
28
+ setTestObservabilityFlags,
29
+ runCypressTestsLocally,
30
+ printBuildLink
31
+ } = require('../testObservability/helper/helper');
32
+
26
33
  module.exports = function run(args, rawArgs) {
27
34
 
28
35
  markBlockStart('preBuild');
@@ -45,6 +52,12 @@ module.exports = function run(args, rawArgs) {
45
52
  logger.debug('Completed browserstack.json validation');
46
53
  markBlockStart('setConfig');
47
54
  logger.debug('Started setting the configs');
55
+
56
+ /*
57
+ Set testObservability & browserstackAutomation flags
58
+ */
59
+ const [isTestObservabilitySession, isBrowserstackInfra] = setTestObservabilityFlags(bsConfig);
60
+
48
61
  utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting);
49
62
 
50
63
  utils.setDefaults(bsConfig, args);
@@ -55,77 +68,97 @@ module.exports = function run(args, rawArgs) {
55
68
  // accept the access key from command line or env variable if provided
56
69
  utils.setAccessKey(bsConfig, args);
57
70
 
58
- let buildReportData = await getInitialDetails(bsConfig, args, rawArgs);
71
+ let buildReportData = !isBrowserstackInfra ? null : await getInitialDetails(bsConfig, args, rawArgs);
59
72
 
60
73
  // accept the build name from command line if provided
61
74
  utils.setBuildName(bsConfig, args);
62
75
 
63
76
  // set cypress config filename
64
77
  utils.setCypressConfigFilename(bsConfig, args);
78
+
79
+ if(isBrowserstackInfra) {
80
+ // set cypress test suite type
81
+ utils.setCypressTestSuiteType(bsConfig);
65
82
 
66
- // set cypress test suite type
67
- utils.setCypressTestSuiteType(bsConfig);
68
-
69
- // set cypress geo location
70
- utils.setGeolocation(bsConfig, args);
83
+ // set cypress geo location
84
+ utils.setGeolocation(bsConfig, args);
71
85
 
72
- // set spec timeout
73
- utils.setSpecTimeout(bsConfig, args);
86
+ // set timezone
87
+ utils.setTimezone(bsConfig, args);
74
88
 
89
+ // set spec timeout
90
+ utils.setSpecTimeout(bsConfig, args);
91
+ }
92
+
75
93
  // accept the specs list from command line if provided
76
94
  utils.setUserSpecs(bsConfig, args);
77
95
 
78
96
  // accept the env list from command line and set it
79
97
  utils.setTestEnvs(bsConfig, args);
80
98
 
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
+
81
107
  // accept the system env list from bsconf and set it
82
108
  utils.setSystemEnvs(bsConfig);
83
109
 
84
- //accept the local from env variable if provided
85
- utils.setLocal(bsConfig, args);
110
+ if(isBrowserstackInfra) {
111
+ //accept the local from env variable if provided
112
+ utils.setLocal(bsConfig, args);
86
113
 
87
- //set network logs
88
- utils.setNetworkLogs(bsConfig);
114
+ //set network logs
115
+ utils.setNetworkLogs(bsConfig);
89
116
 
90
- // set Local Mode (on-demand/ always-on)
91
- utils.setLocalMode(bsConfig, args);
117
+ // set Local Mode (on-demand/ always-on)
118
+ utils.setLocalMode(bsConfig, args);
92
119
 
93
- //accept the local identifier from env variable if provided
94
- utils.setLocalIdentifier(bsConfig, args);
120
+ //accept the local identifier from env variable if provided
121
+ utils.setLocalIdentifier(bsConfig, args);
95
122
 
96
- // set Local Config File
97
- utils.setLocalConfigFile(bsConfig, args);
123
+ // set Local Config File
124
+ utils.setLocalConfigFile(bsConfig, args);
98
125
 
99
- // run test in headed mode
100
- utils.setHeaded(bsConfig, args);
126
+ // run test in headed mode
127
+ utils.setHeaded(bsConfig, args);
101
128
 
102
- // set the no-wrap
103
- utils.setNoWrap(bsConfig, args);
129
+ // set the no-wrap
130
+ utils.setNoWrap(bsConfig, args);
104
131
 
105
- // add cypress dependency if missing
106
- utils.setCypressNpmDependency(bsConfig);
132
+ // add cypress dependency if missing
133
+ utils.setCypressNpmDependency(bsConfig);
134
+ }
107
135
 
108
- const { packagesInstalled } = await packageInstaller.packageSetupAndInstaller(bsConfig, config.packageDirName, {markBlockStart, markBlockEnd});
136
+ const { packagesInstalled } = !isBrowserstackInfra ? false : await packageInstaller.packageSetupAndInstaller(bsConfig, config.packageDirName, {markBlockStart, markBlockEnd});
109
137
 
110
- // set build tag caps
111
- utils.setBuildTags(bsConfig, args);
112
- // set node version
113
- utils.setNodeVersion(bsConfig, args);
138
+ if(isBrowserstackInfra) {
139
+ // set node version
140
+ utils.setNodeVersion(bsConfig, args);
141
+
142
+ //set browsers
143
+ await utils.setBrowsers(bsConfig, args);
114
144
 
115
- //set browsers
116
- await utils.setBrowsers(bsConfig, args);
145
+ //set config (--config)
146
+ utils.setConfig(bsConfig, args);
117
147
 
118
- //set config (--config)
119
- utils.setConfig(bsConfig, args);
148
+ // set sync/async mode (--async/--sync)
149
+ utils.setCLIMode(bsConfig, args);
120
150
 
121
- // set sync/async mode (--async/--sync)
122
- utils.setCLIMode(bsConfig, args);
151
+ // set other cypress configs e.g. reporter and reporter-options
152
+ utils.setOtherConfigs(bsConfig, args);
153
+ }
123
154
 
124
- // set other cypress configs e.g. reporter and reporter-options
125
- utils.setOtherConfigs(bsConfig, args);
126
155
  markBlockEnd('setConfig');
127
156
  logger.debug("Completed setting the configs");
128
157
 
158
+ if(!isBrowserstackInfra) {
159
+ return runCypressTestsLocally(bsConfig, args, rawArgs);
160
+ }
161
+
129
162
  // Validate browserstack.json values and parallels specified via arguments
130
163
  markBlockStart('validateConfig');
131
164
  logger.debug("Started configs validation");
@@ -284,7 +317,10 @@ module.exports = function run(args, rawArgs) {
284
317
 
285
318
  logger.info(message);
286
319
  logger.info(dashboardLink);
287
- if(!args.sync) logger.info(Constants.userMessages.EXIT_SYNC_CLI_MESSAGE.replace("<build-id>",data.build_id));
320
+ if(!args.sync) {
321
+ logger.info(Constants.userMessages.EXIT_SYNC_CLI_MESSAGE.replace("<build-id>",data.build_id));
322
+ printBuildLink(false);
323
+ }
288
324
  let dataToSend = {
289
325
  time_components: getTimeComponents(),
290
326
  unique_id: utils.generateUniqueHash(),
@@ -85,6 +85,8 @@ const userMessages = {
85
85
  "Your build will run using Cypress <actualVersion> instead of Cypress <preferredVersion>.<frameworkUpgradeMessage> Read more about supported versions here: http://browserstack.com/docs/automate/cypress/supported-versions",
86
86
  LOCAL_START_FAILED: "Local Testing setup failed.",
87
87
  LOCAL_STOP_FAILED: "Local Binary stop failed.",
88
+ INVALID_TIMEZONE:
89
+ 'The timezone specified is invalid. Refer to our documentation page https://www.browserstack.com/docs/automate/cypress/configure-timezones for the supported time zones.',
88
90
  INVALID_LOCAL_MODE_WARNING:
89
91
  'Invalid value specified for local_mode. local_mode: ("always-on" | "on-demand"). For more info, check out https://www.browserstack.com/docs/automate/cypress/cli-reference',
90
92
  LOCAL_BINARY_ALREADY_RUNNING:
@@ -320,7 +322,8 @@ const allowedFileTypes = [
320
322
  "pfx",
321
323
  "cfr",
322
324
  "ico",
323
- "html"
325
+ "html",
326
+ "json5"
324
327
  ];
325
328
 
326
329
  const filesToIgnoreWhileUploading = [