From f03253c8afa742c00e9ba384a14b125ec4239b1b Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Wed, 16 Nov 2022 17:19:53 -0600 Subject: [PATCH 01/27] fix: add v8 snapshot usage to cypress in cypress testing --- npm/vite-dev-server/cypress.config.ts | 1 + npm/vite-dev-server/package.json | 2 +- npm/webpack-dev-server/cypress.config.ts | 1 + npm/webpack-dev-server/package.json | 2 +- packages/app/cypress.config.ts | 1 + packages/app/package.json | 2 +- packages/config/package.json | 2 +- .../data-context/src/data/ProjectConfigIpc.ts | 9 ++++++- packages/launchpad/cypress.config.ts | 1 + packages/launchpad/package.json | 9 ++++--- packages/packherd-require/src/loader.ts | 7 ----- packages/server/index.js | 26 ++++++++++++++++--- yarn.lock | 2 +- 13 files changed, 45 insertions(+), 20 deletions(-) diff --git a/npm/vite-dev-server/cypress.config.ts b/npm/vite-dev-server/cypress.config.ts index 9109a38747ae..32291276d731 100644 --- a/npm/vite-dev-server/cypress.config.ts +++ b/npm/vite-dev-server/cypress.config.ts @@ -12,6 +12,7 @@ export default defineConfig({ // Delete this as we only want to honor it on parent Cypress when doing E2E Cypress in Cypress testing delete process.env.HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS + delete process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF = 'true' process.env.CYPRESS_INTERNAL_VITE_OPEN_MODE_TESTING = 'true' const { e2ePluginSetup } = require('@packages/frontend-shared/cypress/e2e/e2ePluginSetup') as typeof import('@packages/frontend-shared/cypress/e2e/e2ePluginSetup') diff --git a/npm/vite-dev-server/package.json b/npm/vite-dev-server/package.json index ac9f49f2a45e..78a9827175d9 100644 --- a/npm/vite-dev-server/package.json +++ b/npm/vite-dev-server/package.json @@ -8,7 +8,7 @@ "build-prod": "tsc || echo 'built, with type errors'", "check-ts": "tsc --noEmit", "cypress:run": "yarn cypress:run-cypress-in-cypress node ../../scripts/cypress run --project . --browser chrome", - "cypress:run-cypress-in-cypress": "cross-env HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS=http://localhost:4455 CYPRESS_REMOTE_DEBUGGING_PORT=6666 TZ=America/New_York", + "cypress:run-cypress-in-cypress": "cross-env CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT=1 HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS=http://localhost:4455 CYPRESS_REMOTE_DEBUGGING_PORT=6666 TZ=America/New_York", "cypress:open": "yarn cypress:run-cypress-in-cypress gulp open --project .", "watch": "tsc -w", "test": "yarn test-unit", diff --git a/npm/webpack-dev-server/cypress.config.ts b/npm/webpack-dev-server/cypress.config.ts index 3f0809d05ca5..204d392c906d 100644 --- a/npm/webpack-dev-server/cypress.config.ts +++ b/npm/webpack-dev-server/cypress.config.ts @@ -11,6 +11,7 @@ export default defineConfig({ // Delete this as we only want to honor it on parent Cypress when doing E2E Cypress in Cypress testing delete process.env.HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS + delete process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF = 'true' const { e2ePluginSetup } = require('@packages/frontend-shared/cypress/e2e/e2ePluginSetup') as typeof import('@packages/frontend-shared/cypress/e2e/e2ePluginSetup') diff --git a/npm/webpack-dev-server/package.json b/npm/webpack-dev-server/package.json index 810ddf973f9e..3785cffa6b5d 100644 --- a/npm/webpack-dev-server/package.json +++ b/npm/webpack-dev-server/package.json @@ -11,7 +11,7 @@ "dev": "tsc --watch", "clean": "rimraf dist", "cypress:run": "yarn cypress:run-cypress-in-cypress node ../../scripts/cypress run --project . --browser chrome", - "cypress:run-cypress-in-cypress": "cross-env HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS=http://localhost:4455 CYPRESS_REMOTE_DEBUGGING_PORT=6666 TZ=America/New_York", + "cypress:run-cypress-in-cypress": "cross-env CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT=1 HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS=http://localhost:4455 CYPRESS_REMOTE_DEBUGGING_PORT=6666 TZ=America/New_York", "cypress:open": "yarn cypress:run-cypress-in-cypress gulp open --project .", "test": "yarn test-unit", "test-unit": "mocha -r ts-node/register/transpile-only --config ./test/.mocharc.js" diff --git a/packages/app/cypress.config.ts b/packages/app/cypress.config.ts index 712790a64fe5..2360a07f2c60 100644 --- a/packages/app/cypress.config.ts +++ b/packages/app/cypress.config.ts @@ -34,6 +34,7 @@ export default defineConfig({ // Delete this as we only want to honor it on parent Cypress when doing E2E Cypress in Cypress testing delete process.env.HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS + delete process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF = 'true' process.env.CYPRESS_INTERNAL_VITE_OPEN_MODE_TESTING = 'true' // process.env.DEBUG = '*' diff --git a/packages/app/package.json b/packages/app/package.json index f748e6418b45..7fb4c4fc7444 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -8,7 +8,7 @@ "clean": "rimraf dist && rimraf ./node_modules/.vite && echo 'cleaned'", "clean-deps": "rimraf node_modules", "test": "echo 'ok'", - "cypress:run-cypress-in-cypress": "cross-env HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS=http://localhost:4455 CYPRESS_REMOTE_DEBUGGING_PORT=6666 TZ=America/New_York", + "cypress:run-cypress-in-cypress": "cross-env CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT=1 HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS=http://localhost:4455 CYPRESS_REMOTE_DEBUGGING_PORT=6666 TZ=America/New_York", "cypress:launch": "yarn cypress:run-cypress-in-cypress gulp open --project .", "cypress:open": "yarn cypress:run-cypress-in-cypress gulp open --project .", "cypress:run:ct": "yarn cypress:run-cypress-in-cypress node ../../scripts/cypress run --component --project .", diff --git a/packages/config/package.json b/packages/config/package.json index c667b832c518..a59796af15eb 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -20,7 +20,7 @@ "@babel/parser": "^7", "@babel/plugin-syntax-typescript": "^7", "@babel/plugin-transform-typescript": "^7", - "@babel/traverse": "^7", + "@babel/traverse": "7.15.4", "@babel/types": "^7", "check-more-types": "2.24.0", "common-tags": "1.8.0", diff --git a/packages/data-context/src/data/ProjectConfigIpc.ts b/packages/data-context/src/data/ProjectConfigIpc.ts index 3a96e89f9912..a5cbb7215338 100644 --- a/packages/data-context/src/data/ProjectConfigIpc.ts +++ b/packages/data-context/src/data/ProjectConfigIpc.ts @@ -1,7 +1,7 @@ /* eslint-disable no-dupe-class-members */ import { CypressError, getError } from '@packages/errors' import type { FullConfig, TestingType } from '@packages/types' -import { ChildProcess, fork, ForkOptions } from 'child_process' +import { ChildProcess, fork, ForkOptions, spawn } from 'child_process' import EventEmitter from 'events' import fs from 'fs-extra' import path from 'path' @@ -310,6 +310,13 @@ export class ProjectConfigIpc extends EventEmitter { debug(`no typescript found, just use regular Node.js`) } + if (process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT) { + return spawn(process.execPath, ['--entryPoint', CHILD_PROCESS_FILE_PATH, ...configProcessArgs], { + ...childOptions, + stdio: ['pipe', 'pipe', 'pipe', 'ipc'], + }) + } + return fork(CHILD_PROCESS_FILE_PATH, configProcessArgs, childOptions) } diff --git a/packages/launchpad/cypress.config.ts b/packages/launchpad/cypress.config.ts index 83b60d158c03..71ab5456fda9 100644 --- a/packages/launchpad/cypress.config.ts +++ b/packages/launchpad/cypress.config.ts @@ -28,6 +28,7 @@ export default defineConfig({ baseUrl: 'http://localhost:5555', supportFile: 'cypress/e2e/support/e2eSupport.ts', async setupNodeEvents (on, config) { + delete process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF = 'true' const { e2ePluginSetup } = require('@packages/frontend-shared/cypress/e2e/e2ePluginSetup') diff --git a/packages/launchpad/package.json b/packages/launchpad/package.json index 1a991b217a93..c2c2c25632df 100644 --- a/packages/launchpad/package.json +++ b/packages/launchpad/package.json @@ -9,10 +9,11 @@ "clean-deps": "rimraf node_modules", "test": "yarn cypress:run:ct && yarn types", "windi": "yarn windicss-analysis", - "cypress:open": "cross-env TZ=America/New_York gulp open --project .", - "cypress:open:ct": "cross-env TZ=America/New_York gulp open --component --project .", - "cypress:run:ct": "cross-env TZ=America/New_York node ../../scripts/cypress run --component --project .", - "cypress:run:e2e": "cross-env TZ=America/New_York node ../../scripts/cypress run --e2e --project .", + "cypress:run-cypress-in-cypress": "cross-env CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT=1 TZ=America/New_York", + "cypress:open": "yarn cypress:run-cypress-in-cypress gulp open --project .", + "cypress:open:ct": "yarn cypress:run-cypress-in-cypress gulp open --component --project .", + "cypress:run:ct": "yarn cypress:run-cypress-in-cypress node ../../scripts/cypress run --component --project .", + "cypress:run:e2e": "yarn cypress:run-cypress-in-cypress node ../../scripts/cypress run --e2e --project .", "dev": "yarn gulp dev --project .", "start": "echo 'run yarn dev from the root' && exit 1", "watch": "echo 'run yarn dev from the root' && exit 1" diff --git a/packages/packherd-require/src/loader.ts b/packages/packherd-require/src/loader.ts index f395aae9ec0b..63f612a3c8be 100644 --- a/packages/packherd-require/src/loader.ts +++ b/packages/packherd-require/src/loader.ts @@ -12,8 +12,6 @@ import { strict as assert } from 'assert' const logDebug = debug('cypress-verbose:packherd:debug') const logTrace = debug('cypress-verbose:packherd:trace') -const logSilly = debug('cypress-verbose:packherd:silly') -const logWarn = debug('cypress:packherd:warn') /** * Provides information that is used to resolve a module's key from its URI. @@ -869,11 +867,6 @@ export class PackherdModuleLoader { this.definitionHits.add(mod.id) return { mod, origin } - } catch (err: any) { - logWarn(err.message) - logSilly(err) - - return { mod: undefined, origin } } finally { this.loading.finish(fullPath) } diff --git a/packages/server/index.js b/packages/server/index.js index ad10f8c50a7b..03958c2cfcc4 100644 --- a/packages/server/index.js +++ b/packages/server/index.js @@ -1,6 +1,20 @@ -const { initializeStartTime } = require('./lib/util/performance_benchmark') +const runChildProcess = async (entryPoint) => { + require('./lib/plugins/child/register_ts_node') + if (require.name !== 'customRequire') { + // Purposefully make this a dynamic require so that it doesn't have the potential to get picked up by snapshotting mechanism + const hook = './hook' + + const { hookRequire } = require(`${hook}-require`) + + hookRequire(false) + } + + require(entryPoint) +} + +const runMainProcess = async () => { + const { initializeStartTime } = require('./lib/util/performance_benchmark') -const run = async () => { initializeStartTime() if (require.name !== 'customRequire') { @@ -15,4 +29,10 @@ const run = async () => { await require('./server-entry') } -module.exports = run() +const { entryPoint } = require('minimist')(process.argv.slice(1)) + +if (entryPoint) { + module.exports = runChildProcess(entryPoint) +} else { + module.exports = runMainProcess() +} diff --git a/yarn.lock b/yarn.lock index 6cf60f529def..8b3d1507f2be 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2204,7 +2204,7 @@ debug "^4.1.0" globals "^11.1.0" -"@babel/traverse@^7", "@babel/traverse@^7.0.0", "@babel/traverse@^7.1.0", "@babel/traverse@^7.13.0", "@babel/traverse@^7.15.4", "@babel/traverse@^7.16.7", "@babel/traverse@^7.16.8", "@babel/traverse@^7.17.3", "@babel/traverse@^7.17.9", "@babel/traverse@^7.4.3", "@babel/traverse@^7.6.0", "@babel/traverse@^7.7.0", "@babel/traverse@^7.9.0": +"@babel/traverse@^7.0.0", "@babel/traverse@^7.1.0", "@babel/traverse@^7.13.0", "@babel/traverse@^7.15.4", "@babel/traverse@^7.16.7", "@babel/traverse@^7.16.8", "@babel/traverse@^7.17.3", "@babel/traverse@^7.17.9", "@babel/traverse@^7.4.3", "@babel/traverse@^7.6.0", "@babel/traverse@^7.7.0", "@babel/traverse@^7.9.0": version "7.17.9" resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.17.9.tgz#1f9b207435d9ae4a8ed6998b2b82300d83c37a0d" integrity sha512-PQO8sDIJ8SIwipTPiR71kJQCKQYB5NGImbOviK8K+kg5xkNSYXLBupuX9QhatFowrsvo9Hj8WgArg3W7ijNAQw== From 65580d92f45e9e09fc5e8b56f49169ff655b2403 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Wed, 16 Nov 2022 19:08:37 -0600 Subject: [PATCH 02/27] fix linux build --- .circleci/config.yml | 10 +++++----- packages/data-context/src/data/ProjectConfigIpc.ts | 13 +++++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ece7fad43a0c..5d401a3a1f80 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,7 +27,7 @@ mainBuildFilters: &mainBuildFilters branches: only: - develop - - 'ryanm/fix/typescript-issue' + - 'ryanm/fix/cy-in-cy-and-v8-snapshots' # usually we don't build Mac app - it takes a long time # but sometimes we want to really confirm we are doing the right thing @@ -36,7 +36,7 @@ macWorkflowFilters: &darwin-workflow-filters when: or: - equal: [ develop, << pipeline.git.branch >> ] - - equal: [ 'ryanm/fix/typescript-issue', << pipeline.git.branch >> ] + - equal: [ 'ryanm/fix/cy-in-cy-and-v8-snapshots', << pipeline.git.branch >> ] - matches: pattern: "-release$" value: << pipeline.git.branch >> @@ -45,7 +45,7 @@ linuxArm64WorkflowFilters: &linux-arm64-workflow-filters when: or: - equal: [ develop, << pipeline.git.branch >> ] - - equal: [ 'ryanm/fix/typescript-issue', << pipeline.git.branch >> ] + - equal: [ 'ryanm/fix/cy-in-cy-and-v8-snapshots', << pipeline.git.branch >> ] - matches: pattern: "-release$" value: << pipeline.git.branch >> @@ -63,7 +63,7 @@ windowsWorkflowFilters: &windows-workflow-filters when: or: - equal: [ develop, << pipeline.git.branch >> ] - - equal: [ 'ryanm/fix/typescript-issue', << pipeline.git.branch >> ] + - equal: [ 'ryanm/fix/cy-in-cy-and-v8-snapshots', << pipeline.git.branch >> ] - matches: pattern: "-release$" value: << pipeline.git.branch >> @@ -130,7 +130,7 @@ commands: - run: name: Check current branch to persist artifacts command: | - if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "ryanm/fix/typescript-issue" ]]; then + if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "ryanm/fix/cy-in-cy-and-v8-snapshots" ]]; then echo "Not uploading artifacts or posting install comment for this branch." circleci-agent step halt fi diff --git a/packages/data-context/src/data/ProjectConfigIpc.ts b/packages/data-context/src/data/ProjectConfigIpc.ts index a5cbb7215338..c441c4be01fb 100644 --- a/packages/data-context/src/data/ProjectConfigIpc.ts +++ b/packages/data-context/src/data/ProjectConfigIpc.ts @@ -10,6 +10,7 @@ import debugLib from 'debug' import { autoBindDebug, hasTypeScriptInstalled, toPosix } from '../util' import _ from 'lodash' import { pathToFileURL } from 'url' +import os from 'os' const pkg = require('@packages/root') const debug = debugLib(`cypress:lifecycle:ProjectConfigIpc`) @@ -21,6 +22,14 @@ const tsNode = toPosix(require.resolve('@packages/server/lib/plugins/child/regis export type IpcHandler = (ipc: ProjectConfigIpc) => void +/** + * If running as root on Linux, no-sandbox must be passed or Chrome will not start + */ +const isSandboxNeeded = () => { + // eslint-disable-next-line no-restricted-properties + return (os.platform() === 'linux') && (process.geteuid && process.geteuid() === 0) +} + export interface SetupNodeEventsReply { setupConfig: Cypress.ConfigOptions | null requires: string[] @@ -311,6 +320,10 @@ export class ProjectConfigIpc extends EventEmitter { } if (process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT) { + if (isSandboxNeeded()) { + configProcessArgs.push('--no-sandbox') + } + return spawn(process.execPath, ['--entryPoint', CHILD_PROCESS_FILE_PATH, ...configProcessArgs], { ...childOptions, stdio: ['pipe', 'pipe', 'pipe', 'ipc'], From 6684f14b6d5af6c467330423555ad1e2a44fe82e Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Wed, 16 Nov 2022 21:04:09 -0600 Subject: [PATCH 03/27] ensure that snapshot is only used on e2e --- packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts | 9 +++++++++ packages/server/index.js | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts b/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts index fb8cbb5c8057..2faca21e56e5 100644 --- a/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts +++ b/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts @@ -1,3 +1,12 @@ +if (require.name !== 'customRequire') { + // Purposefully make this a dynamic require so that it doesn't have the potential to get picked up by snapshotting mechanism + const hook = '@packages/server/hook' + + const { hookRequire } = require(`${hook}-require`) + + hookRequire(false) +} + import path from 'path' import execa from 'execa' diff --git a/packages/server/index.js b/packages/server/index.js index 03958c2cfcc4..d1dce918085e 100644 --- a/packages/server/index.js +++ b/packages/server/index.js @@ -1,14 +1,5 @@ const runChildProcess = async (entryPoint) => { require('./lib/plugins/child/register_ts_node') - if (require.name !== 'customRequire') { - // Purposefully make this a dynamic require so that it doesn't have the potential to get picked up by snapshotting mechanism - const hook = './hook' - - const { hookRequire } = require(`${hook}-require`) - - hookRequire(false) - } - require(entryPoint) } From e2d06d1030ffe2a85705dac6868b041d2a560dbe Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Thu, 17 Nov 2022 09:05:44 -0600 Subject: [PATCH 04/27] fix ci --- packages/data-context/src/data/ProjectConfigIpc.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/data-context/src/data/ProjectConfigIpc.ts b/packages/data-context/src/data/ProjectConfigIpc.ts index c441c4be01fb..b1023406ab5b 100644 --- a/packages/data-context/src/data/ProjectConfigIpc.ts +++ b/packages/data-context/src/data/ProjectConfigIpc.ts @@ -319,11 +319,11 @@ export class ProjectConfigIpc extends EventEmitter { debug(`no typescript found, just use regular Node.js`) } - if (process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT) { - if (isSandboxNeeded()) { - configProcessArgs.push('--no-sandbox') - } + if (isSandboxNeeded()) { + configProcessArgs.push('--no-sandbox') + } + if (process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT) { return spawn(process.execPath, ['--entryPoint', CHILD_PROCESS_FILE_PATH, ...configProcessArgs], { ...childOptions, stdio: ['pipe', 'pipe', 'pipe', 'ipc'], From 67d736686737d3ded320a14dc0f71daf7a4f733f Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Thu, 17 Nov 2022 13:05:15 -0600 Subject: [PATCH 05/27] add debugging --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5d401a3a1f80..0bb404cbffd8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1618,6 +1618,7 @@ jobs: percy: << parameters.percy >> package: app type: e2e + debug: 'cypress:*' driver-integration-tests-chrome: <<: *defaults From a45ca79791ea7a12f83b9545e385855c91440b99 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Mon, 28 Nov 2022 09:11:09 -0600 Subject: [PATCH 06/27] Empty commit From a5388d9636527cd14fe4d8398f9da61fae4eb8ba Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Mon, 28 Nov 2022 10:16:13 -0600 Subject: [PATCH 07/27] enable more debugging --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0bb404cbffd8..37ebd6e24809 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1618,7 +1618,7 @@ jobs: percy: << parameters.percy >> package: app type: e2e - debug: 'cypress:*' + debug: 'cypress*packh*' driver-integration-tests-chrome: <<: *defaults From 92c21ad842e2d65734bb341af4dea9c4a7e246cc Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Mon, 28 Nov 2022 10:20:08 -0600 Subject: [PATCH 08/27] enable more debugging --- system-tests/projects/component-tests/package.json | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 system-tests/projects/component-tests/package.json diff --git a/system-tests/projects/component-tests/package.json b/system-tests/projects/component-tests/package.json new file mode 100644 index 000000000000..455ba9f1c455 --- /dev/null +++ b/system-tests/projects/component-tests/package.json @@ -0,0 +1,4 @@ +{ + "name": "component-tests", + "version": "0.0.0" +} From d0821948dcd72860fe1330662b44eaf8042e476c Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Mon, 28 Nov 2022 10:22:29 -0600 Subject: [PATCH 09/27] enable more debugging --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 37ebd6e24809..405c929f9010 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1618,7 +1618,7 @@ jobs: percy: << parameters.percy >> package: app type: e2e - debug: 'cypress*packh*' + debug: 'cypress:*packh*' driver-integration-tests-chrome: <<: *defaults From f24e168187735259c2359732d8fb4750210c377d Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Mon, 28 Nov 2022 11:03:17 -0600 Subject: [PATCH 10/27] fix bug --- packages/app/cypress/e2e/runs.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app/cypress/e2e/runs.cy.ts b/packages/app/cypress/e2e/runs.cy.ts index 2f15f5d393c8..54cbd981685d 100644 --- a/packages/app/cypress/e2e/runs.cy.ts +++ b/packages/app/cypress/e2e/runs.cy.ts @@ -77,7 +77,7 @@ describe('App: Runs', { viewportWidth: 1200 }, () => { moveToRunsPage() cy.contains(defaultMessages.runs.connect.buttonUser).click() cy.withCtx((ctx, o) => { - o.sinon.spy(ctx._apis.authApi, 'logIn') + o.sinon.stub(ctx._apis.authApi, 'logIn') }) cy.findByRole('dialog', { name: 'Log in to Cypress' }).within(() => { From 33cbd0ceb93e7e26d613d9790b45411349c7f1a8 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Mon, 28 Nov 2022 11:27:21 -0600 Subject: [PATCH 11/27] fix bug --- packages/app/cypress/e2e/settings.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app/cypress/e2e/settings.cy.ts b/packages/app/cypress/e2e/settings.cy.ts index 831a155f19b8..80f4bba10b89 100644 --- a/packages/app/cypress/e2e/settings.cy.ts +++ b/packages/app/cypress/e2e/settings.cy.ts @@ -411,7 +411,7 @@ describe('App: Settings without cloud', () => { cy.findByText('Dashboard settings').click() cy.findByText('Project ID').should('not.exist') cy.withCtx((ctx, o) => { - o.sinon.spy(ctx._apis.authApi, 'logIn') + o.sinon.stub(ctx._apis.authApi, 'logIn') }) cy.contains('button', 'Log in to the Cypress Dashboard').click() From 789421319d10b9e8a90874668ec6b6b3a8be75a8 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Mon, 28 Nov 2022 12:18:27 -0600 Subject: [PATCH 12/27] fix tests --- packages/data-context/src/sources/ErrorDataSource.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/data-context/src/sources/ErrorDataSource.ts b/packages/data-context/src/sources/ErrorDataSource.ts index f116b4083b43..965b84b1534b 100644 --- a/packages/data-context/src/sources/ErrorDataSource.ts +++ b/packages/data-context/src/sources/ErrorDataSource.ts @@ -38,7 +38,7 @@ export class ErrorDataSource { } else { // Skip any stack trace lines which come from node:internal code const stackLines = stackUtils.getStackLines(source.cypressError.stack ?? '') - const filteredStackLines = stackLines.filter((stackLine) => !stackLine.includes('node:internal') && !stackLine.includes('source-map-support')) + const filteredStackLines = stackLines.filter((stackLine) => !stackLine.includes('node:electron') && !stackLine.includes('node:internal') && !stackLine.includes('source-map-support')) const parsedLine = stackUtils.parseStackLine(filteredStackLines[0] ?? '') if (parsedLine) { From ff9387c6fda46add0aaf40a352caa54827fcad31 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Mon, 28 Nov 2022 13:10:56 -0600 Subject: [PATCH 13/27] Update config.yml --- .circleci/config.yml | 2927 +----------------------------------------- 1 file changed, 47 insertions(+), 2880 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d7b0ad260f95..52d1f7ba8f32 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,2907 +1,74 @@ version: 2.1 +setup: true -defaults: &defaults - parallelism: 1 - working_directory: ~/cypress - parameters: &defaultsParameters - executor: - type: executor - default: cy-doc - only-cache-for-root-user: - type: boolean - default: false - executor: <> - environment: &defaultsEnvironment - ## set specific timezone - TZ: "/usr/share/zoneinfo/America/New_York" +orbs: + continuation: circleci/continuation@0.3.1 - ## store artifacts here - CIRCLE_ARTIFACTS: /tmp/artifacts - - ## set so that e2e tests are consistent - COLUMNS: 100 - LINES: 24 - -mainBuildFilters: &mainBuildFilters - filters: - branches: - only: - - develop - - 'feature/run-all-specs' - -# usually we don't build Mac app - it takes a long time -# but sometimes we want to really confirm we are doing the right thing -# so just add your branch to the list here to build and test on Mac -macWorkflowFilters: &darwin-workflow-filters - when: - or: - - equal: [ develop, << pipeline.git.branch >> ] - - equal: [ 'feature/run-all-specs', << pipeline.git.branch >> ] - - matches: - pattern: "-release$" - value: << pipeline.git.branch >> - -linuxArm64WorkflowFilters: &linux-arm64-workflow-filters - when: - or: - - equal: [ develop, << pipeline.git.branch >> ] - - equal: [ 'feature/run-all-specs', << pipeline.git.branch >> ] - - matches: - pattern: "-release$" - value: << pipeline.git.branch >> - -# uncomment & add to the branch conditions below to disable the main linux -# flow if we don't want to test it for a certain branch -linuxWorkflowExcludeFilters: &linux-x64-workflow-exclude-filters - unless: - or: - - false - -# windows is slow and expensive in CI, so it normally only runs on main branches -# add your branch to this list to run the full Windows build on your PR -windowsWorkflowFilters: &windows-workflow-filters - when: - or: - - equal: [ develop, << pipeline.git.branch >> ] - - equal: [ 'astone123/fix-windows-lint', << pipeline.git.branch >> ] - - matches: - pattern: "-release$" - value: << pipeline.git.branch >> - -executors: - # the Docker image with Cypress dependencies and Chrome browser - cy-doc: - docker: - - image: cypress/browsers:node16.16.0-chrome106-ff99-edge - # by default, we use "medium" to balance performance + CI costs. bump or reduce on a per-job basis if needed. - resource_class: medium - environment: - PLATFORM: linux - CI_DOCKER: "true" - - # Docker image with non-root "node" user - non-root-docker-user: +jobs: + verify-ci-should-run: docker: - - image: cypress/browsers:node16.16.0-chrome106-ff99-edge - user: node - environment: - PLATFORM: linux - - # executor to run on Mac OS - # https://circleci.com/docs/2.0/executor-types/#using-macos - # https://circleci.com/docs/2.0/testing-ios/#supported-xcode-versions - mac: - macos: - # Executor should have Node >= required version - xcode: "14.0.0" - resource_class: macos.x86.medium.gen2 - environment: - PLATFORM: darwin - - # executor to run on Windows - based off of the windows-orb default executor since it is - # not customizable enough to align with our existing setup. - # https://github.com/CircleCI-Public/windows-orb/blob/master/src/executors/default.yml - # https://circleci.com/docs/2.0/hello-world-windows/#software-pre-installed-in-the-windows-image - windows: &windows-executor - machine: - image: windows-server-2019-vs2019:stable - shell: bash.exe -eo pipefail - resource_class: windows.large - environment: - PLATFORM: windows - - darwin-arm64: &darwin-arm64-executor - machine: true - environment: - PLATFORM: darwin - - linux-arm64: &linux-arm64-executor - machine: - image: ubuntu-2004:2022.04.1 - resource_class: arm.medium - environment: - PLATFORM: linux - # TODO: Disabling snapshots for now on Linux Arm 64 architectures. Will revisit with https://github.com/cypress-io/cypress/issues/23557 - DISABLE_SNAPSHOT_REQUIRE: 1 - -commands: - verify_should_persist_artifacts: + - image: cimg/node:current steps: - run: - name: Check current branch to persist artifacts + name: Verify CI should run command: | - if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "feature/run-all-specs" ]]; then - echo "Not uploading artifacts or posting install comment for this branch." - circleci-agent step halt + # run CI when manually triggers via CircleCi Dashboard + if [ <> == 'api' ]; then + echo "Always run CI when manually triggered from the UI." + exit 0 fi - restore_workspace_binaries: - steps: - - attach_workspace: - at: ~/ - # make sure we have cypress.zip received - - run: ls -l - - run: ls -l cypress.zip cypress.tgz - - run: node --version - - run: npm --version - - restore_cached_workspace: - steps: - - attach_workspace: - at: ~/ - - install-required-node - - unpack-dependencies - - restore_cached_binary: - steps: - - attach_workspace: - at: ~/ - - prepare-modules-cache: - parameters: - dont-move: - type: boolean - default: false - steps: - - run: node scripts/circle-cache.js --action prepare - - unless: - condition: << parameters.dont-move >> - steps: - - run: - name: Move to /tmp dir for consistent caching across root/non-root users - command: | - mkdir -p /tmp/node_modules_cache - mv ~/cypress/node_modules /tmp/node_modules_cache/root_node_modules - mv ~/cypress/cli/node_modules /tmp/node_modules_cache/cli_node_modules - mv ~/cypress/system-tests/node_modules /tmp/node_modules_cache/system-tests_node_modules - mv ~/cypress/globbed_node_modules /tmp/node_modules_cache/globbed_node_modules - - install-webkit-deps: - steps: - - run: - name: Install WebKit dependencies - command: | - npx playwright install webkit - npx playwright install-deps webkit - - build-and-persist: - description: Save entire folder as artifact for other jobs to run without reinstalling - steps: - - run: - name: Build all codegen - command: | - source ./scripts/ensure-node.sh - yarn gulp buildProd - - run: - name: Build packages - command: | - source ./scripts/ensure-node.sh - yarn build - - run: - name: Generate v8 snapshot - command: | - source ./scripts/ensure-node.sh - yarn build-v8-snapshot-prod - - prepare-modules-cache # So we don't throw these in the workspace cache - - persist_to_workspace: - root: ~/ - paths: - - cypress - - .ssh - - node_modules # contains the npm i -g modules - - install_cache_helpers_dependencies: - steps: - - run: - # Dependencies needed by circle-cache.js, before we "yarn" or unpack cached node_modules - name: Cache Helper Dependencies - working_directory: ~/ - command: npm i glob@7.1.6 fs-extra@10.0.0 minimist@1.2.5 fast-json-stable-stringify@2.1.0 - - unpack-dependencies: - description: 'Unpacks dependencies associated with the current workflow' - steps: - - install_cache_helpers_dependencies - - run: - name: Generate Circle Cache Key - command: node scripts/circle-cache.js --action cacheKey > circle_cache_key - - run: - name: Generate platform key - command: node ./scripts/get-platform-key.js > platform_key - - restore_cache: - name: Restore cache state, to check for known modules cache existence - key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-node-modules-cache-{{ checksum "circle_cache_key" }} - - run: - name: Move node_modules back from /tmp - command: | - if [[ -d "/tmp/node_modules_cache" ]]; then - mv /tmp/node_modules_cache/root_node_modules ~/cypress/node_modules - mv /tmp/node_modules_cache/cli_node_modules ~/cypress/cli/node_modules - mv /tmp/node_modules_cache/system-tests_node_modules ~/cypress/system-tests/node_modules - mv /tmp/node_modules_cache/globbed_node_modules ~/cypress/globbed_node_modules - rm -rf /tmp/node_modules_cache - fi - - run: - name: Restore all node_modules to proper workspace folders - command: node scripts/circle-cache.js --action unpack - - restore_cached_system_tests_deps: - description: 'Restore the cached node_modules for projects in "system-tests/projects/**"' - steps: - - run: - name: Generate Circle Cache key for system tests - command: ./system-tests/scripts/cache-key.sh > system_tests_cache_key - - run: - name: Generate platform key - command: node ./scripts/get-platform-key.js > platform_key - - restore_cache: - name: Restore system tests node_modules cache - keys: - - v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }} - - update_cached_system_tests_deps: - description: 'Update the cached node_modules for projects in "system-tests/projects/**"' - steps: - - run: - name: Generate Circle Cache key for system tests - command: ./system-tests/scripts/cache-key.sh > system_tests_cache_key - - run: - name: Generate platform key - command: node ./scripts/get-platform-key.js > platform_key - - restore_cache: - name: Restore cache state, to check for known modules cache existence - keys: - - v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-state-of-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }} - - run: - name: Send root honeycomb event for this CI build - command: cd system-tests/scripts && node ./send-root-honeycomb-event.js - - run: - name: Bail if specific cache exists - command: | - if [[ -f "/tmp/system_tests_node_modules_installed" ]]; then - echo "No updates to system tests node modules, exiting" - circleci-agent step halt - fi - - restore_cache: - name: Restore system tests node_modules cache - keys: - - v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }} - - v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache- - - run: - name: Update system-tests node_modules cache - command: yarn workspace @tooling/system-tests projects:yarn:install - - save_cache: - name: Save system tests node_modules cache - key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }} - paths: - - /tmp/cy-system-tests-node-modules - - run: touch /tmp/system_tests_node_modules_installed - - save_cache: - name: Save system tests node_modules cache state key - key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-state-of-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }} - paths: - - /tmp/system_tests_node_modules_installed - - caching-dependency-installer: - description: 'Installs & caches the dependencies based on yarn lock & package json dependencies' - parameters: - only-cache-for-root-user: - type: boolean - default: false - steps: - - install_cache_helpers_dependencies - - run: - name: Generate Circle Cache Key - command: node scripts/circle-cache.js --action cacheKey > circle_cache_key - - run: - name: Generate platform key - command: node ./scripts/get-platform-key.js > platform_key - - restore_cache: - name: Restore cache state, to check for known modules cache existence - key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" }} - - run: - name: Bail if cache exists - command: | - if [[ -f "node_modules_installed" ]]; then - echo "Node modules already cached for dependencies, exiting" - circleci-agent step halt + if [[ "$CIRCLE_BRANCH" == "develop" || "$CIRCLE_BRANCH" == "release/"* ]]; then + echo "Always run CI for develop and for release candidate branches." + exit 0 fi - - run: date +%Y-%U > cache_date - - restore_cache: - name: Restore weekly yarn cache - keys: - - v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-deps-root-weekly-{{ checksum "cache_date" }} - - run: - name: Install Node Modules - command: | - source ./scripts/ensure-node.sh - # avoid installing Percy's Chromium every time we use @percy/cli - # https://docs.percy.io/docs/caching-asset-discovery-browser-in-ci - PERCY_POSTINSTALL_BROWSER=true \ - yarn --prefer-offline --frozen-lockfile --cache-folder ~/.yarn - no_output_timeout: 20m - - prepare-modules-cache: - dont-move: <> # we don't move, so we don't hit any issues unpacking symlinks - - when: - condition: <> # we don't move to /tmp since we don't need to worry about different users - steps: - - save_cache: - name: Saving node modules for root, cli, and all globbed workspace packages - key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-node-modules-cache-{{ checksum "circle_cache_key" }} - paths: - - node_modules - - cli/node_modules - - system-tests/node_modules - - globbed_node_modules - - unless: - condition: <> - steps: - - save_cache: - name: Saving node modules for root, cli, and all globbed workspace packages - key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-node-modules-cache-{{ checksum "circle_cache_key" }} - paths: - - /tmp/node_modules_cache - - run: touch node_modules_installed - - save_cache: - name: Saving node-modules cache state key - key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" }} - paths: - - node_modules_installed - - save_cache: - name: Save weekly yarn cache - key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-deps-root-weekly-{{ checksum "cache_date" }} - paths: - - ~/.yarn - - ~/.cy-npm-cache - verify-build-setup: - description: Common commands run when setting up for build or yarn install - parameters: - executor: - type: executor - default: cy-doc - steps: - - run: pwd - - run: - name: print global yarn cache path - command: echo $(yarn global bin) - - run: - name: print yarn version - command: yarn versions - - unless: - condition: - # stop-only does not correctly match on windows: https://github.com/bahmutov/stop-only/issues/78 - equal: [ *windows-executor, << parameters.executor >> ] - steps: - - run: - name: Stop .only - # this will catch ".only"s in js/coffee as well - command: | - source ./scripts/ensure-node.sh - yarn stop-only-all - - run: - name: Check terminal variables - ## make sure the TERM is set to 'xterm' in node (Linux only) - ## else colors (and tests) will fail - ## See the following information - ## * http://andykdocs.de/development/Docker/Fixing+the+Docker+TERM+variable+issue - ## * https://unix.stackexchange.com/questions/43945/whats-the-difference-between-various-term-variables - command: | - source ./scripts/ensure-node.sh - yarn check-terminal - - install-required-node: - # https://discuss.circleci.com/t/switch-nodejs-version-on-machine-executor-solved/26675/2 - description: Install Node version matching .node-version - steps: - # installing NVM will use git+ssh, so update known_hosts - - update_known_hosts - - run: - name: Install Node - command: | - node_version=$(cat .node-version) - source ./scripts/ensure-node.sh - echo "Installing Yarn" - npm install yarn -g # ensure yarn is installed with the correct node engine - yarn check-node-version - - run: - name: Check Node - command: | - source ./scripts/ensure-node.sh - yarn check-node-version + cancel_build () { + echo "Canceling the CI build..." + curl --request POST \ + --url https://circleci.com/api/v2/workflow/$CIRCLE_WORKFLOW_ID/cancel \ + --header "Circle-Token: ${CIRCLE_TOKEN}" + sleep 30 # Give cancellation a chance to run. This script then won't continue running. + exit 1 # If cancellation didn't run for some reason, fail the build. + } - install-chrome: - description: Install Google Chrome - parameters: - channel: - description: browser channel to install - type: string - version: - description: browser version to install - type: string - steps: - - run: - name: Install Google Chrome (<>) - command: | - echo "Installing Chrome (<>) v<>" - wget -O /usr/src/google-chrome-<>_<>_amd64.deb "http://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-<>/google-chrome-<>_<>-1_amd64.deb" && \ - dpkg -i /usr/src/google-chrome-<>_<>_amd64.deb ; \ - apt-get install -f -y && \ - rm -f /usr/src/google-chrome-<>_<>_amd64.deb - which google-chrome-<> || (printf "\n\033[0;31mChrome was not successfully downloaded - bailing\033[0m\n\n" && exit 1) - echo "Location of Google Chrome Installation: `which google-chrome-<>`" - echo "Google Chrome Version: `google-chrome-<> --version`" + TRIGGER_INSTRUCTIONS="to trigger CI , include 'run ci' in the commit message or click the 'Trigger Pipeline' button in the CircleCI UI." - run-driver-integration-tests: - parameters: - browser: - description: browser shortname to target - type: string - install-chrome-channel: - description: chrome channel to install - type: string - default: '' - experimentalSessionAndOrigin: - description: experimental flag to apply - type: boolean - default: false - steps: - - restore_cached_workspace - - when: - condition: <> - steps: - - install-chrome: - channel: <> - version: $(node ./scripts/get-browser-version.js chrome:<>) - - when: - condition: - equal: [ webkit, << parameters.browser >> ] - steps: - - install-webkit-deps - - run: - name: Run driver tests in Cypress - environment: - CYPRESS_CONFIG_ENV: production - command: | - echo Current working directory is $PWD - echo Total containers $CIRCLE_NODE_TOTAL + if [ ! -z "${CIRCLE_PULL_REQUEST##*/}" ]; then + DRAFT=$(curl --silent "https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/pulls/${CIRCLE_PULL_REQUEST##*/}" | jq '.draft') - if [[ -v MAIN_RECORD_KEY ]]; then - # internal PR - if <>; then - CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \ - yarn cypress:run-experimentalSessionAndOrigin --record --parallel --group 5x-driver-<>-experimentalSessionAndOrigin --browser <> - else - CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \ - yarn cypress:run --record --parallel --group 5x-driver-<> --browser <> + if [[ "${DRAFT}" == true ]]; then + echo "Skipping CI; PR is in draft - $TRIGGER_INSTRUCTIONS" + cancel_build fi - else - # external PR - TESTFILES=$(circleci tests glob "cypress/e2e/**/*.cy.*" | circleci tests split --total=$CIRCLE_NODE_TOTAL) - echo "Test files for this machine are $TESTFILES" - if [[ -z "$TESTFILES" ]]; then - echo "Empty list of test files" - fi - if <>; then - yarn cypress:run-experimentalSessionAndOrigin --browser <> --spec $TESTFILES - else - yarn cypress:run --browser <> --spec $TESTFILES - fi + echo "Always run CI for PR that is ready for review." + exit 0 fi - working_directory: packages/driver - - verify-mocha-results - - store_test_results: - path: /tmp/cypress - - store_artifacts: - path: /tmp/artifacts - - store-npm-logs - windows-install-chrome: - parameters: - browser: - description: browser shortname to target - type: string - steps: - - run: - # TODO: How can we have preinstalled browsers on CircleCI? - name: 'Install Chrome on Windows' - command: | - # install with `--ignore-checksums` to avoid checksum error - # https://www.gep13.co.uk/blog/chocolatey-error-hashes-do-not-match - [[ $PLATFORM == 'windows' && '<>' == 'chrome' ]] && choco install googlechrome --ignore-checksums || [[ $PLATFORM != 'windows' ]] + LAST_COMMIT_MESSAGE=$(curl --silent "https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/commits/${CIRCLE_BRANCH}" | jq '.commit.message') - run-new-ui-tests: - parameters: - package: - description: package to target - type: enum - enum: ['frontend-shared', 'launchpad', 'app', 'reporter'] - browser: - description: browser shortname to target - type: string - percy: - description: enable percy - type: boolean - default: false - type: - description: ct or e2e - type: enum - enum: ['ct', 'e2e'] - debug: - description: debug option - type: string - default: '' - steps: - - restore_cached_workspace - - windows-install-chrome: - browser: <> - - run: - command: | - echo Current working directory is $PWD - echo Total containers $CIRCLE_NODE_TOTAL - - if [[ -v MAIN_RECORD_KEY ]]; then - # internal PR - cmd=$([[ <> == 'true' ]] && echo 'yarn percy exec --parallel -- --') || true - DEBUG=<> \ - CYPRESS_CONFIG_ENV=production \ - CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \ - PERCY_PARALLEL_NONCE=$CIRCLE_WORKFLOW_WORKSPACE_ID \ - PERCY_ENABLE=${PERCY_TOKEN:-0} \ - PERCY_PARALLEL_TOTAL=-1 \ - $cmd yarn workspace @packages/<> cypress:run:<> --browser <> --record --parallel --group <>-<> - else - # external PR - - # To make `circleci tests` work correctly, we need to step into the package folder. - cd packages/<> - - GLOB="cypress/e2e/**/*cy.*" - - if [[ <> == 'ct' ]]; then - # component tests are located side by side with the source codes. - GLOB="src/**/*cy.*" - fi - - TESTFILES=$(circleci tests glob "$GLOB" | circleci tests split --total=$CIRCLE_NODE_TOTAL) - echo "Test files for this machine are $TESTFILES" - - # To run the `yarn` command, we need to walk out of the package folder. - cd ../.. - - DEBUG=<> \ - CYPRESS_CONFIG_ENV=production \ - PERCY_PARALLEL_NONCE=$CIRCLE_WORKFLOW_WORKSPACE_ID \ - PERCY_ENABLE=${PERCY_TOKEN:-0} \ - PERCY_PARALLEL_TOTAL=-1 \ - yarn workspace @packages/<> cypress:run:<> --browser <> --spec $TESTFILES + if ! [[ "$LAST_COMMIT_MESSAGE" =~ "run ci" ]]; then + echo "Skipping CI; branch in progress - $TRIGGER_INSTRUCTIONS" + cancel_build fi - - run: - command: | - if [[ <> == 'app' && <> == 'true' && -d "packages/app/cypress/screenshots/runner/screenshot/screenshot.cy.tsx/percy" ]]; then - PERCY_PARALLEL_NONCE=$CIRCLE_WORKFLOW_WORKSPACE_ID \ - PERCY_ENABLE=${PERCY_TOKEN:-0} \ - PERCY_PARALLEL_TOTAL=-1 \ - yarn percy upload packages/app/cypress/screenshots/runner/screenshot/screenshot.cy.tsx/percy - else - echo "skipping percy screenshots uploading" - fi - - store_test_results: - path: /tmp/cypress - - store_artifacts: - path: ./packages/<>/cypress/videos - - store-npm-logs - - run-system-tests: - parameters: - browser: - description: browser shortname to target - type: string - steps: - - restore_cached_workspace - - restore_cached_system_tests_deps - - when: - condition: - equal: [ webkit, << parameters.browser >> ] - steps: - - install-webkit-deps - - run: - name: Run system tests - command: | - ALL_SPECS=`circleci tests glob "/root/cypress/system-tests/test/*spec*"` - SPECS= - for file in $ALL_SPECS; do - # filter out non_root tests, they have their own stage - if [[ "$file" == *"non_root"* ]]; then - echo "Skipping $file" - continue - fi - SPECS="$SPECS $file" - done - SPECS=`echo $SPECS | xargs -n 1 | circleci tests split --split-by=timings` - echo SPECS=$SPECS - yarn workspace @tooling/system-tests test:ci $SPECS --browser <> - - verify-mocha-results - - store_test_results: - path: /tmp/cypress - - store_artifacts: - path: /tmp/artifacts - - store-npm-logs - - run-binary-system-tests: - steps: - - restore_cached_workspace - - restore_cached_system_tests_deps - - run: - name: Run system tests - command: | - ALL_SPECS=`circleci tests glob "$HOME/cypress/system-tests/test-binary/*spec*"` - SPECS=`echo $ALL_SPECS | xargs -n 1 | circleci tests split --split-by=timings` - echo SPECS=$SPECS - yarn workspace @tooling/system-tests test:ci $SPECS - - verify-mocha-results - - store_test_results: - path: /tmp/cypress - - store_artifacts: - path: /tmp/artifacts - - store-npm-logs - - store-npm-logs: - description: Saves any NPM debug logs as artifacts in case there is a problem - steps: - - store_artifacts: - path: ~/.npm/_logs - - post-install-comment: - description: Post GitHub comment with a blurb on how to install pre-release version - steps: - - run: - name: Post pre-release install comment - command: | - node scripts/add-install-comment.js \ - --npm npm-package-url.json \ - --binary binary-url.json - - verify-mocha-results: - description: Double-check that Mocha tests ran as expected. - parameters: - expectedResultCount: - description: The number of result files to expect, ie, the number of Mocha test suites that ran. - type: integer - ## by default, assert that at least 1 test ran - default: 0 - steps: - - run: - name: 'Verify Mocha Results' - command: | - source ./scripts/ensure-node.sh - yarn verify:mocha:results <> - - clone-repo-and-checkout-branch: - description: | - Clones an external repo and then checks out the branch that matches the next version otherwise uses 'master' branch. - parameters: - repo: - description: "Name of the github repo to clone like: cypress-example-kitchensink" - type: string - pull_request_id: - description: Pull request number to check out before installing and testing - type: integer - default: 0 - steps: - - restore_cached_binary - - run: - name: "Cloning test project and checking out release branch: <>" - working_directory: /tmp/<> - command: | - git clone --depth 1 --no-single-branch https://github.com/cypress-io/<>.git . - - cd ~/cypress/.. - # install some deps for get-next-version - npm i semver@7.3.2 conventional-recommended-bump@6.1.0 conventional-changelog-angular@5.0.12 - NEXT_VERSION=$(node ./cypress/scripts/get-next-version.js) - cd - - - git checkout $NEXT_VERSION || true - - when: - condition: <> - steps: - - run: - name: Check out PR <> - working_directory: /tmp/<> - command: | - git fetch origin pull/<>/head:pr-<> - git checkout pr-<> - - test-binary-against-rwa: - description: | - Takes the built binary and NPM package, clones the RWA repo - and runs the new version of Cypress against it. - parameters: - repo: - description: "Name of the github repo to clone like" - type: string - default: "cypress-realworld-app" - browser: - description: Name of the browser to use, like "electron", "chrome", "firefox" - type: enum - enum: ["", "electron", "chrome", "firefox"] - default: "" - command: - description: Test command to run to start Cypress tests - type: string - default: "yarn cypress:run" - # if the repo to clone and test is a monorepo, you can - # run tests inside a specific subfolder - folder: - description: Subfolder to test in - type: string - default: "" - # you can test new features in the test runner against recipes or other repos - # by opening a pull request in those repos and running this test job - # against a pull request number in the example repo - pull_request_id: - description: Pull request number to check out before installing and testing - type: integer - default: 0 - wait-on: - description: Whether to use wait-on to wait on a server to be booted - type: string - default: "" - server-start-command: - description: Server start command for repo - type: string - default: "CI=true yarn start" - steps: - - clone-repo-and-checkout-branch: - repo: <> - - when: - condition: <> - steps: - - run: - name: Check out PR <> - working_directory: /tmp/<> - command: | - git fetch origin pull/<>/head:pr-<> - git checkout pr-<> - git log -n 2 - - run: - command: yarn - working_directory: /tmp/<> - - run: - name: Install Cypress - working_directory: /tmp/<> - # force installing the freshly built binary - command: | - CYPRESS_INSTALL_BINARY=~/cypress/cypress.zip npm i --legacy-peer-deps ~/cypress/cypress.tgz && [[ -f yarn.lock ]] && yarn - - run: - name: Print Cypress version - working_directory: /tmp/<> - command: npx cypress version - - run: - name: Types check 🧩 (maybe) - working_directory: /tmp/<> - command: yarn types - - run: - working_directory: /tmp/<> - command: <> - background: true - - run: - condition: <> - name: "Waiting on server to boot: <>" - command: "npx wait-on <>" - - when: - condition: <> - steps: - - when: - condition: <> - steps: - - run: - name: Run tests using browser "<>" - working_directory: /tmp/<>/<> - command: | - <> -- --browser <> - - unless: - condition: <> - steps: - - run: - name: Run tests using command - working_directory: /tmp/<>/<> - command: <> - - unless: - condition: <> - steps: - - when: - condition: <> - steps: - - run: - name: Run tests using browser "<>" - working_directory: /tmp/<> - command: <> -- --browser <> - - unless: - condition: <> - steps: - - run: - name: Run tests using command - working_directory: /tmp/<> - command: <> - - store-npm-logs - - test-binary-against-repo: - description: | - Takes the built binary and NPM package, clones given example repo - and runs the new version of Cypress against it. - parameters: - repo: - description: "Name of the github repo to clone like: cypress-example-kitchensink" - type: string - browser: - description: Name of the browser to use, like "electron", "chrome", "firefox" - type: enum - enum: ["", "electron", "chrome", "firefox"] - default: "" - command: - description: Test command to run to start Cypress tests - type: string - default: "npm run e2e" - build-project: - description: Should the project build script be executed - type: boolean - default: true - # if the repo to clone and test is a monorepo, you can - # run tests inside a specific subfolder - folder: - description: Subfolder to test in - type: string - default: "" - # you can test new features in the test runner against recipes or other repos - # by opening a pull request in those repos and running this test job - # against a pull request number in the example repo - pull_request_id: - description: Pull request number to check out before installing and testing - type: integer - default: 0 - wait-on: - description: Whether to use wait-on to wait on a server to be booted - type: string - default: "" - server-start-command: - description: Server start command for repo - type: string - default: "npm start --if-present" - steps: - - clone-repo-and-checkout-branch: - repo: <> - pull_request_id: <> - - run: - # Ensure we're installing the node-version for the cloned repo - command: | - if [[ -f .node-version ]]; then - branch="<< pipeline.git.branch >>" - - externalBranchPattern='^pull\/[0-9]+' - if [[ $branch =~ $externalBranchPattern ]]; then - # We are unable to curl from the external PR branch location - # so we fall back to develop - branch="develop" - fi - - curl -L https://raw.githubusercontent.com/cypress-io/cypress/$branch/scripts/ensure-node.sh --output ci-ensure-node.sh - else - # if no .node-version file exists, we no-op the node script and use the global yarn - echo '' > ci-ensure-node.sh - fi - working_directory: /tmp/<> - - run: - # Install deps + Cypress binary with yarn if yarn.lock present - command: | - source ./ci-ensure-node.sh - if [[ -f yarn.lock ]]; then - yarn --frozen-lockfile - CYPRESS_INSTALL_BINARY=~/cypress/cypress.zip yarn add -D ~/cypress/cypress.tgz - else - npm install - CYPRESS_INSTALL_BINARY=~/cypress/cypress.zip npm install --legacy-peer-deps ~/cypress/cypress.tgz - fi - working_directory: /tmp/<> - - run: - name: Scaffold new config file - working_directory: /tmp/<> - environment: - CYPRESS_INTERNAL_FORCE_SCAFFOLD: "1" - command: | - if [[ -f cypress.json ]]; then - rm -rf cypress.json - echo 'module.exports = { e2e: {} }' > cypress.config.js - fi - - run: - name: Rename support file - working_directory: /tmp/<> - command: | - if [[ -f cypress/support/index.js ]]; then - mv cypress/support/index.js cypress/support/e2e.js - fi - - run: - name: Print Cypress version - working_directory: /tmp/<> - command: | - source ./ci-ensure-node.sh - npx cypress version - - run: - name: Types check 🧩 (maybe) - working_directory: /tmp/<> - command: | - source ./ci-ensure-node.sh - [[ -f yarn.lock ]] && yarn types || npm run types --if-present - - when: - condition: <> - steps: - - run: - name: Build 🏗 (maybe) - working_directory: /tmp/<> - command: | - source ./ci-ensure-node.sh - [[ -f yarn.lock ]] && yarn build || npm run build --if-present - - run: - working_directory: /tmp/<> - command: | - source ./ci-ensure-node.sh - <> - background: true - - run: - condition: <> - name: "Waiting on server to boot: <>" - command: | - npx wait-on <> --timeout 120000 - - windows-install-chrome: - browser: <> - - when: - condition: <> - steps: - - when: - condition: <> - steps: - - run: - name: Run tests using browser "<>" - working_directory: /tmp/<>/<> - command: | - <> -- --browser <> - - unless: - condition: <> - steps: - - run: - name: Run tests using command - working_directory: /tmp/<>/<> - command: <> - - unless: - condition: <> - steps: - - when: - condition: <> - steps: - - run: - name: Run tests using browser "<>" - working_directory: /tmp/<> - command: | - source ./ci-ensure-node.sh - <> -- --browser <> - - unless: - condition: <> - steps: - - run: - name: Run tests using command - working_directory: /tmp/<> - command: | - source ./ci-ensure-node.sh - <> - - store-npm-logs - - wait-on-circle-jobs: - description: Polls certain Circle CI jobs until they finish - parameters: - job-names: - description: comma separated list of circle ci job names to wait for - type: string - steps: - - run: - name: "Waiting on Circle CI jobs: <>" - command: node ./scripts/wait-on-circle-jobs.js --job-names="<>" - - build-binary: - steps: - - run: - name: Check environment variables before code sign (if on Mac/Windows) - # NOTE - # our code sign works via electron-builder - # by default, electron-builder will NOT sign app built in a pull request - # even our internal one (!) - # Usually this is not a problem, since we only build and test binary - # built on the "develop" branch - # but if you need to really build and sign a binary in a PR - # set variable CSC_FOR_PULL_REQUEST=true - command: | - set -e - NEEDS_CODE_SIGNING=`node -p 'process.platform === "win32" || process.platform === "darwin"'` - if [[ "$NEEDS_CODE_SIGNING" == "true" ]]; then - echo "Checking for required environment variables..." - if [ -z "$CSC_LINK" ]; then - echo "Need to provide environment variable CSC_LINK" - echo "with base64 encoded certificate .p12 file" - exit 1 - fi - if [ -z "$CSC_KEY_PASSWORD" ]; then - echo "Need to provide environment variable CSC_KEY_PASSWORD" - echo "with password for unlocking certificate .p12 file" - exit 1 - fi - echo "Succeeded." - else - echo "Not code signing for this platform" - fi - - run: - name: Build the Cypress binary - environment: - DEBUG: electron-builder,electron-osx-sign* - # notarization on Mac can take a while - no_output_timeout: "45m" - command: | - source ./scripts/ensure-node.sh - node --version - if [[ `node ./scripts/get-platform-key.js` == 'linux-arm64' ]]; then - # these are missing on Circle and there is no way to pre-install them on Arm - sudo apt-get update - sudo apt-get install -y libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb - DISABLE_SNAPSHOT_REQUIRE=1 yarn binary-build --version $(node ./scripts/get-next-version.js) - else - yarn binary-build --version $(node ./scripts/get-next-version.js) - fi - - run: - name: Zip the binary - command: | - if [[ $PLATFORM == 'linux' ]]; then - # on Arm, CI runs as non-root, on x64 CI runs as root but there is no sudo binary - if [[ `whoami` == 'root' ]]; then - apt-get update && apt-get install -y zip - else - sudo apt-get update && sudo apt-get install -y zip - fi - fi - source ./scripts/ensure-node.sh - yarn binary-zip - - store-npm-logs - - persist_to_workspace: - root: ~/ - paths: - - cypress/cypress.zip - - build-cypress-npm-package: - parameters: - executor: - type: executor - default: cy-doc - steps: - - run: - name: Bump NPM version - command: | - source ./scripts/ensure-node.sh - yarn get-next-version --npm - - run: - name: Build NPM package - command: | - source ./scripts/ensure-node.sh - yarn build --scope cypress - - run: - name: Copy Re-exported NPM Packages - command: node ./scripts/post-build.js - working_directory: cli - - run: - command: ls -la types - working_directory: cli/build - - run: - command: ls -la vue vue2 mount-utils react - working_directory: cli/build - - unless: - condition: - equal: [ *windows-executor, << parameters.executor >> ] - steps: - - run: - name: list NPM package contents - command: | - source ./scripts/ensure-node.sh - yarn workspace cypress size - - run: - name: pack NPM package - working_directory: cli/build - command: yarn pack --filename ../../cypress.tgz - - run: - name: list created NPM package - command: ls -l - - store-npm-logs - - persist_to_workspace: - root: ~/ - paths: - - cypress/cypress.tgz - - upload-build-artifacts: - steps: - - run: ls -l - - run: - name: Upload unique binary to S3 - command: | - node scripts/binary.js upload-build-artifact \ - --type binary \ - --file cypress.zip \ - --version $(node -p "require('./package.json').version") - - run: - name: Upload NPM package to S3 - command: | - node scripts/binary.js upload-build-artifact \ - --type npm-package \ - --file cypress.tgz \ - --version $(node -p "require('./package.json').version") - - store-npm-logs - - run: ls -l - - run: cat binary-url.json - - run: cat npm-package-url.json - - persist_to_workspace: - root: ~/ - paths: - - cypress/binary-url.json - - cypress/npm-package-url.json - - update_known_hosts: - description: Ensures that we have the latest Git public keys to prevent git+ssh from failing. - steps: - - run: - name: Update known_hosts with github.com keys - command: | - mkdir -p ~/.ssh - ssh-keyscan github.com >> ~/.ssh/known_hosts - -jobs: - ## Checks if we already have a valid cache for the node_modules_install and if it has, - ## skips ahead to the build step, otherwise installs and caches the node_modules - node_modules_install: - <<: *defaults - parameters: - <<: *defaultsParameters - resource_class: - type: string - default: medium - resource_class: << parameters.resource_class >> - steps: - - checkout - - install-required-node - - verify-build-setup: - executor: << parameters.executor >> - - persist_to_workspace: - root: ~/ - paths: - - cypress - - .nvm # mac / linux - - ProgramData/nvm # windows - - caching-dependency-installer: - only-cache-for-root-user: <> - - store-npm-logs - - ## restores node_modules from previous step & builds if first step skipped - build: - <<: *defaults - parameters: - <<: *defaultsParameters - resource_class: - type: string - default: large - resource_class: << parameters.resource_class >> - steps: - - restore_cached_workspace - - run: - name: Top level packages - command: yarn list --depth=0 || true - - run: - name: Check env canaries on Linux - command: | - # only Docker has the required env data for this - if [[ $CI_DOCKER == 'true' ]]; then - node ./scripts/circle-env.js --check-canaries - fi - - build-and-persist - - store-npm-logs - - lint: - <<: *defaults - steps: - - restore_cached_workspace - - run: - name: Linting 🧹 - command: | - yarn clean - git clean -df - yarn lint - - run: - name: cypress info (dev) - command: node cli/bin/cypress info --dev - - store-npm-logs - - check-ts: - <<: *defaults - steps: - - restore_cached_workspace - - install-required-node - - run: - name: Check TS Types - command: NODE_OPTIONS=--max_old_space_size=4096 yarn gulp checkTs - - - # a special job that keeps polling Circle and when all - # individual jobs are finished, it closes the Percy build - percy-finalize: - <<: *defaults - resource_class: small - parameters: - <<: *defaultsParameters - required_env_var: - type: env_var_name - steps: - - restore_cached_workspace - - run: - # if this is an external pull request, the environment variables - # are NOT set for security reasons, thus no need to poll - - # and no need to finalize Percy, since there will be no visual tests - name: Check if <> is set - command: | - if [[ -v <> ]]; then - echo "Internal PR, good to go" - else - echo "This is an external PR, cannot access other services" - circleci-agent step halt - fi - - wait-on-circle-jobs: - job-names: > - cli-visual-tests, - reporter-integration-tests, - run-app-component-tests-chrome, - run-app-integration-tests-chrome, - run-frontend-shared-component-tests-chrome, - run-launchpad-component-tests-chrome, - run-launchpad-integration-tests-chrome, - run-reporter-component-tests-chrome, - run-webpack-dev-server-integration-tests, - run-vite-dev-server-integration-tests - - run: - # Sometimes, even though all the circle jobs have finished, Percy times out during `build:finalize` - # If all other jobs finish but `build:finalize` fails, we retry it once - name: Finalize percy build - allows single retry - command: | - PERCY_PARALLEL_NONCE=$CIRCLE_WORKFLOW_WORKSPACE_ID \ - yarn percy build:finalize || yarn percy build:finalize - - cli-visual-tests: - <<: *defaults - resource_class: small - steps: - - restore_cached_workspace - - run: mkdir -p cli/visual-snapshots - - run: - command: node cli/bin/cypress info --dev | yarn --silent term-to-html | node scripts/sanitize --type cli-info > cli/visual-snapshots/cypress-info.html - environment: - FORCE_COLOR: 2 - - run: - command: node cli/bin/cypress help | yarn --silent term-to-html > cli/visual-snapshots/cypress-help.html - environment: - FORCE_COLOR: 2 - - store_artifacts: - path: cli/visual-snapshots - - run: - name: Upload CLI snapshots for diffing - command: | - PERCY_PARALLEL_NONCE=$CIRCLE_WORKFLOW_WORKSPACE_ID \ - PERCY_ENABLE=${PERCY_TOKEN:-0} \ - PERCY_PARALLEL_TOTAL=-1 \ - yarn percy snapshot ./cli/visual-snapshots - - v8-integration-tests: - <<: *defaults - parameters: - <<: *defaultsParameters - resource_class: - type: string - default: medium - resource_class: << parameters.resource_class >> - parallelism: 1 - steps: - - restore_cached_workspace - - restore_cached_system_tests_deps - # TODO: Remove this once we switch off self-hosted M1 runners - - when: - condition: - equal: [ *darwin-arm64-executor, << parameters.executor >> ] - steps: - - run: rm -f /tmp/cypress/junit/* - - unless: - condition: - or: - - equal: [ *linux-arm64-executor, << parameters.executor >> ] # TODO: Figure out how to support linux-arm64 when we get to linux arm64 build: https://github.com/cypress-io/cypress/issues/23557 - steps: - - run: - name: Run v8 integration tests - command: | - source ./scripts/ensure-node.sh - yarn test-integration --scope "'@tooling/{packherd,v8-snapshot,electron-mksnapshot}'" - - verify-mocha-results: - expectedResultCount: 3 - - when: - condition: - or: - - equal: [ *linux-arm64-executor, << parameters.executor >> ] - steps: - - run: - name: Run v8 integration tests - command: | - source ./scripts/ensure-node.sh - yarn test-integration --scope "'@tooling/packherd'" - - verify-mocha-results: - expectedResultCount: 1 - - store_test_results: - path: /tmp/cypress - - store-npm-logs - - unit-tests: - <<: *defaults - parameters: - <<: *defaultsParameters - resource_class: - type: string - default: medium - resource_class: << parameters.resource_class >> - parallelism: 1 - steps: - - restore_cached_workspace - - when: - condition: - # several snapshots fails for windows due to paths. - # until these are fixed, run the tests that are working. - equal: [ *windows-executor, << parameters.executor >> ] - steps: - - run: yarn test-scripts scripts/**/*spec.js - - unless: - condition: - equal: [ *windows-executor, << parameters.executor >> ] - steps: - - run: yarn test-scripts - # make sure packages with TypeScript can be transpiled to JS - - run: yarn lerna run build-prod --stream --concurrency 4 - # run unit tests from each individual package - - run: yarn test - # run type checking for each individual package - - run: yarn lerna run types - - verify-mocha-results: - expectedResultCount: 18 - - store_test_results: - path: /tmp/cypress - # CLI tests generate HTML files with sample CLI command output - - store_artifacts: - path: cli/test/html - - store_artifacts: - path: packages/errors/__snapshot-images__ - - store-npm-logs - - unit-tests-release: - <<: *defaults - resource_class: small - parallelism: 1 - steps: - - restore_cached_workspace - - update_known_hosts - - run: yarn test-npm-package-release-script - - lint-types: - <<: *defaults - parallelism: 1 - steps: - - restore_cached_workspace - - run: - command: ls -la types - working_directory: cli - - run: - command: ls -la chai - working_directory: cli/types - - run: - name: "Lint types 🧹" - command: yarn workspace cypress dtslint - # todo(lachlan): do we need this? yarn check-ts does something very similar - # - run: - # name: "TypeScript check 🧩" - # command: yarn type-check --ignore-progress - - store-npm-logs - - server-unit-tests: - <<: *defaults - parallelism: 1 - steps: - - restore_cached_workspace - - run: yarn test-unit --scope @packages/server - - verify-mocha-results: - expectedResultCount: 1 - - store_test_results: - path: /tmp/cypress - - store-npm-logs - - server-integration-tests: - <<: *defaults - parallelism: 1 - steps: - - restore_cached_workspace - - run: yarn test-integration --scope @packages/server - - verify-mocha-results: - expectedResultCount: 1 - - store_test_results: - path: /tmp/cypress - - store-npm-logs - - server-performance-tests: - <<: *defaults - steps: - - restore_cached_workspace - - run: - command: yarn workspace @packages/server test-performance - - verify-mocha-results: - expectedResultCount: 1 - - store_test_results: - path: /tmp/cypress - - store_artifacts: - path: /tmp/artifacts - - store-npm-logs - - system-tests-node-modules-install: - <<: *defaults - steps: - - restore_cached_workspace - - update_cached_system_tests_deps - - binary-system-tests: - parallelism: 2 - working_directory: ~/cypress - environment: - <<: *defaultsEnvironment - PLATFORM: linux - machine: - # using `machine` gives us a Linux VM that can run Docker - image: ubuntu-2004:202111-02 - docker_layer_caching: true - resource_class: medium - steps: - - run-binary-system-tests - - system-tests-chrome: - <<: *defaults - parallelism: 8 - steps: - - run-system-tests: - browser: chrome - - system-tests-electron: - <<: *defaults - parallelism: 8 - steps: - - run-system-tests: - browser: electron - - system-tests-firefox: - <<: *defaults - parallelism: 8 - steps: - - run-system-tests: - browser: firefox - - system-tests-webkit: - <<: *defaults - parallelism: 8 - steps: - - run-system-tests: - browser: webkit - - system-tests-non-root: - <<: *defaults - steps: - - restore_cached_workspace - - run: - command: yarn workspace @tooling/system-tests test:ci "test/non_root*spec*" --browser electron - - verify-mocha-results - - store_test_results: - path: /tmp/cypress - - store_artifacts: - path: /tmp/artifacts - - store-npm-logs - - run-frontend-shared-component-tests-chrome: - <<: *defaults - parameters: - <<: *defaultsParameters - percy: - type: boolean - default: false - parallelism: 3 - steps: - - run-new-ui-tests: - browser: chrome - percy: << parameters.percy >> - package: frontend-shared - type: ct - - run-launchpad-component-tests-chrome: - <<: *defaults - parameters: - <<: *defaultsParameters - percy: - type: boolean - default: false - parallelism: 7 - steps: - - run-new-ui-tests: - browser: chrome - percy: << parameters.percy >> - package: launchpad - type: ct - # debug: cypress:*,engine:socket - - run-launchpad-integration-tests-chrome: - <<: *defaults - parameters: - <<: *defaultsParameters - resource_class: - type: string - default: medium - percy: - type: boolean - default: false - resource_class: << parameters.resource_class >> - parallelism: 3 - steps: - - run-new-ui-tests: - browser: chrome - percy: << parameters.percy >> - package: launchpad - type: e2e - - run-app-component-tests-chrome: - <<: *defaults - parameters: - <<: *defaultsParameters - percy: - type: boolean - default: false - parallelism: 7 - steps: - - run-new-ui-tests: - browser: chrome - percy: << parameters.percy >> - package: app - type: ct - - run-app-integration-tests-chrome: - <<: *defaults - parameters: - <<: *defaultsParameters - resource_class: - type: string - default: medium - percy: - type: boolean - default: false - resource_class: << parameters.resource_class >> - parallelism: 8 - steps: - - run-new-ui-tests: - browser: chrome - percy: << parameters.percy >> - package: app - type: e2e - - driver-integration-tests-chrome: - <<: *defaults - parallelism: 5 - steps: - - run-driver-integration-tests: - browser: chrome - install-chrome-channel: stable - - driver-integration-tests-chrome-beta: - <<: *defaults - parallelism: 5 - steps: - - run-driver-integration-tests: - browser: chrome:beta - install-chrome-channel: beta - - driver-integration-tests-firefox: - <<: *defaults - parallelism: 5 - steps: - - run-driver-integration-tests: - browser: firefox - - driver-integration-tests-electron: - <<: *defaults - parallelism: 5 - steps: - - run-driver-integration-tests: - browser: electron - - driver-integration-tests-webkit: - <<: *defaults - parallelism: 5 - steps: - - run-driver-integration-tests: - browser: webkit - - driver-integration-tests-chrome-experimentalSessionAndOrigin: - <<: *defaults - resource_class: medium - parallelism: 5 - steps: - - run-driver-integration-tests: - browser: chrome - install-chrome-channel: stable - experimentalSessionAndOrigin: true - - driver-integration-tests-chrome-beta-experimentalSessionAndOrigin: - <<: *defaults - resource_class: medium - parallelism: 5 - steps: - - run-driver-integration-tests: - browser: chrome:beta - install-chrome-channel: beta - experimentalSessionAndOrigin: true - - driver-integration-tests-firefox-experimentalSessionAndOrigin: - <<: *defaults - resource_class: medium - parallelism: 5 - steps: - - run-driver-integration-tests: - browser: firefox - experimentalSessionAndOrigin: true - - driver-integration-tests-electron-experimentalSessionAndOrigin: - <<: *defaults - resource_class: medium - parallelism: 5 - steps: - - run-driver-integration-tests: - browser: electron - experimentalSessionAndOrigin: true - - driver-integration-tests-webkit-experimentalSessionAndOrigin: - <<: *defaults - resource_class: medium - parallelism: 5 - steps: - - run-driver-integration-tests: - browser: webkit - experimentalSessionAndOrigin: true - - run-reporter-component-tests-chrome: - <<: *defaults - parameters: - <<: *defaultsParameters - percy: - type: boolean - default: false - parallelism: 2 - steps: - - run-new-ui-tests: - browser: chrome - percy: << parameters.percy >> - package: reporter - type: ct - - reporter-integration-tests: - <<: *defaults - parallelism: 3 - steps: - - restore_cached_workspace - - run: - command: yarn build-for-tests - working_directory: packages/reporter - - run: - command: | - CYPRESS_CONFIG_ENV=production \ - CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \ - PERCY_PARALLEL_NONCE=$CIRCLE_WORKFLOW_WORKSPACE_ID \ - PERCY_ENABLE=${PERCY_TOKEN:-0} \ - PERCY_PARALLEL_TOTAL=-1 \ - yarn percy exec --parallel -- -- \ - yarn cypress:run --record --parallel --group reporter - working_directory: packages/reporter - - verify-mocha-results - - store_test_results: - path: /tmp/cypress - - store_artifacts: - path: /tmp/artifacts - - store-npm-logs - - run-webpack-dev-server-integration-tests: - <<: *defaults - parallelism: 2 - steps: - - restore_cached_workspace - - restore_cached_system_tests_deps - - run: - command: | - CYPRESS_CONFIG_ENV=production \ - CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \ - PERCY_PARALLEL_NONCE=$CIRCLE_WORKFLOW_WORKSPACE_ID \ - PERCY_ENABLE=${PERCY_TOKEN:-0} \ - PERCY_PARALLEL_TOTAL=-1 \ - yarn percy exec --parallel -- -- \ - yarn cypress:run --record --parallel --group webpack-dev-server - working_directory: npm/webpack-dev-server - - store_test_results: - path: /tmp/cypress - - store_artifacts: - path: /tmp/artifacts - - store-npm-logs - - run-vite-dev-server-integration-tests: - <<: *defaults - # parallelism: 3 TODO: Add parallelism once we have more specs - steps: - - restore_cached_workspace - - restore_cached_system_tests_deps - - run: - command: | - CYPRESS_CONFIG_ENV=production \ - CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \ - PERCY_PARALLEL_NONCE=$CIRCLE_WORKFLOW_WORKSPACE_ID \ - PERCY_ENABLE=${PERCY_TOKEN:-0} \ - PERCY_PARALLEL_TOTAL=-1 \ - yarn percy exec --parallel -- -- \ - yarn cypress:run --record --parallel --group vite-dev-server - working_directory: npm/vite-dev-server - - store_test_results: - path: /tmp/cypress - - store_artifacts: - path: /tmp/artifacts - - store-npm-logs - - npm-webpack-preprocessor: - <<: *defaults - steps: - - restore_cached_workspace - - run: - name: Build - command: yarn workspace @cypress/webpack-preprocessor build - - run: - name: Test babelrc - command: yarn test - working_directory: npm/webpack-preprocessor/examples/use-babelrc - - run: - name: Build ts-loader - command: yarn install - working_directory: npm/webpack-preprocessor/examples/use-ts-loader - - run: - name: Types ts-loader - command: yarn types - working_directory: npm/webpack-preprocessor/examples/use-ts-loader - - run: - name: Test ts-loader - command: yarn test - working_directory: npm/webpack-preprocessor/examples/use-ts-loader - - run: - name: Start React app - command: yarn start - background: true - working_directory: npm/webpack-preprocessor/examples/react-app - - run: - name: Test React app - command: yarn test - working_directory: npm/webpack-preprocessor/examples/react-app - - run: - name: Run tests - command: yarn workspace @cypress/webpack-preprocessor test - - store-npm-logs - npm-webpack-dev-server: - <<: *defaults - steps: - - restore_cached_workspace - - restore_cached_system_tests_deps - - run: - name: Run tests - command: yarn workspace @cypress/webpack-dev-server test - - run: - name: Run tests - command: yarn workspace @cypress/webpack-dev-server test + echo "Always run CI when the commit message includes 'run ci'." - npm-vite-dev-server: - <<: *defaults - steps: - - restore_cached_workspace - - run: - name: Run tests - command: yarn test - working_directory: npm/vite-dev-server - - store_test_results: - path: npm/vite-dev-server/test_results - - store-npm-logs - - npm-webpack-batteries-included-preprocessor: - <<: *defaults - resource_class: small - steps: - - restore_cached_workspace - - run: - name: Run tests - command: yarn workspace @cypress/webpack-batteries-included-preprocessor test - - npm-vue: - <<: *defaults - steps: - - restore_cached_workspace - - run: - name: Build - command: yarn workspace @cypress/vue build - - run: - name: Type Check - command: yarn typecheck - working_directory: npm/vue - - store_test_results: - path: npm/vue/test_results - - store_artifacts: - path: npm/vue/test_results - - store-npm-logs - - npm-angular: - <<: *defaults - steps: - - restore_cached_workspace - - run: - name: Build - command: yarn workspace @cypress/angular build - - store-npm-logs - - npm-react: - <<: *defaults - steps: - - restore_cached_workspace - - run: - name: Build - command: yarn workspace @cypress/react build - - run: - name: Run tests - command: yarn test - working_directory: npm/react - - store_test_results: - path: npm/react/test_results - - store_artifacts: - path: npm/react/test_results - - store-npm-logs - - npm-mount-utils: - <<: *defaults - steps: - - restore_cached_workspace - - run: - name: Build - command: yarn workspace @cypress/mount-utils build - - store-npm-logs - - npm-xpath: - <<: *defaults - resource_class: small - steps: - - restore_cached_workspace - - run: - name: Run tests - command: yarn workspace @cypress/xpath cy:run - - store_test_results: - path: npm/xpath/test_results - - store_artifacts: - path: npm/xpath/test_results - - store-npm-logs - - npm-grep: - <<: *defaults - resource_class: small - steps: - - restore_cached_workspace - - run: - name: Run tests - command: yarn workspace @cypress/grep cy:run - - store_test_results: - path: npm/grep/test_results - - store_artifacts: - path: npm/grep/test_results - - store-npm-logs - - npm-create-cypress-tests: - <<: *defaults - resource_class: small - steps: - - restore_cached_workspace - - run: yarn workspace create-cypress-tests build - - npm-eslint-plugin-dev: - <<: *defaults - steps: - - restore_cached_workspace - - run: - name: Run tests - command: yarn workspace @cypress/eslint-plugin-dev test - - npm-cypress-schematic: - <<: *defaults - steps: - - restore_cached_workspace - - run: - name: Build + Install - command: | - yarn workspace @cypress/schematic build - working_directory: npm/cypress-schematic - run: - name: Run unit tests + name: Download .circleci/workflows.yaml command: | - yarn test - working_directory: npm/cypress-schematic - - store-npm-logs - - npm-release: - <<: *defaults - resource_class: medium+ - steps: - - restore_cached_workspace - - run: - name: Release packages after all jobs pass - command: yarn npm-release - - create-build-artifacts: - <<: *defaults - parameters: - <<: *defaultsParameters - resource_class: - type: string - default: large - resource_class: << parameters.resource_class >> - steps: - - restore_cached_workspace - - build-binary - - build-cypress-npm-package: - executor: << parameters.executor >> - - verify_should_persist_artifacts - - upload-build-artifacts - - post-install-comment - - test-kitchensink: - <<: *defaults - parameters: - <<: *defaultsParameters - resource_class: - type: string - default: medium+ - steps: - - restore_cached_workspace - - clone-repo-and-checkout-branch: - repo: cypress-example-kitchensink - - install-required-node - - run: - name: Remove cypress.json - description: Remove cypress.json in case it exists - working_directory: /tmp/cypress-example-kitchensink - environment: - CYPRESS_INTERNAL_FORCE_SCAFFOLD: "1" - command: rm -rf cypress.json - - run: - name: Install prod dependencies - command: yarn --production - working_directory: /tmp/cypress-example-kitchensink - - run: - name: Example server - command: yarn start - working_directory: /tmp/cypress-example-kitchensink - background: true - - run: - name: Rename support file - working_directory: /tmp/cypress-example-kitchensink - command: | - if [[ -f cypress/support/index.js ]]; then - mv cypress/support/index.js cypress/support/e2e.js + if [[ "$CIRCLE_BRANCH" == "pull/"* ]]; then + curl -o workflows.yml https://raw.githubusercontent.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/develop/.circleci/workflows.yml + else + curl -o workflows.yml https://raw.githubusercontent.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/${CIRCLE_BRANCH}/.circleci/workflows.yml fi - - run: - name: Run Kitchensink example project - command: | - yarn cypress:run --project /tmp/cypress-example-kitchensink - - store-npm-logs - - test-kitchensink-against-staging: - <<: *defaults - steps: - - restore_cached_workspace - - clone-repo-and-checkout-branch: - repo: cypress-example-kitchensink - - install-required-node - - run: - name: Install prod dependencies - command: yarn --production - working_directory: /tmp/cypress-example-kitchensink - - run: - name: Example server - command: yarn start - working_directory: /tmp/cypress-example-kitchensink - background: true - - run: - name: Run Kitchensink example project - command: | - CYPRESS_PROJECT_ID=$TEST_KITCHENSINK_PROJECT_ID \ - CYPRESS_RECORD_KEY=$TEST_KITCHENSINK_RECORD_KEY \ - CYPRESS_INTERNAL_ENV=staging \ - CYPRESS_video=false \ - yarn cypress:run --project /tmp/cypress-example-kitchensink --record - - store-npm-logs - - test-against-staging: - <<: *defaults - steps: - - restore_cached_workspace - - clone-repo-and-checkout-branch: - repo: cypress-test-tiny - - run: - name: Run test project - command: | - CYPRESS_PROJECT_ID=$TEST_TINY_PROJECT_ID \ - CYPRESS_RECORD_KEY=$TEST_TINY_RECORD_KEY \ - CYPRESS_INTERNAL_ENV=staging \ - yarn cypress:run --project /tmp/cypress-test-tiny --record - - store-npm-logs - - test-npm-module-and-verify-binary: - <<: *defaults - steps: - - restore_cached_workspace - # make sure we have cypress.zip received - - run: ls -l - - run: ls -l cypress.zip cypress.tgz - - run: mkdir test-binary - - run: - name: Create new NPM package - working_directory: test-binary - command: npm init -y - - run: - # install NPM from built NPM package folder - name: Install Cypress - working_directory: test-binary - # force installing the freshly built binary - command: CYPRESS_INSTALL_BINARY=/root/cypress/cypress.zip npm i /root/cypress/cypress.tgz - - run: - name: Cypress version - working_directory: test-binary - command: $(yarn bin cypress) version - - run: - name: Verify Cypress binary - working_directory: test-binary - command: $(yarn bin cypress) verify - - run: - name: Cypress help - working_directory: test-binary - command: $(yarn bin cypress) help - - run: - name: Cypress info - working_directory: test-binary - command: $(yarn bin cypress) info - - store-npm-logs - - test-npm-module-on-minimum-node-version: - <<: *defaults - resource_class: small - docker: - - image: cypress/base:12.0.0-libgbm - steps: - - restore_workspace_binaries - - run: mkdir test-binary - - run: - name: Create new NPM package - working_directory: test-binary - command: npm init -y - - run: - name: Install Cypress - working_directory: test-binary - command: CYPRESS_INSTALL_BINARY=/root/cypress/cypress.zip npm install /root/cypress/cypress.tgz - - run: - name: Verify Cypress binary - working_directory: test-binary - command: $(npm bin)/cypress verify - - run: - name: Print Cypress version - working_directory: test-binary - command: $(npm bin)/cypress version - - run: - name: Cypress info - working_directory: test-binary - command: $(npm bin)/cypress info - - test-types-cypress-and-jest: - parameters: - executor: - description: Executor name to use - type: executor - default: cy-doc - wd: - description: Working directory, should be OUTSIDE cypress monorepo folder - type: string - default: /root/test-cypress-and-jest - <<: *defaults - resource_class: small - steps: - - restore_workspace_binaries - - run: mkdir <> - - run: - name: Create new NPM package ⚗️ - working_directory: <> - command: npm init -y - - run: - name: Install dependencies 📦 - working_directory: <> - environment: - CYPRESS_INSTALL_BINARY: /root/cypress/cypress.zip - # let's install Cypress, Jest and any other package that might conflict - # https://github.com/cypress-io/cypress/issues/6690 - - # Todo: Add `jest` back into the list once https://github.com/yargs/yargs-parser/issues/452 - # is resolved. - command: | - npm install /root/cypress/cypress.tgz \ - typescript @types/jest enzyme @types/enzyme - - run: - name: Test types clash ⚔️ - working_directory: <> - command: | - echo "console.log('hello world')" > hello.ts - npx tsc hello.ts --noEmit - - test-full-typescript-project: - parameters: - executor: - description: Executor name to use - type: executor - default: cy-doc - wd: - description: Working directory, should be OUTSIDE cypress monorepo folder - type: string - default: /root/test-full-typescript - <<: *defaults - resource_class: small - steps: - - restore_workspace_binaries - - run: mkdir <> - - run: - name: Create new NPM package ⚗️ - working_directory: <> - command: npm init -y - - run: - name: Install dependencies 📦 - working_directory: <> - environment: - CYPRESS_INSTALL_BINARY: /root/cypress/cypress.zip - command: | - npm install /root/cypress/cypress.tgz typescript - - run: - name: Scaffold full TypeScript project 🏗 - working_directory: <> - command: npx @bahmutov/cly@1.9.0 init --typescript - - run: - name: Run project tests 🗳 - working_directory: <> - command: npx cypress run - - # install NPM + binary zip and run against staging API - test-binary-against-staging: - <<: *defaults - steps: - - restore_workspace_binaries - - clone-repo-and-checkout-branch: - repo: cypress-test-tiny - - run: - name: Install Cypress - working_directory: /tmp/cypress-test-tiny - # force installing the freshly built binary - command: CYPRESS_INSTALL_BINARY=~/cypress/cypress.zip npm i --legacy-peer-deps ~/cypress/cypress.tgz - - run: - name: Run test project - working_directory: /tmp/cypress-test-tiny - command: | - CYPRESS_PROJECT_ID=$TEST_TINY_PROJECT_ID \ - CYPRESS_RECORD_KEY=$TEST_TINY_RECORD_KEY \ - CYPRESS_INTERNAL_ENV=staging \ - $(yarn bin cypress) run --record - - store-npm-logs - - test-binary-against-recipes-firefox: - <<: *defaults - steps: - - test-binary-against-repo: - repo: cypress-example-recipes - command: npm run test:ci:firefox - - test-binary-against-recipes-chrome: - <<: *defaults - steps: - - test-binary-against-repo: - repo: cypress-example-recipes - command: npm run test:ci:chrome - - test-binary-against-recipes: - <<: *defaults - steps: - - test-binary-against-repo: - repo: cypress-example-recipes - command: npm run test:ci - - # This is a special job. It allows you to test the current - # built test runner against a pull request in the repo - # cypress-example-recipes. - # Imagine you are working on a feature and want to show / test a recipe - # You would need to run the built test runner before release - # against a PR that cannot be merged until the new version - # of the test runner is released. - # Use: - # specify pull request number - # and the recipe folder - - # test-binary-against-recipe-pull-request: - # <<: *defaults - # steps: - # # test a specific pull request by number from cypress-example-recipes - # - test-binary-against-repo: - # repo: cypress-example-recipes - # command: npm run test:ci - # pull_request_id: 515 - # folder: examples/fundamentals__typescript - - test-binary-against-kitchensink: - <<: *defaults - steps: - - test-binary-against-repo: - repo: cypress-example-kitchensink - browser: "electron" - - test-binary-against-kitchensink-firefox: - <<: *defaults - steps: - - test-binary-against-repo: - repo: cypress-example-kitchensink - browser: firefox - - test-binary-against-kitchensink-chrome: - <<: *defaults - steps: - - test-binary-against-repo: - repo: cypress-example-kitchensink - browser: chrome - - test-binary-against-todomvc-firefox: - <<: *defaults - steps: - - test-binary-against-repo: - repo: cypress-example-todomvc - browser: firefox - - test-binary-against-conduit-chrome: - <<: *defaults - steps: - - test-binary-against-repo: - repo: cypress-example-conduit-app - browser: chrome - command: "npm run cypress:run" - wait-on: http://localhost:3000 - - test-binary-against-api-testing-firefox: - <<: *defaults - steps: - - test-binary-against-repo: - repo: cypress-example-api-testing - browser: firefox - command: "npm run cy:run" - - test-binary-against-piechopper-firefox: - <<: *defaults - steps: - - test-binary-against-repo: - repo: cypress-example-piechopper - browser: firefox - command: "npm run cypress:run" - - test-binary-against-cypress-realworld-app: - <<: *defaults - resource_class: medium+ - steps: - - test-binary-against-rwa: - repo: cypress-realworld-app - browser: chrome - wait-on: http://localhost:3000 - - test-binary-as-specific-user: - <<: *defaults - steps: - - restore_workspace_binaries - # the user should be "node" - - run: whoami - - run: pwd - # prints the current user's effective user id - # for root it is 0 - # for other users it is a positive integer - - run: node -e 'console.log(process.geteuid())' - # make sure the binary and NPM package files are present - - run: ls -l - - run: ls -l cypress.zip cypress.tgz - - run: mkdir test-binary - - run: - name: Create new NPM package - working_directory: test-binary - command: npm init -y - - run: - # install NPM from built NPM package folder - name: Install Cypress - working_directory: test-binary - # force installing the freshly built binary - command: CYPRESS_INSTALL_BINARY=~/cypress/cypress.zip npm i ~/cypress/cypress.tgz - - run: - name: Cypress help - working_directory: test-binary - command: $(yarn bin cypress) help - - run: - name: Cypress info - working_directory: test-binary - command: $(yarn bin cypress) info - - run: - name: Add Cypress demo - working_directory: test-binary - command: npx @bahmutov/cly@1.9.0 init - - run: - name: Verify Cypress binary - working_directory: test-binary - command: DEBUG=cypress:cli $(yarn bin cypress) verify - - run: - name: Run Cypress binary - working_directory: test-binary - command: DEBUG=cypress:cli $(yarn bin cypress) run - - store-npm-logs - -linux-x64-workflow: &linux-x64-workflow - jobs: - - node_modules_install - - build: - context: test-runner:env-canary - requires: - - node_modules_install - - check-ts: - requires: - - build - - lint: - name: linux-lint - requires: - - build - - percy-finalize: - context: [test-runner:poll-circle-workflow, test-runner:percy] - required_env_var: PERCY_TOKEN # skips job if not defined (external PR) - requires: - - build - - lint-types: - requires: - - build - # unit, integration and e2e tests - - cli-visual-tests: - context: test-runner:percy - requires: - - build - - unit-tests: - requires: - - build - - unit-tests-release: - context: test-runner:npm-release - requires: - - build - - server-unit-tests: - requires: - - build - - server-integration-tests: - requires: - - build - - server-performance-tests: - requires: - - build - - system-tests-node-modules-install: - context: test-runner:performance-tracking - requires: - - build - - system-tests-chrome: - context: test-runner:performance-tracking - requires: - - system-tests-node-modules-install - - system-tests-electron: - context: test-runner:performance-tracking - requires: - - system-tests-node-modules-install - - system-tests-firefox: - context: test-runner:performance-tracking - requires: - - system-tests-node-modules-install - - system-tests-webkit: - context: test-runner:performance-tracking - requires: - - system-tests-node-modules-install - - system-tests-non-root: - context: test-runner:performance-tracking - executor: non-root-docker-user - requires: - - system-tests-node-modules-install - - driver-integration-tests-chrome: - context: test-runner:cypress-record-key - requires: - - build - - driver-integration-tests-chrome-beta: - context: test-runner:cypress-record-key - requires: - - build - - driver-integration-tests-firefox: - context: test-runner:cypress-record-key - requires: - - build - - driver-integration-tests-electron: - context: test-runner:cypress-record-key - requires: - - build - - driver-integration-tests-webkit: - context: test-runner:cypress-record-key - requires: - - build - - driver-integration-tests-chrome-experimentalSessionAndOrigin: - context: test-runner:cypress-record-key - requires: - - build - - driver-integration-tests-chrome-beta-experimentalSessionAndOrigin: - context: test-runner:cypress-record-key - requires: - - build - - driver-integration-tests-firefox-experimentalSessionAndOrigin: - context: test-runner:cypress-record-key - requires: - - build - - driver-integration-tests-electron-experimentalSessionAndOrigin: - context: test-runner:cypress-record-key - requires: - - build - - driver-integration-tests-webkit-experimentalSessionAndOrigin: - context: test-runner:cypress-record-key - requires: - - build - - run-frontend-shared-component-tests-chrome: - context: [test-runner:cypress-record-key, test-runner:launchpad-tests, test-runner:percy] - percy: true - requires: - - build - - run-launchpad-integration-tests-chrome: - context: [test-runner:cypress-record-key, test-runner:launchpad-tests, test-runner:percy] - percy: true - requires: - - build - - run-launchpad-component-tests-chrome: - context: [test-runner:cypress-record-key, test-runner:launchpad-tests, test-runner:percy] - percy: true - requires: - - build - - run-app-integration-tests-chrome: - context: [test-runner:cypress-record-key, test-runner:launchpad-tests, test-runner:percy] - percy: true - requires: - - build - - run-webpack-dev-server-integration-tests: - context: [test-runner:cypress-record-key, test-runner:percy] - requires: - - system-tests-node-modules-install - - run-vite-dev-server-integration-tests: - context: [test-runner:cypress-record-key, test-runner:percy] - requires: - - system-tests-node-modules-install - - run-app-component-tests-chrome: - context: [test-runner:cypress-record-key, test-runner:launchpad-tests, test-runner:percy] - percy: true - requires: - - build - - run-reporter-component-tests-chrome: - context: [test-runner:cypress-record-key, test-runner:percy] - percy: true - requires: - - build - - reporter-integration-tests: - context: [test-runner:cypress-record-key, test-runner:percy] - requires: - - build - - npm-webpack-dev-server: - requires: - - system-tests-node-modules-install - - npm-vite-dev-server: - requires: - - build - - npm-webpack-preprocessor: - requires: - - build - - npm-webpack-batteries-included-preprocessor: - requires: - - build - - npm-vue: - requires: - - build - - npm-react: - requires: - - build - - npm-angular: - requires: - - build - - npm-mount-utils: - requires: - - build - - npm-create-cypress-tests: - requires: - - build - - npm-eslint-plugin-dev: - requires: - - build - - npm-cypress-schematic: - requires: - - build - - v8-integration-tests: - requires: - - system-tests-node-modules-install - # This release definition must be updated with any new jobs - # Any attempts to automate this are welcome - # If CircleCI provided an "after all" hook, then this wouldn't be necessary - - npm-release: - context: test-runner:npm-release - requires: - - build - - check-ts - - npm-angular - - npm-eslint-plugin-dev - - npm-create-cypress-tests - - npm-react - - npm-mount-utils - - npm-vue - - npm-webpack-batteries-included-preprocessor - - npm-webpack-preprocessor - - npm-vite-dev-server - - npm-webpack-dev-server - - npm-cypress-schematic - - lint-types - - linux-lint - - percy-finalize - - driver-integration-tests-firefox - - driver-integration-tests-chrome - - driver-integration-tests-chrome-beta - - driver-integration-tests-electron - - driver-integration-tests-firefox-experimentalSessionAndOrigin - - driver-integration-tests-chrome-experimentalSessionAndOrigin - - driver-integration-tests-chrome-beta-experimentalSessionAndOrigin - - driver-integration-tests-electron-experimentalSessionAndOrigin - - system-tests-non-root - - system-tests-firefox - - system-tests-electron - - system-tests-chrome - - server-performance-tests - - server-integration-tests - - server-unit-tests - - test-kitchensink - - unit-tests - - unit-tests-release - - cli-visual-tests - - reporter-integration-tests - - run-app-component-tests-chrome - - run-app-integration-tests-chrome - - run-frontend-shared-component-tests-chrome - - run-launchpad-component-tests-chrome - - run-launchpad-integration-tests-chrome - - run-reporter-component-tests-chrome - - run-webpack-dev-server-integration-tests - - run-vite-dev-server-integration-tests - - v8-integration-tests - - # various testing scenarios, like building full binary - # and testing it on a real project - - test-against-staging: - context: test-runner:record-tests - <<: *mainBuildFilters - requires: - - build - - test-kitchensink: - requires: - - build - - test-kitchensink-against-staging: - context: test-runner:record-tests - <<: *mainBuildFilters - requires: - - build - - create-build-artifacts: - context: - - test-runner:upload - - test-runner:commit-status-checks - requires: - - build - - test-npm-module-on-minimum-node-version: - requires: - - create-build-artifacts - - test-types-cypress-and-jest: - requires: - - create-build-artifacts - - test-full-typescript-project: - requires: - - create-build-artifacts - - test-binary-against-kitchensink: - requires: - - create-build-artifacts - - test-npm-module-and-verify-binary: - <<: *mainBuildFilters - requires: - - create-build-artifacts - - test-binary-against-staging: - context: test-runner:record-tests - <<: *mainBuildFilters - requires: - - create-build-artifacts - - test-binary-against-kitchensink-chrome: - <<: *mainBuildFilters - requires: - - create-build-artifacts - - test-binary-against-recipes-firefox: - <<: *mainBuildFilters - requires: - - create-build-artifacts - - test-binary-against-recipes-chrome: - <<: *mainBuildFilters - requires: - - create-build-artifacts - - test-binary-against-recipes: - <<: *mainBuildFilters - requires: - - create-build-artifacts - - test-binary-against-kitchensink-firefox: - <<: *mainBuildFilters - requires: - - create-build-artifacts - - test-binary-against-todomvc-firefox: - <<: *mainBuildFilters - requires: - - create-build-artifacts - - test-binary-against-cypress-realworld-app: - <<: *mainBuildFilters - requires: - - create-build-artifacts - - test-binary-as-specific-user: - name: "test binary as a non-root user" - executor: non-root-docker-user - requires: - - create-build-artifacts - - test-binary-as-specific-user: - name: "test binary as a root user" - requires: - - create-build-artifacts - - binary-system-tests: - requires: - - create-build-artifacts - - system-tests-node-modules-install - -linux-arm64-workflow: &linux-arm64-workflow - jobs: - - node_modules_install: - name: linux-arm64-node-modules-install - executor: linux-arm64 - resource_class: arm.medium - only-cache-for-root-user: true - - - build: - name: linux-arm64-build - executor: linux-arm64 - resource_class: arm.medium - requires: - - linux-arm64-node-modules-install - - - create-build-artifacts: - name: linux-arm64-create-build-artifacts - context: - - test-runner:upload - - test-runner:commit-status-checks - executor: linux-arm64 - resource_class: arm.medium - requires: - - linux-arm64-build - - - v8-integration-tests: - name: linux-arm64-v8-integration-tests - executor: linux-arm64 - resource_class: arm.medium - requires: - - linux-arm64-build - -darwin-x64-workflow: &darwin-x64-workflow - jobs: - - node_modules_install: - name: darwin-x64-node-modules-install - executor: mac - resource_class: macos.x86.medium.gen2 - only-cache-for-root-user: true - - - build: - name: darwin-x64-build - context: test-runner:env-canary - executor: mac - resource_class: macos.x86.medium.gen2 - requires: - - darwin-x64-node-modules-install - - - lint: - name: darwin-x64-lint - executor: mac - requires: - - darwin-x64-build - - - create-build-artifacts: - name: darwin-x64-create-build-artifacts - context: - - test-runner:sign-mac-binary - - test-runner:upload - - test-runner:commit-status-checks - executor: mac - resource_class: macos.x86.medium.gen2 - requires: - - darwin-x64-build - - - test-kitchensink: - name: darwin-x64-test-kitchensink - executor: mac - requires: - - darwin-x64-build - - - v8-integration-tests: - name: darwin-x64-v8-integration-tests - executor: mac - resource_class: macos.x86.medium.gen2 - requires: - - darwin-x64-build - -darwin-arm64-workflow: &darwin-arm64-workflow - jobs: - - node_modules_install: - name: darwin-arm64-node-modules-install - executor: darwin-arm64 - resource_class: cypress-io/latest_m1 - only-cache-for-root-user: true - - - build: - name: darwin-arm64-build - executor: darwin-arm64 - resource_class: cypress-io/latest_m1 - requires: - - darwin-arm64-node-modules-install - - - create-build-artifacts: - name: darwin-arm64-create-build-artifacts - context: - - test-runner:sign-mac-binary - - test-runner:upload - - test-runner:commit-status-checks - executor: darwin-arm64 - resource_class: cypress-io/latest_m1 - requires: - - darwin-arm64-build - - - v8-integration-tests: - name: darwin-arm64-v8-integration-tests - executor: darwin-arm64 - resource_class: cypress-io/latest_m1 - requires: - - darwin-arm64-build - -windows-workflow: &windows-workflow - jobs: - - node_modules_install: - name: windows-node-modules-install - executor: windows - resource_class: windows.large - only-cache-for-root-user: true - - - build: - name: windows-build - context: test-runner:env-canary - executor: windows - resource_class: windows.large - requires: - - windows-node-modules-install - - - run-app-integration-tests-chrome: - name: windows-run-app-integration-tests-chrome - executor: windows - resource_class: windows.large - context: [test-runner:cypress-record-key, test-runner:launchpad-tests] - requires: - - windows-build - - - run-launchpad-integration-tests-chrome: - name: windows-run-launchpad-integration-tests-chrome - executor: windows - resource_class: windows.large - context: [test-runner:cypress-record-key, test-runner:launchpad-tests] - requires: - - windows-build - - - lint: - name: windows-lint - executor: windows - requires: - - windows-build - - - unit-tests: - name: windows-unit-tests - executor: windows - resource_class: windows.large - requires: - - windows-build - - - create-build-artifacts: - name: windows-create-build-artifacts - executor: windows - resource_class: windows.large - context: - - test-runner:sign-windows-binary - - test-runner:upload - - test-runner:commit-status-checks - requires: - - windows-build - - test-binary-against-kitchensink-chrome: - name: windows-test-binary-against-kitchensink-chrome - executor: windows - requires: - - windows-create-build-artifacts - - - v8-integration-tests: - name: windows-v8-integration-tests - executor: windows - resource_class: windows.large - requires: - - windows-build + - continuation/continue: + configuration_path: workflows.yml workflows: - linux-x64: - <<: *linux-x64-workflow - <<: *linux-x64-workflow-exclude-filters - linux-arm64: - <<: *linux-arm64-workflow - <<: *linux-arm64-workflow-filters - darwin-x64: - <<: *darwin-x64-workflow - <<: *darwin-workflow-filters - darwin-arm64: - <<: *darwin-arm64-workflow - <<: *darwin-workflow-filters - windows: - <<: *windows-workflow - <<: *windows-workflow-filters + # the setup-workflow workflow is always triggered. + setup-workflow: + jobs: + - verify-ci-should-run: + context: workflow-setup From d4ef5b48437043f0a190993b2725f810e63feec8 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Mon, 28 Nov 2022 13:12:28 -0600 Subject: [PATCH 14/27] Update workflows.yml --- .circleci/workflows.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.circleci/workflows.yml b/.circleci/workflows.yml index d7b0ad260f95..5d401a3a1f80 100644 --- a/.circleci/workflows.yml +++ b/.circleci/workflows.yml @@ -27,7 +27,7 @@ mainBuildFilters: &mainBuildFilters branches: only: - develop - - 'feature/run-all-specs' + - 'ryanm/fix/cy-in-cy-and-v8-snapshots' # usually we don't build Mac app - it takes a long time # but sometimes we want to really confirm we are doing the right thing @@ -36,7 +36,7 @@ macWorkflowFilters: &darwin-workflow-filters when: or: - equal: [ develop, << pipeline.git.branch >> ] - - equal: [ 'feature/run-all-specs', << pipeline.git.branch >> ] + - equal: [ 'ryanm/fix/cy-in-cy-and-v8-snapshots', << pipeline.git.branch >> ] - matches: pattern: "-release$" value: << pipeline.git.branch >> @@ -45,7 +45,7 @@ linuxArm64WorkflowFilters: &linux-arm64-workflow-filters when: or: - equal: [ develop, << pipeline.git.branch >> ] - - equal: [ 'feature/run-all-specs', << pipeline.git.branch >> ] + - equal: [ 'ryanm/fix/cy-in-cy-and-v8-snapshots', << pipeline.git.branch >> ] - matches: pattern: "-release$" value: << pipeline.git.branch >> @@ -63,7 +63,7 @@ windowsWorkflowFilters: &windows-workflow-filters when: or: - equal: [ develop, << pipeline.git.branch >> ] - - equal: [ 'astone123/fix-windows-lint', << pipeline.git.branch >> ] + - equal: [ 'ryanm/fix/cy-in-cy-and-v8-snapshots', << pipeline.git.branch >> ] - matches: pattern: "-release$" value: << pipeline.git.branch >> @@ -130,7 +130,7 @@ commands: - run: name: Check current branch to persist artifacts command: | - if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "feature/run-all-specs" ]]; then + if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "ryanm/fix/cy-in-cy-and-v8-snapshots" ]]; then echo "Not uploading artifacts or posting install comment for this branch." circleci-agent step halt fi From dd6d5d9223d86d838521bc3445f7a2e9bcb22355 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Mon, 28 Nov 2022 13:13:25 -0600 Subject: [PATCH 15/27] refactoring --- packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts | 9 ++------- packages/rewriter/script/worker-shim.js | 2 +- packages/server/hook-require.js | 2 +- packages/server/index.js | 2 +- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts b/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts index 2faca21e56e5..b4dcdbcb38b4 100644 --- a/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts +++ b/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts @@ -1,11 +1,6 @@ -if (require.name !== 'customRequire') { - // Purposefully make this a dynamic require so that it doesn't have the potential to get picked up by snapshotting mechanism - const hook = '@packages/server/hook' +const { hookRequire } = require('@packages/server/hook-require') - const { hookRequire } = require(`${hook}-require`) - - hookRequire(false) -} +hookRequire({ forceTypeScript: false }) import path from 'path' import execa from 'execa' diff --git a/packages/rewriter/script/worker-shim.js b/packages/rewriter/script/worker-shim.js index 2a61bf648282..2825dc9f2ff1 100644 --- a/packages/rewriter/script/worker-shim.js +++ b/packages/rewriter/script/worker-shim.js @@ -9,7 +9,7 @@ if (require.name !== 'customRequire') { const { hookRequire } = require(`@packages/server/${hook}-require`) - hookRequire(true) + hookRequire({ forceTypeScript: true }) } require('../lib/threads/worker.ts') diff --git a/packages/server/hook-require.js b/packages/server/hook-require.js index a328364fabf5..98781d2f7eb4 100644 --- a/packages/server/hook-require.js +++ b/packages/server/hook-require.js @@ -30,7 +30,7 @@ function runWithSnapshot (forceTypeScript) { }) } -const hookRequire = (forceTypeScript) => { +const hookRequire = ({ forceTypeScript }) => { if (['1', 'true'].includes(process.env.DISABLE_SNAPSHOT_REQUIRE) || typeof snapshotResult === 'undefined') { require('@packages/ts/register') } else { diff --git a/packages/server/index.js b/packages/server/index.js index d1dce918085e..b1a753d9aad5 100644 --- a/packages/server/index.js +++ b/packages/server/index.js @@ -14,7 +14,7 @@ const runMainProcess = async () => { const { hookRequire } = require(`${hook}-require`) - hookRequire(false) + hookRequire({ forceTypeScript: false }) } await require('./server-entry') From 51eff1c4ae12a9402750bb11ac5682305a5b4857 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Mon, 28 Nov 2022 13:15:07 -0600 Subject: [PATCH 16/27] cleanup --- system-tests/projects/component-tests/package.json | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 system-tests/projects/component-tests/package.json diff --git a/system-tests/projects/component-tests/package.json b/system-tests/projects/component-tests/package.json deleted file mode 100644 index 455ba9f1c455..000000000000 --- a/system-tests/projects/component-tests/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "component-tests", - "version": "0.0.0" -} From c962c42e20406955aa2323d6218c65c1a32edc05 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Mon, 28 Nov 2022 13:44:02 -0600 Subject: [PATCH 17/27] run ci From 737391bdba511adcbc9850ad52df74564ef57a11 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Mon, 5 Dec 2022 12:22:06 -0600 Subject: [PATCH 18/27] clean up the bytenode dependency --- package.json | 5 +- scripts/after-pack-hook.js | 111 ++++++++++-------- scripts/binary/binary-entry-point-source.js | 2 +- .../binary/binary-integrity-check-source.js | 13 +- scripts/binary/binary-sources.js | 14 ++- scripts/binary/build.ts | 1 - scripts/binary/smoke.js | 1 - 7 files changed, 73 insertions(+), 74 deletions(-) diff --git a/package.json b/package.json index 60636530ce27..99f660149848 100644 --- a/package.json +++ b/package.json @@ -69,10 +69,6 @@ "watch": "yarn gulp watch", "prepare": "husky install" }, - "dependencies": { - "bytenode": "1.3.7", - "nvm": "0.0.4" - }, "devDependencies": { "@aws-sdk/credential-providers": "3.53.0", "@cypress/questions-remain": "1.0.1", @@ -132,6 +128,7 @@ "babel-eslint": "10.1.0", "bluebird": "3.5.3", "bluebird-retry": "0.11.0", + "bytenode": "1.3.7", "c8": "^7.10.0", "chai": "4.2.0", "chai-as-promised": "7.1.1", diff --git a/scripts/after-pack-hook.js b/scripts/after-pack-hook.js index 1a2f9a83a391..3723d97e40ee 100644 --- a/scripts/after-pack-hook.js +++ b/scripts/after-pack-hook.js @@ -10,67 +10,74 @@ const { buildEntryPointAndCleanup } = require('./binary/binary-cleanup') const { getIntegrityCheckSource, getBinaryEntryPointSource } = require('./binary/binary-sources') module.exports = async function (params) { - console.log('****************************') - console.log('After pack hook') - console.log(params.appOutDir) - console.log(params.outDir) - console.log(params.electronPlatformName) - console.log('****************************') - - const packages = glob.sync('packages/*/node_modules', { - cwd: params.packager.info._appDir, - }) - - const buildSubfoldersPerPlatform = { - darwin: join('Cypress.app', 'Contents', 'Resources', 'app'), - linux: join('resources', 'app'), - win32: join('resources', 'app'), // TODO check this path - } - const buildSubfolder = buildSubfoldersPerPlatform[os.platform()] - const outputFolder = join(params.appOutDir, buildSubfolder) + try { + console.log('****************************') + console.log('After pack hook') + console.log(params.appOutDir) + console.log(params.outDir) + console.log(params.electronPlatformName) + console.log('****************************') - console.log('copying node_modules to', outputFolder) + const packages = glob.sync('packages/*/node_modules', { + cwd: params.packager.info._appDir, + }) - for await (const packageNodeModules of packages) { - console.log('copying', packageNodeModules) + const buildSubfoldersPerPlatform = { + darwin: join('Cypress.app', 'Contents', 'Resources', 'app'), + linux: join('resources', 'app'), + win32: join('resources', 'app'), // TODO check this path + } + const buildSubfolder = buildSubfoldersPerPlatform[os.platform()] + const outputFolder = join(params.appOutDir, buildSubfolder) - const sourceFolder = join(params.packager.info._appDir, packageNodeModules) - const destinationFolder = join(outputFolder, packageNodeModules) + console.log('copying node_modules to', outputFolder) - await fs.copy(sourceFolder, destinationFolder) - } + for await (const packageNodeModules of packages) { + console.log('copying', packageNodeModules) - const distNodeModules = path.join(params.packager.info._appDir, 'node_modules') - const appNodeModules = path.join(outputFolder, 'node_modules') + const sourceFolder = join(params.packager.info._appDir, packageNodeModules) + const destinationFolder = join(outputFolder, packageNodeModules) - console.log('copying ', distNodeModules, ' to', appNodeModules) + await fs.copy(sourceFolder, destinationFolder) + } - await fs.copy(distNodeModules, appNodeModules) + const distNodeModules = path.join(params.packager.info._appDir, 'node_modules') + const appNodeModules = path.join(outputFolder, 'node_modules') - console.log('all node_modules subfolders copied to', outputFolder) + console.log('copying ', distNodeModules, ' to', appNodeModules) - const exePathPerPlatform = { - darwin: join(params.appOutDir, 'Cypress.app', 'Contents', 'MacOS', 'Cypress'), - linux: join(params.appOutDir, 'Cypress'), - win32: join(params.appOutDir, 'Cypress.exe'), - } + await fs.copy(distNodeModules, appNodeModules) - if (!['1', 'true'].includes(process.env.DISABLE_SNAPSHOT_REQUIRE)) { - await fs.writeFile(path.join(outputFolder, 'index.js'), getBinaryEntryPointSource()) - - await flipFuses( - exePathPerPlatform[os.platform()], - { - version: FuseVersion.V1, - [FuseV1Options.LoadBrowserProcessSpecificV8Snapshot]: true, - }, - ) - - // Build out the entry point and clean up prior to setting up v8 snapshots so that the state of the binary is correct - await buildEntryPointAndCleanup(outputFolder) - await setupV8Snapshots({ - cypressAppPath: params.appOutDir, - integrityCheckSource: getIntegrityCheckSource(outputFolder), - }) + console.log('all node_modules subfolders copied to', outputFolder) + + const exePathPerPlatform = { + darwin: join(params.appOutDir, 'Cypress.app', 'Contents', 'MacOS', 'Cypress'), + linux: join(params.appOutDir, 'Cypress'), + win32: join(params.appOutDir, 'Cypress.exe'), + } + + if (!['1', 'true'].includes(process.env.DISABLE_SNAPSHOT_REQUIRE)) { + const binaryEntryPointSource = await getBinaryEntryPointSource() + + await fs.writeFile(path.join(outputFolder, 'index.js'), binaryEntryPointSource) + + await flipFuses( + exePathPerPlatform[os.platform()], + { + version: FuseVersion.V1, + [FuseV1Options.LoadBrowserProcessSpecificV8Snapshot]: true, + }, + ) + + // Build out the entry point and clean up prior to setting up v8 snapshots so that the state of the binary is correct + await buildEntryPointAndCleanup(outputFolder) + await setupV8Snapshots({ + cypressAppPath: params.appOutDir, + integrityCheckSource: getIntegrityCheckSource(outputFolder), + }) + } + } catch (error) { + console.log(error) + throw error } } diff --git a/scripts/binary/binary-entry-point-source.js b/scripts/binary/binary-entry-point-source.js index ddf0469eeebf..fcab4c31418c 100644 --- a/scripts/binary/binary-entry-point-source.js +++ b/scripts/binary/binary-entry-point-source.js @@ -3,7 +3,7 @@ const path = require('path') process.env.CYPRESS_INTERNAL_ENV = process.env.CYPRESS_INTERNAL_ENV || 'production' try { - require('./node_modules/bytenode/lib/index.js') + require('bytenode') const filename = path.join(__dirname, 'packages', 'server', 'index.jsc') const dirname = path.dirname(filename) diff --git a/scripts/binary/binary-integrity-check-source.js b/scripts/binary/binary-integrity-check-source.js index cec2c9316ca9..59f4a89cf98b 100644 --- a/scripts/binary/binary-integrity-check-source.js +++ b/scripts/binary/binary-integrity-check-source.js @@ -143,9 +143,9 @@ function integrityCheck (options) { fileName: 'evalmachine.', }, { - functionName: 'Module._extensions.', + functionName: 'Module2._extensions.', // eslint-disable-next-line no-undef - fileName: [appPath, 'node_modules', 'bytenode', 'lib', 'index.js'].join(PATH_SEP), + fileName: [appPath, 'index.js'].join(PATH_SEP), }, { // eslint-disable-next-line no-undef @@ -164,15 +164,6 @@ function integrityCheck (options) { errorMessage: 'Integrity check failed for main index.js file', }) - validateFile({ - // eslint-disable-next-line no-undef - filePath: [appPath, 'node_modules', 'bytenode', 'lib', 'index.js'].join(PATH_SEP), - crypto, - fs, - expectedHash: 'BYTENODE_HASH', - errorMessage: 'Integrity check failed for main bytenode.js file', - }) - validateFile({ // eslint-disable-next-line no-undef filePath: [appPath, 'packages', 'server', 'index.jsc'].join(PATH_SEP), diff --git a/scripts/binary/binary-sources.js b/scripts/binary/binary-sources.js index 077ff675dd28..2e9d1ade817a 100644 --- a/scripts/binary/binary-sources.js +++ b/scripts/binary/binary-sources.js @@ -1,6 +1,7 @@ const fs = require('fs') const crypto = require('crypto') const path = require('path') +const esbuild = require('esbuild') const escapeString = (string) => string.replaceAll(`\``, `\\\``).replaceAll(`$`, `\\$`) @@ -10,8 +11,15 @@ function read (file) { return fs.readFileSync(pathToFile, 'utf8') } -const getBinaryEntryPointSource = () => { - return read('binary-entry-point-source.js') +const getBinaryEntryPointSource = async () => { + const esbuildResult = await esbuild.build({ + entryPoints: [require.resolve('./binary-entry-point-source.js')], + bundle: true, + platform: 'node', + write: false, + }) + + return esbuildResult.outputFiles[0].text } const getIntegrityCheckSource = (baseDirectory) => { @@ -19,12 +27,10 @@ const getIntegrityCheckSource = (baseDirectory) => { const secret = require('crypto').randomBytes(48).toString('hex') const mainIndexHash = crypto.createHmac('md5', secret).update(fs.readFileSync(path.join(baseDirectory, './index.js'), 'utf8')).digest('hex') - const bytenodeHash = crypto.createHmac('md5', secret).update(fs.readFileSync(path.join(baseDirectory, './node_modules/bytenode/lib/index.js'), 'utf8')).digest('hex') const indexJscHash = crypto.createHmac('md5', secret).update(fs.readFileSync(path.join(baseDirectory, './packages/server/index.jsc'), 'utf8')).digest('hex') return fileSource.split('\n').join(`\n `) .replaceAll('MAIN_INDEX_HASH', mainIndexHash) - .replaceAll('BYTENODE_HASH', bytenodeHash) .replaceAll('INDEX_JSC_HASH', indexJscHash) .replaceAll('HMAC_SECRET', secret) .replaceAll('CRYPTO_CREATE_HMAC_TO_STRING', escapeString(crypto.createHmac.toString())) diff --git a/scripts/binary/build.ts b/scripts/binary/build.ts index 65a85334d4df..5215733c82c6 100644 --- a/scripts/binary/build.ts +++ b/scripts/binary/build.ts @@ -176,7 +176,6 @@ export async function buildCypressApp (options: BuildCypressAppOpts) { fs.writeFileSync(meta.distDir('index.js'), `\ process.env.CYPRESS_INTERNAL_ENV = process.env.CYPRESS_INTERNAL_ENV || 'production' -require('./node_modules/bytenode/lib/index.js') require('./packages/server/index.js') `) diff --git a/scripts/binary/smoke.js b/scripts/binary/smoke.js index 6438ca54e50d..cbe38d75674a 100644 --- a/scripts/binary/smoke.js +++ b/scripts/binary/smoke.js @@ -264,7 +264,6 @@ const runIntegrityTest = async function (buildAppExecutable, buildAppDir, e2e) { await testCorruptingFile(path.join(buildAppDir, 'index.js'), 'Integrity check failed for main index.js file') await testCorruptingFile(path.join(buildAppDir, 'packages', 'server', 'index.jsc'), 'Integrity check failed for main server index.jsc file') - await testCorruptingFile(path.join(buildAppDir, 'node_modules', 'bytenode', 'lib', 'index.js'), 'Integrity check failed for main bytenode.js file') const testAlteringEntryPoint = async (additionalCode, errorMessage) => { const packageJsonContents = await fs.readJSON(path.join(buildAppDir, 'package.json')) From 7d80f64b2174e89fb2953bb1437ca2026fc676ae Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Mon, 5 Dec 2022 13:01:16 -0600 Subject: [PATCH 19/27] fix build --- packages/server/index.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/server/index.js b/packages/server/index.js index 6385db1d3ebd..fdda14fc0f25 100644 --- a/packages/server/index.js +++ b/packages/server/index.js @@ -4,19 +4,21 @@ const runChildProcess = async (entryPoint) => { } const startCypress = async () => { - const { initializeStartTime } = require('./lib/util/performance_benchmark') + try { + const { initializeStartTime } = require('./lib/util/performance_benchmark') - initializeStartTime() + initializeStartTime() - const { hookRequire } = require('./hook-require') + const { hookRequire } = require('./hook-require') - hookRequire({ forceTypeScript: false }) + hookRequire({ forceTypeScript: false }) - await require('./start-cypress') -} catch (error) { + await require('./start-cypress') + } catch (error) { // eslint-disable-next-line no-console - console.error(error) - process.exit(1) + console.error(error) + process.exit(1) + } } const { entryPoint } = require('minimist')(process.argv.slice(1)) From 08732204787bab27a7b520cc78790da799b6c6ee Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Mon, 5 Dec 2022 16:07:45 -0600 Subject: [PATCH 20/27] update yarn.lock --- yarn.lock | 5 ----- 1 file changed, 5 deletions(-) diff --git a/yarn.lock b/yarn.lock index 3d38e0871942..60d905d0e00c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -25383,11 +25383,6 @@ number-is-nan@^1.0.0: resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0= -nvm@0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/nvm/-/nvm-0.0.4.tgz#38a178e9d31b283508c92d15c9da861d1a9210bc" - integrity sha1-OKF46dMbKDUIyS0VydqGHRqSELw= - nwsapi@^2.0.7, nwsapi@^2.0.9, nwsapi@^2.1.3: version "2.2.0" resolved "https://registry.yarnpkg.com/nwsapi/-/nwsapi-2.2.0.tgz#204879a9e3d068ff2a55139c2c772780681a38b7" From 5179d50edf768cac66241c0229f6f3cde1b4ba78 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Mon, 5 Dec 2022 20:39:34 -0600 Subject: [PATCH 21/27] Update cache-version.txt --- .circleci/cache-version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/cache-version.txt b/.circleci/cache-version.txt index fc3ae1411bde..ac501d1253cf 100644 --- a/.circleci/cache-version.txt +++ b/.circleci/cache-version.txt @@ -1,3 +1,3 @@ # Bump this version to force CI to re-create the cache from scratch. -12-01-22 +12-05-22 From ce86292a391870f9c46b18301125f51646e10e57 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Tue, 6 Dec 2022 12:05:39 -0600 Subject: [PATCH 22/27] Update packages/data-context/src/data/ProjectConfigIpc.ts --- packages/data-context/src/data/ProjectConfigIpc.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/data-context/src/data/ProjectConfigIpc.ts b/packages/data-context/src/data/ProjectConfigIpc.ts index 98550d726e46..bbe7a372d200 100644 --- a/packages/data-context/src/data/ProjectConfigIpc.ts +++ b/packages/data-context/src/data/ProjectConfigIpc.ts @@ -319,11 +319,11 @@ export class ProjectConfigIpc extends EventEmitter { debug(`no typescript found, just use regular Node.js`) } - if (isSandboxNeeded()) { - configProcessArgs.push('--no-sandbox') - } - if (process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT) { + if (isSandboxNeeded()) { + configProcessArgs.push('--no-sandbox') + } + return spawn(process.execPath, ['--entryPoint', CHILD_PROCESS_FILE_PATH, ...configProcessArgs], { ...childOptions, stdio: ['pipe', 'pipe', 'pipe', 'ipc'], From 2bf7b8a284f6b1294e80c5509709ed26057becb9 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Tue, 6 Dec 2022 12:07:49 -0600 Subject: [PATCH 23/27] Update packages/server/index.js --- packages/server/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/index.js b/packages/server/index.js index fdda14fc0f25..e5a5d503a7c1 100644 --- a/packages/server/index.js +++ b/packages/server/index.js @@ -15,7 +15,7 @@ const startCypress = async () => { await require('./start-cypress') } catch (error) { - // eslint-disable-next-line no-console + // eslint-disable-next-line no-console console.error(error) process.exit(1) } From d8f5dcf5f353bddfcd5a48ec6822f50bafd88fec Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Tue, 6 Dec 2022 12:58:55 -0600 Subject: [PATCH 24/27] move around the hook for snapshots --- packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts | 4 ---- packages/server/index.js | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts b/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts index b4dcdbcb38b4..fb8cbb5c8057 100644 --- a/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts +++ b/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts @@ -1,7 +1,3 @@ -const { hookRequire } = require('@packages/server/hook-require') - -hookRequire({ forceTypeScript: false }) - import path from 'path' import execa from 'execa' diff --git a/packages/server/index.js b/packages/server/index.js index e5a5d503a7c1..fed2bdd7116a 100644 --- a/packages/server/index.js +++ b/packages/server/index.js @@ -1,5 +1,10 @@ const runChildProcess = async (entryPoint) => { require('./lib/plugins/child/register_ts_node') + + const { hookRequire } = require('@packages/server/hook-require') + + hookRequire({ forceTypeScript: false }) + require(entryPoint) } From 1ff59273fff9dad19e812c788d15c4e9a6cc4176 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Tue, 6 Dec 2022 14:36:58 -0600 Subject: [PATCH 25/27] ensure to fail if snapshots become unavailable for cypress in cypress --- packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts b/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts index fb8cbb5c8057..82d4c1d5ecf9 100644 --- a/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts +++ b/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts @@ -43,6 +43,11 @@ chai.use(chaiSubset) chai.use(sinonChai) export async function e2ePluginSetup (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) { + // @ts-ignore snapshotAuxiliaryData is injected by the snapshot script + if (typeof global.snapshotAuxiliaryData === 'undefined') { + throw new Error('snapshotAuxiliaryData is undefined. v8 snapshots are not being used in Cypress in Cypress') + } + process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF = 'true' delete process.env.CYPRESS_INTERNAL_GRAPHQL_PORT delete process.env.CYPRESS_INTERNAL_VITE_DEV From ea405645bc57b17a5c3113476dfabf2430ef0385 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Tue, 6 Dec 2022 15:07:38 -0600 Subject: [PATCH 26/27] undo refactor --- packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts | 4 ++++ packages/server/index.js | 5 ----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts b/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts index 82d4c1d5ecf9..09cd4ff25773 100644 --- a/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts +++ b/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts @@ -1,3 +1,7 @@ +import { hookRequire } from '@packages/server/hook-require' + +hookRequire({ forceTypeScript: false }) + import path from 'path' import execa from 'execa' diff --git a/packages/server/index.js b/packages/server/index.js index fed2bdd7116a..e5a5d503a7c1 100644 --- a/packages/server/index.js +++ b/packages/server/index.js @@ -1,10 +1,5 @@ const runChildProcess = async (entryPoint) => { require('./lib/plugins/child/register_ts_node') - - const { hookRequire } = require('@packages/server/hook-require') - - hookRequire({ forceTypeScript: false }) - require(entryPoint) } From d483d4744dc965e6c01d3c6c90702af330e34a72 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Wed, 7 Dec 2022 14:54:05 -0600 Subject: [PATCH 27/27] use getSnapshotResult for check in e2eplugins --- .../prod-darwin/snapshot-meta.cache.json | 57 +++++++++---------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/tooling/v8-snapshot/cache/prod-darwin/snapshot-meta.cache.json b/tooling/v8-snapshot/cache/prod-darwin/snapshot-meta.cache.json index b5b881125887..a4d732dae7c0 100644 --- a/tooling/v8-snapshot/cache/prod-darwin/snapshot-meta.cache.json +++ b/tooling/v8-snapshot/cache/prod-darwin/snapshot-meta.cache.json @@ -4,10 +4,6 @@ "./get-stream/buffer-stream.js", "./graceful-fs/polyfills.js", "./lockfile/lockfile.js", - "./node_modules/@babel/traverse/lib/path/comments.js", - "./node_modules/@babel/traverse/lib/path/conversion.js", - "./node_modules/@babel/traverse/lib/path/family.js", - "./node_modules/@babel/traverse/lib/path/introspection.js", "./node_modules/@cspotcode/source-map-support/source-map-support.js", "./node_modules/@cypress/commit-info/node_modules/debug/src/node.js", "./node_modules/@cypress/get-windows-proxy/node_modules/debug/src/node.js", @@ -44,6 +40,10 @@ "./node_modules/tcp-port-used/node_modules/debug/src/node.js", "./node_modules/trash/node_modules/make-dir/index.js", "./node_modules/utif/UTIF.js", + "./packages/config/node_modules/@babel/traverse/lib/path/comments.js", + "./packages/config/node_modules/@babel/traverse/lib/path/conversion.js", + "./packages/config/node_modules/@babel/traverse/lib/path/family.js", + "./packages/config/node_modules/@babel/traverse/lib/path/introspection.js", "./packages/data-context/node_modules/debug/src/node.js", "./packages/data-context/node_modules/minimatch/minimatch.js", "./packages/graphql/node_modules/debug/src/node.js", @@ -54,6 +54,7 @@ "./packages/server/lib/capture.js", "./packages/server/lib/cloud/exception.ts", "./packages/server/lib/errors.ts", + "./packages/server/lib/makeDataContext.ts", "./packages/server/lib/modes/record.js", "./packages/server/lib/modes/run.ts", "./packages/server/lib/open_project.ts", @@ -75,17 +76,6 @@ "deferred": [ "./node_modules/@babel/generator/lib/node/index.js", "./node_modules/@babel/generator/lib/node/whitespace.js", - "./node_modules/@babel/helper-environment-visitor/lib/index.js", - "./node_modules/@babel/traverse/lib/context.js", - "./node_modules/@babel/traverse/lib/index.js", - "./node_modules/@babel/traverse/lib/path/ancestry.js", - "./node_modules/@babel/traverse/lib/path/context.js", - "./node_modules/@babel/traverse/lib/path/index.js", - "./node_modules/@babel/traverse/lib/path/modification.js", - "./node_modules/@babel/traverse/lib/path/removal.js", - "./node_modules/@babel/traverse/lib/path/replacement.js", - "./node_modules/@babel/traverse/lib/scope/index.js", - "./node_modules/@babel/traverse/lib/traverse-node.js", "./node_modules/@babel/types/lib/definitions/core.js", "./node_modules/@babel/types/lib/definitions/experimental.js", "./node_modules/@babel/types/lib/definitions/flow.js", @@ -630,6 +620,15 @@ "./node_modules/yauzl/index.js", "./node_modules/zip-stream/index.js", "./packages/config/index.js", + "./packages/config/node_modules/@babel/traverse/lib/context.js", + "./packages/config/node_modules/@babel/traverse/lib/index.js", + "./packages/config/node_modules/@babel/traverse/lib/path/ancestry.js", + "./packages/config/node_modules/@babel/traverse/lib/path/context.js", + "./packages/config/node_modules/@babel/traverse/lib/path/index.js", + "./packages/config/node_modules/@babel/traverse/lib/path/modification.js", + "./packages/config/node_modules/@babel/traverse/lib/path/removal.js", + "./packages/config/node_modules/@babel/traverse/lib/path/replacement.js", + "./packages/config/node_modules/@babel/traverse/lib/scope/index.js", "./packages/config/src/ast-utils/addToCypressConfig.ts", "./packages/config/src/ast-utils/addToCypressConfigPlugin.ts", "./packages/config/src/browser.ts", @@ -844,7 +843,6 @@ "./packages/server/lib/environment.js", "./packages/server/lib/gui/windows.ts", "./packages/server/lib/log.js", - "./packages/server/lib/makeDataContext.ts", "./packages/server/lib/modes/interactive.ts", "./packages/server/lib/plugins/dev-server.js", "./packages/server/lib/plugins/preprocessor.js", @@ -1028,18 +1026,6 @@ "./node_modules/@babel/template/lib/parse.js", "./node_modules/@babel/template/lib/populate.js", "./node_modules/@babel/template/lib/string.js", - "./node_modules/@babel/traverse/lib/cache.js", - "./node_modules/@babel/traverse/lib/hub.js", - "./node_modules/@babel/traverse/lib/path/evaluation.js", - "./node_modules/@babel/traverse/lib/path/inference/index.js", - "./node_modules/@babel/traverse/lib/path/inference/inferer-reference.js", - "./node_modules/@babel/traverse/lib/path/inference/inferers.js", - "./node_modules/@babel/traverse/lib/path/lib/hoister.js", - "./node_modules/@babel/traverse/lib/path/lib/removal-hooks.js", - "./node_modules/@babel/traverse/lib/path/lib/virtual-types.js", - "./node_modules/@babel/traverse/lib/scope/binding.js", - "./node_modules/@babel/traverse/lib/scope/lib/renamer.js", - "./node_modules/@babel/traverse/lib/visitors.js", "./node_modules/@babel/types/lib/asserts/assertNode.js", "./node_modules/@babel/types/lib/asserts/generated/index.js", "./node_modules/@babel/types/lib/ast-types/generated/index.js", @@ -3508,6 +3494,18 @@ "./node_modules/yn/index.js", "./node_modules/yn/lenient.js", "./package.json", + "./packages/config/node_modules/@babel/traverse/lib/cache.js", + "./packages/config/node_modules/@babel/traverse/lib/hub.js", + "./packages/config/node_modules/@babel/traverse/lib/path/evaluation.js", + "./packages/config/node_modules/@babel/traverse/lib/path/inference/index.js", + "./packages/config/node_modules/@babel/traverse/lib/path/inference/inferer-reference.js", + "./packages/config/node_modules/@babel/traverse/lib/path/inference/inferers.js", + "./packages/config/node_modules/@babel/traverse/lib/path/lib/hoister.js", + "./packages/config/node_modules/@babel/traverse/lib/path/lib/removal-hooks.js", + "./packages/config/node_modules/@babel/traverse/lib/path/lib/virtual-types.js", + "./packages/config/node_modules/@babel/traverse/lib/scope/binding.js", + "./packages/config/node_modules/@babel/traverse/lib/scope/lib/renamer.js", + "./packages/config/node_modules/@babel/traverse/lib/visitors.js", "./packages/config/src/ast-utils/astConfigHelpers.ts", "./packages/config/src/utils.ts", "./packages/data-context/node_modules/@babel/code-frame/lib/index.js", @@ -3709,6 +3707,7 @@ "./packages/server/lib/automation/automation.ts", "./packages/server/lib/automation/index.ts", "./packages/server/lib/automation/screenshot.ts", + "./packages/server/lib/automation/util.ts", "./packages/server/lib/browsers/protocol.ts", "./packages/server/lib/cloud/machine_id.js", "./packages/server/lib/cloud/upload.ts", @@ -3934,5 +3933,5 @@ "./tooling/v8-snapshot/cache/prod-darwin/snapshot-entry.js" ], "deferredHashFile": "yarn.lock", - "deferredHash": "844da7908a41692a3b04716c88e2f0cdad85ece6f94f6ab89fbd1ffe5c332fd2" + "deferredHash": "1ebada20bbce44514cab9420511462a591efa7fbb0c00b64c4f72d31227714ca" } \ No newline at end of file