From fec6912cf93fe602e67f08b4b5c73c3f1bd6b94e Mon Sep 17 00:00:00 2001 From: Bill Glesias Date: Wed, 5 Feb 2025 13:53:04 -0500 Subject: [PATCH] chore: move browser-versions.json values straight into the workflow yaml (#30989) * use env variables in yaml [run ci] * add husky hook to lint-staged to format the circle workflow file on commit when the file changes to keep the diff from the github actions job short * chore: cut over browser-version scripts from json to yaml to update the workflow file inline * Update scripts/format-workflow-file.js Co-authored-by: Matt Schile * move expected yaml keys to const variables --------- Co-authored-by: Matt Schile --- .circleci/workflows.yml | 335 ++++++++++++------ .github/workflows/update-browser-versions.yml | 2 + browser-versions.json | 5 - package.json | 4 +- scripts/format-workflow-file.js | 17 + scripts/get-browser-version.js | 4 - .../github-actions/update-browser-versions.js | 46 ++- .../update-browser-version-spec.js | 21 +- yarn.lock | 10 +- 9 files changed, 280 insertions(+), 164 deletions(-) delete mode 100644 browser-versions.json create mode 100644 scripts/format-workflow-file.js delete mode 100644 scripts/get-browser-version.js diff --git a/.circleci/workflows.yml b/.circleci/workflows.yml index 4632677144..bab7f645bd 100644 --- a/.circleci/workflows.yml +++ b/.circleci/workflows.yml @@ -1,5 +1,9 @@ version: 2.1 +chrome-stable-version: &chrome-stable-version "132.0.6834.159" +chrome-beta-version: &chrome-beta-version "133.0.6943.35" +firefox-stable-version: &firefox-stable-version "134.0.2" + orbs: browser-tools: circleci/browser-tools@1.5.0 @@ -14,8 +18,9 @@ defaults: &defaults type: boolean default: false executor: <> - environment: &defaultsEnvironment + environment: ## set specific timezone + &defaultsEnvironment TZ: "/usr/share/zoneinfo/America/New_York" ## store artifacts here @@ -40,47 +45,47 @@ mainBuildFilters: &mainBuildFilters macWorkflowFilters: &darwin-workflow-filters when: or: - - equal: [ develop, << pipeline.git.branch >> ] - # use the following branch as well to ensure that v8 snapshot cache updates are fully tested - - equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ] - - equal: [ 'chore/browser_spike', << pipeline.git.branch >> ] - - matches: - pattern: /^release\/\d+\.\d+\.\d+$/ - value: << pipeline.git.branch >> + - equal: [ develop, << pipeline.git.branch >> ] + # use the following branch as well to ensure that v8 snapshot cache updates are fully tested + - equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ] + - equal: [ 'chore/browser_spike', << pipeline.git.branch >> ] + - matches: + pattern: /^release\/\d+\.\d+\.\d+$/ + value: << pipeline.git.branch >> linuxArm64WorkflowFilters: &linux-arm64-workflow-filters when: or: - - equal: [ develop, << pipeline.git.branch >> ] - # use the following branch as well to ensure that v8 snapshot cache updates are fully tested - - equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ] - - equal: [ 'chore/browser_spike', << pipeline.git.branch >> ] - - matches: - pattern: /^release\/\d+\.\d+\.\d+$/ - value: << pipeline.git.branch >> + - equal: [ develop, << pipeline.git.branch >> ] + # use the following branch as well to ensure that v8 snapshot cache updates are fully tested + - equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ] + - equal: [ 'chore/browser_spike', << pipeline.git.branch >> ] + - matches: + pattern: /^release\/\d+\.\d+\.\d+$/ + 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: - - matches: - pattern: /^pull\/[0-9]+/ - value: << pipeline.git.branch >> - - false + - matches: + pattern: /^pull\/[0-9]+/ + value: << pipeline.git.branch >> + - 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 >> ] - # use the following branch as well to ensure that v8 snapshot cache updates are fully tested - - equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ] - - equal: [ 'chore/fix_priv_channel_windows', << pipeline.git.branch >> ] - - matches: - pattern: /^release\/\d+\.\d+\.\d+$/ - value: << pipeline.git.branch >> + - equal: [ develop, << pipeline.git.branch >> ] + # use the following branch as well to ensure that v8 snapshot cache updates are fully tested + - equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ] + - equal: [ 'chore/browser_spike', << pipeline.git.branch >> ] + - matches: + pattern: /^release\/\d+\.\d+\.\d+$/ + value: << pipeline.git.branch >> executors: # the Docker image with Cypress dependencies and Chrome browser @@ -92,7 +97,7 @@ executors: environment: PLATFORM: linux CI_DOCKER: "true" - + kitchensink-executor: docker: - image: cypress/base-internal:20.18.1-bullseye @@ -101,7 +106,7 @@ executors: environment: PLATFORM: linux CI_DOCKER: "true" - + # Docker image with non-root "node" user non-root-docker-user: docker: @@ -257,7 +262,8 @@ commands: # 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 + 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' @@ -271,7 +277,8 @@ commands: 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" }} + 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: | @@ -287,7 +294,8 @@ commands: 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/**"' + description: 'Restore the cached node_modules for projects in + "system-tests/projects/**"' steps: - run: name: Generate Circle Cache key for system tests @@ -298,7 +306,9 @@ commands: - 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-{{ + checksum "system_tests_cache_key" }} update_cached_system_tests_deps: description: 'Update the cached node_modules for projects in "system-tests/projects/**"' @@ -312,7 +322,10 @@ commands: - 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" }} + - v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum + "platform_key" + }}-state-of-system-tests-projects-node-modules-cache-{{ checksum + "system_tests_cache_key" }} - run: name: Bail if specific cache exists command: | @@ -323,25 +336,33 @@ commands: - 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- + - 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" }} + 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" }} + 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' + description: 'Installs & caches the dependencies based on yarn lock & package + json dependencies' parameters: only-cache-for-root-user: type: boolean @@ -362,13 +383,17 @@ commands: steps: - 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" }}-better-sqlite3 + key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" + }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" + }}-better-sqlite3 - unless: condition: <> steps: - 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" }} + 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: | @@ -380,7 +405,8 @@ commands: - restore_cache: name: Restore weekly yarn cache keys: - - v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-deps-root-weekly-{{ checksum "cache_date" }} + - v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum + "platform_key" }}-deps-root-weekly-{{ checksum "cache_date" }} - run: name: Install Node Modules command: | @@ -419,7 +445,8 @@ commands: 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" }} + key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" + }}-node-modules-cache-{{ checksum "circle_cache_key" }} paths: - node_modules - cli/node_modules @@ -430,7 +457,8 @@ commands: 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" }} + 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 @@ -439,7 +467,9 @@ commands: steps: - 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" }}-better-sqlite3 + key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" + }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" + }}-better-sqlite3 paths: - node_modules_installed - unless: @@ -447,12 +477,15 @@ commands: steps: - 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" }} + 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" }} + key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" + }}-deps-root-weekly-{{ checksum "cache_date" }} paths: - ~/.yarn - ~/.cy-npm-cache @@ -477,8 +510,7 @@ commands: equal: [ *windows-executor, << parameters.executor >> ] steps: - run: - name: Stop .only - # this will catch ".only"s in js/coffee as well + name: Stop .only # this will catch ".only"s in js/coffee as well command: | source ./scripts/ensure-node.sh yarn stop-only-all @@ -530,7 +562,7 @@ commands: description: Google Chrome version to install type: string # latest can also be used here - default: 132.0.6834.159 + default: *chrome-stable-version install-firefox: description: whether or not to install firefox type: boolean @@ -539,7 +571,7 @@ commands: description: Firefox version to install type: string # latest can also be used here - default: 134.0.2 + default: *firefox-stable-version steps: - when: condition: @@ -560,7 +592,7 @@ commands: steps: - browser-tools/install-chrome: # https://www.ubuntuupdates.org/package/google_chrome/stable/main/base/google-chrome-stable - channel: << parameters.google-chrome-channel >> + channel: << parameters.google-chrome-channel >> chrome-version: << parameters.google-chrome-version >> - when: condition: @@ -570,7 +602,7 @@ commands: # When the beta is downloaded with this orb, # google-chrome-beta is linked in addition to google-chrome, # which we do not expect and errors out when running Cypress - name: remove linked google-chrome binary + name: remove linked google-chrome binary command: | rm /usr/bin/google-chrome @@ -599,7 +631,8 @@ commands: cp ~/cypress/better_sqlite3.node ~/cypress/node_modules/better-sqlite3/build/Release/better_sqlite3.node fi - save_cache: - key: better-sqlite3-{{ checksum "node_modules/better-sqlite3/package.json" }}-{{ checksum "node_modules/electron/package.json" }} + key: better-sqlite3-{{ checksum "node_modules/better-sqlite3/package.json" }}-{{ + checksum "node_modules/electron/package.json" }} paths: - better_sqlite3.node - run: @@ -707,7 +740,7 @@ commands: package: description: package to target type: enum - enum: ['frontend-shared', 'launchpad', 'app', 'reporter'] + enum: [ 'frontend-shared', 'launchpad', 'app', 'reporter' ] browser: description: browser shortname to target type: string @@ -721,7 +754,7 @@ commands: type: description: ct or e2e type: enum - enum: ['ct', 'e2e'] + enum: [ 'ct', 'e2e' ] debug: description: debug option type: string @@ -739,7 +772,7 @@ commands: name: reinstall dependencies to work around cache issue (Windows only) command: rm -rf node_modules && yarn - install-browsers: - install-chrome: true + install-chrome: true install-firefox: true executor: << parameters.executor >> - windows-install-chrome: @@ -890,7 +923,8 @@ commands: 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. + 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 @@ -915,7 +949,8 @@ commands: steps: - restore_cached_binary - run: - name: "Cloning test project and checking out release branch: <>" + 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 . @@ -949,12 +984,14 @@ commands: browser: description: Name of the browser to use, like "electron", "chrome", "firefox" type: enum - enum: ["", "electron", "chrome", "firefox"] + enum: [ "", "electron", "chrome", "firefox" ] default: "" command: description: Test command to run to start Cypress tests type: string - default: "CYPRESS_INTERNAL_ENABLE_TELEMETRY=1 CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY CYPRESS_PROJECT_ID=ypt4pf yarn cypress:run" + default: "CYPRESS_INTERNAL_ENABLE_TELEMETRY=1 + CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY CYPRESS_PROJECT_ID=ypt4pf yarn + cypress:run" # if the repo to clone and test is a monorepo, you can # run tests inside a specific subfolder folder: @@ -1057,7 +1094,7 @@ commands: browser: description: Name of the browser to use, like "electron", "chrome", "firefox" type: enum - enum: ["", "electron", "chrome", "firefox"] + enum: [ "", "electron", "chrome", "firefox" ] default: "" command: description: Test command to run to start Cypress tests @@ -1163,12 +1200,12 @@ commands: - 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: + 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: | @@ -1438,13 +1475,14 @@ commands: - cypress/npm-package-url.json update_known_hosts: - description: Ensures that we have the latest Git public keys to prevent git+ssh from failing. + 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 + - 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, @@ -1607,11 +1645,14 @@ jobs: - 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 + 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 + command: node cli/bin/cypress help | yarn --silent term-to-html > + cli/visual-snapshots/cypress-help.html environment: FORCE_COLOR: 2 - store_artifacts: @@ -1916,7 +1957,8 @@ jobs: yarn set version 1.22.22 yarn install --ignore-scripts - run: - name: install dependencies in yarn-v4.3.1-pnp-dep-resolution with yarn berry 4.3.1 + name: install dependencies in yarn-v4.3.1-pnp-dep-resolution with yarn berry + 4.3.1 command: | yarn set version 4.3.1 cd ./system-tests/projects/yarn-v4.3.1-pnp-dep-resolution && yarn @@ -1991,7 +2033,8 @@ jobs: - run: environment: CYPRESS_COMMERCIAL_RECOMMENDATIONS: '0' - command: yarn workspace @tooling/system-tests test:ci "test/non_root*spec*" --browser electron + command: yarn workspace @tooling/system-tests test:ci "test/non_root*spec*" + --browser electron - verify-mocha-results - store_test_results: path: /tmp/cypress @@ -2099,7 +2142,7 @@ jobs: - run-driver-integration-tests: browser: chrome install-chrome-channel: stable - + driver-integration-tests-chrome-inject-document-domain: <<: *defaults parallelism: 5 @@ -2605,7 +2648,8 @@ jobs: 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 + command: CYPRESS_INSTALL_BINARY=/root/cypress/cypress.zip npm i + /root/cypress/cypress.tgz - run: name: Cypress version working_directory: test-binary @@ -2640,7 +2684,8 @@ jobs: - run: name: Install Cypress working_directory: test-binary - command: CYPRESS_INSTALL_BINARY=/root/cypress/cypress.zip npm install /root/cypress/cypress.tgz + command: CYPRESS_INSTALL_BINARY=/root/cypress/cypress.zip npm install + /root/cypress/cypress.tgz - run: name: Verify Cypress binary working_directory: test-binary @@ -2735,7 +2780,8 @@ jobs: 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 + 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 @@ -2769,7 +2815,8 @@ jobs: - test-binary-against-repo: repo: cypress-example-recipes # Split the specs up across 4 different machines to run in parallel - command: npm run test:ci -- --chunk $CIRCLE_NODE_INDEX --total-chunks $CIRCLE_NODE_TOTAL + command: npm run test:ci -- --chunk $CIRCLE_NODE_INDEX --total-chunks + $CIRCLE_NODE_TOTAL browser: electron # This is a special job. It allows you to test the current @@ -2878,7 +2925,8 @@ jobs: name: Install Cypress working_directory: /tmp/cypress-test-tiny # force installing the freshly built binary - command: CYPRESS_INSTALL_BINARY=~/cypress/cypress.zip npm i ~/cypress/cypress.tgz + command: CYPRESS_INSTALL_BINARY=~/cypress/cypress.zip npm i + ~/cypress/cypress.tgz - run: name: Cypress help working_directory: /tmp/cypress-test-tiny @@ -3027,45 +3075,70 @@ linux-x64-workflow: &linux-x64-workflow requires: - build - run-frontend-shared-component-tests-chrome: - context: [test-runner:cypress-record-key, test-runner:launchpad-tests, test-runner:percy] + 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] + 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] + 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] + 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] + 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] + 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] + 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] + 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] + context: [ test-runner:cypress-record-key, test-runner:percy ] requires: - build - npm-webpack-dev-server: @@ -3398,45 +3471,70 @@ linux-x64-contributor-workflow: &linux-x64-contributor-workflow requires: - build - run-frontend-shared-component-tests-chrome: - context: [test-runner:cypress-record-key, test-runner:launchpad-tests, test-runner:percy] + context: + [ + test-runner:cypress-record-key, + test-runner:launchpad-tests, + test-runner:percy + ] percy: true requires: - contributor-pr - run-launchpad-integration-tests-chrome: - context: [test-runner:cypress-record-key, test-runner:launchpad-tests, test-runner:percy] + context: + [ + test-runner:cypress-record-key, + test-runner:launchpad-tests, + test-runner:percy + ] percy: true requires: - contributor-pr - run-launchpad-component-tests-chrome: - context: [test-runner:cypress-record-key, test-runner:launchpad-tests, test-runner:percy] + context: + [ + test-runner:cypress-record-key, + test-runner:launchpad-tests, + test-runner:percy + ] percy: true requires: - contributor-pr - run-app-integration-tests-chrome: - context: [test-runner:cypress-record-key, test-runner:launchpad-tests, test-runner:percy] + context: + [ + test-runner:cypress-record-key, + test-runner:launchpad-tests, + test-runner:percy + ] percy: true requires: - contributor-pr - run-webpack-dev-server-integration-tests: - context: [test-runner:cypress-record-key, test-runner:percy] + 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] + 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] + context: + [ + test-runner:cypress-record-key, + test-runner:launchpad-tests, + test-runner:percy + ] percy: true requires: - contributor-pr - run-reporter-component-tests-chrome: - context: [test-runner:cypress-record-key, test-runner:percy] + context: [ test-runner:cypress-record-key, test-runner:percy ] percy: true requires: - contributor-pr - reporter-integration-tests: - context: [test-runner:cypress-record-key, test-runner:percy] + context: [ test-runner:cypress-record-key, test-runner:percy ] requires: - contributor-pr - npm-webpack-dev-server: @@ -3533,11 +3631,11 @@ linux-x64-contributor-workflow: &linux-x64-contributor-workflow - ready-to-release - create-and-trigger-packaging-artifacts: - context: [test-runner:upload, test-runner:build-binary, publish-binary] + context: [ test-runner:upload, test-runner:build-binary, publish-binary ] requires: - contributor-pr - get-published-artifacts: - context: [publish-binary, test-runner:commit-status-checks] + context: [ publish-binary, test-runner:commit-status-checks ] requires: - create-and-trigger-packaging-artifacts # various testing scenarios, like building full binary @@ -3644,7 +3742,13 @@ linux-arm64-workflow: &linux-arm64-workflow - create-and-trigger-packaging-artifacts: name: linux-arm64-create-and-trigger-packaging-artifacts - context: [test-runner:upload, test-runner:commit-status-checks, test-runner:build-binary, publish-binary] + context: + [ + test-runner:upload, + test-runner:commit-status-checks, + test-runner:build-binary, + publish-binary + ] executor: linux-arm64 resource_class: arm.medium requires: @@ -3658,7 +3762,7 @@ linux-arm64-workflow: &linux-arm64-workflow - get-published-artifacts: name: linux-arm64-get-published-artifacts - context: [publish-binary, test-runner:commit-status-checks] + context: [ publish-binary, test-runner:commit-status-checks ] executor: linux-arm64 resource_class: arm.medium requires: @@ -3721,7 +3825,7 @@ darwin-x64-workflow: &darwin-x64-workflow resource_class: cypress-io/intel-macstadium requires: - darwin-x64-build - + - server-unit-tests-cloud-environment: name: darwin-x64-driver-server-unit-tests-cloud-environment executor: darwin-amd64 @@ -3795,7 +3899,7 @@ windows-workflow: &windows-workflow name: windows-run-app-integration-tests-chrome executor: windows resource_class: windows.large - context: [test-runner:cypress-record-key, test-runner:launchpad-tests] + context: [ test-runner:cypress-record-key, test-runner:launchpad-tests ] requires: - windows-build @@ -3803,7 +3907,7 @@ windows-workflow: &windows-workflow name: windows-run-launchpad-integration-tests-chrome executor: windows resource_class: windows.large - context: [test-runner:cypress-record-key, test-runner:launchpad-tests] + context: [ test-runner:cypress-record-key, test-runner:launchpad-tests ] requires: - windows-build @@ -3854,8 +3958,7 @@ windows-workflow: &windows-workflow workflows: linux-x64: - <<: *linux-x64-workflow - <<: *linux-x64-workflow-exclude-filters + <<: [ *linux-x64-workflow, *linux-x64-workflow-exclude-filters ] linux-x64-contributor: <<: *linux-x64-contributor-workflow when: @@ -3863,14 +3966,10 @@ workflows: pattern: /^pull\/[0-9]+/ value: << pipeline.git.branch >> linux-arm64: - <<: *linux-arm64-workflow - <<: *linux-arm64-workflow-filters + <<: [ *linux-arm64-workflow, *linux-arm64-workflow-filters ] darwin-x64: - <<: *darwin-x64-workflow - <<: *darwin-workflow-filters + <<: [ *darwin-x64-workflow, *darwin-workflow-filters ] darwin-arm64: - <<: *darwin-arm64-workflow - <<: *darwin-workflow-filters + <<: [ *darwin-arm64-workflow, *darwin-workflow-filters ] windows: - <<: *windows-workflow - <<: *windows-workflow-filters + <<: [ *windows-workflow, *windows-workflow-filters ] diff --git a/.github/workflows/update-browser-versions.yml b/.github/workflows/update-browser-versions.yml index 935ffc247c..076531204f 100644 --- a/.github/workflows/update-browser-versions.yml +++ b/.github/workflows/update-browser-versions.yml @@ -31,6 +31,8 @@ jobs: uses: actions/setup-node@v4 with: node-version: 20 + - name: install dependencies + run: CI=true yarn - name: Check for new Chrome versions id: get-versions uses: actions/github-script@v7 diff --git a/browser-versions.json b/browser-versions.json deleted file mode 100644 index b0aaac5f31..0000000000 --- a/browser-versions.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "chrome:beta": "133.0.6943.35", - "chrome:stable": "132.0.6834.159", - "chrome:minimum": "64.0.3282.0" -} diff --git a/package.json b/package.json index f103df2073..151cc66d20 100644 --- a/package.json +++ b/package.json @@ -209,6 +209,7 @@ "tree-kill": "1.2.2", "ts-node": "^10.9.2", "typescript": "5.3.3", + "yaml": "2.7.0", "yarn-deduplicate": "3.1.0" }, "engines": { @@ -263,7 +264,8 @@ }, "lint-staged": { "*.coffee": "yarn stop-only --folder", - "*.{js,jsx,ts,tsx,json,eslintrc,vue}": "eslint --fix" + "*.{js,jsx,ts,tsx,json,eslintrc,vue}": "eslint --fix", + "*workflows.yml": "node scripts/format-workflow-file.js" }, "resolutions": { "**/@types/cheerio": "0.22.21", diff --git a/scripts/format-workflow-file.js b/scripts/format-workflow-file.js new file mode 100644 index 0000000000..f0c6773e6d --- /dev/null +++ b/scripts/format-workflow-file.js @@ -0,0 +1,17 @@ +const fs = require('fs') +const yaml = require('yaml') + +/** + * from root of directory run: + * node ./scripts/format-workflow-file.js + * + * This script is also executed as a pre-commit hook in husky to ensure the workflow file is always formatted correctly + */ +const formatWorkflowFile = () => { + // file path is relative to repo root + const doc = yaml.parseDocument(fs.readFileSync('./.circleci/workflows.yml', 'utf8')) + + fs.writeFileSync('./.circleci/workflows.yml', yaml.stringify(doc), 'utf8') +} + +formatWorkflowFile() diff --git a/scripts/get-browser-version.js b/scripts/get-browser-version.js deleted file mode 100644 index 08b5c08cc1..0000000000 --- a/scripts/get-browser-version.js +++ /dev/null @@ -1,4 +0,0 @@ -const versions = require('../browser-versions') -const channel = process.argv[2] - -process.stdout.write(versions[channel]) diff --git a/scripts/github-actions/update-browser-versions.js b/scripts/github-actions/update-browser-versions.js index b6813a32b1..660f0bb12d 100644 --- a/scripts/github-actions/update-browser-versions.js +++ b/scripts/github-actions/update-browser-versions.js @@ -1,5 +1,9 @@ const https = require('https') const fs = require('fs') +const yaml = require('yaml') + +const CHROME_STABLE_KEY = 'chrome-stable-version' +const CHROME_BETA_KEY = 'chrome-beta-version' // https://developer.chrome.com/docs/versionhistory/reference/#platform-identifiers const getLatestVersionData = ({ channel, currentVersion }) => { @@ -34,9 +38,13 @@ const getLatestVersionData = ({ channel, currentVersion }) => { const getVersions = async ({ core }) => { try { // file path is relative to repo root - const currentBrowserVersions = JSON.parse(fs.readFileSync('./browser-versions.json')) - const stableData = JSON.parse(await getLatestVersionData({ channel: 'stable', currentVersion: currentBrowserVersions['chrome:stable'] })) - const betaData = JSON.parse(await getLatestVersionData({ channel: 'beta', currentVersion: currentBrowserVersions['chrome:beta'] })) + const doc = yaml.parseDocument(fs.readFileSync('./.circleci/workflows.yml', 'utf8')) + + const currentChromeStable = doc.contents.items.find((item) => item.key.value === CHROME_STABLE_KEY).value.value + const currentChromeBeta = doc.contents.items.find((item) => item.key.value === CHROME_BETA_KEY).value.value + + const stableData = JSON.parse(await getLatestVersionData({ channel: 'stable', currentVersion: currentChromeStable })) + const betaData = JSON.parse(await getLatestVersionData({ channel: 'beta', currentVersion: currentChromeBeta })) const hasStableUpdate = stableData.versions.length > 0 const hasBetaUpdate = betaData.versions.length > 0 let description = 'Update ' @@ -54,10 +62,10 @@ const getVersions = async ({ core }) => { } core.setOutput('has_update', (hasStableUpdate || hasBetaUpdate) ? 'true' : 'false') - core.setOutput('current_stable_version', currentBrowserVersions['chrome:stable']) - core.setOutput('latest_stable_version', hasStableUpdate ? stableData.versions[0].version : currentBrowserVersions['chrome:stable']) - core.setOutput('current_beta_version', currentBrowserVersions['chrome:beta']) - core.setOutput('latest_beta_version', hasBetaUpdate ? betaData.versions[0].version : currentBrowserVersions['chrome:beta']) + core.setOutput('current_stable_version', currentChromeStable) + core.setOutput('latest_stable_version', hasStableUpdate ? stableData.versions[0].version : currentChromeStable) + core.setOutput('current_beta_version', currentChromeBeta) + core.setOutput('latest_beta_version', hasBetaUpdate ? betaData.versions[0].version : currentChromeBeta) core.setOutput('description', description) } catch (err) { console.log('Errored checking for new Chrome versions:', err.stack) @@ -67,22 +75,28 @@ const getVersions = async ({ core }) => { const checkNeedForBranchUpdate = ({ core, latestStableVersion, latestBetaVersion }) => { // file path is relative to repo root - const branchBrowserVersions = JSON.parse(fs.readFileSync('./browser-versions.json')) - const hasNewerStableVersion = branchBrowserVersions['chrome:stable'] !== latestStableVersion - const hasNewerBetaVersion = branchBrowserVersions['chrome:beta'] !== latestBetaVersion + const doc = yaml.parseDocument(fs.readFileSync('./.circleci/workflows.yml', 'utf8')) + + const currentChromeStable = doc.contents.items.find((item) => item.key.value === CHROME_STABLE_KEY).value.value + const currentChromeBeta = doc.contents.items.find((item) => item.key.value === CHROME_BETA_KEY).value.value + + const hasNewerStableVersion = currentChromeStable !== latestStableVersion + const hasNewerBetaVersion = currentChromeBeta !== latestBetaVersion core.setOutput('has_newer_update', (hasNewerStableVersion || hasNewerBetaVersion) ? 'true' : 'false') } const updateBrowserVersionsFile = ({ latestBetaVersion, latestStableVersion }) => { - const currentBrowserVersions = JSON.parse(fs.readFileSync('./browser-versions.json')) - const newVersions = Object.assign(currentBrowserVersions, { - 'chrome:beta': latestBetaVersion, - 'chrome:stable': latestStableVersion, - }) + const doc = yaml.parseDocument(fs.readFileSync('./.circleci/workflows.yml', 'utf8')) + + const currentChromeStableYamlRef = doc.contents.items.find((item) => item.key.value === CHROME_STABLE_KEY) + const currentChromeBetaYamlRef = doc.contents.items.find((item) => item.key.value === CHROME_BETA_KEY) + + currentChromeStableYamlRef.value.value = latestStableVersion + currentChromeBetaYamlRef.value.value = latestBetaVersion // file path is relative to repo root - fs.writeFileSync('./browser-versions.json', `${JSON.stringify(newVersions, null, 2) }\n`) + fs.writeFileSync('./.circleci/workflows.yml', yaml.stringify(doc), 'utf8') } const updatePRTitle = async ({ context, github, baseBranch, branchName, description }) => { diff --git a/scripts/unit/github-actions/update-browser-version-spec.js b/scripts/unit/github-actions/update-browser-version-spec.js index 40892cb283..8a9e7daaea 100644 --- a/scripts/unit/github-actions/update-browser-version-spec.js +++ b/scripts/unit/github-actions/update-browser-version-spec.js @@ -29,10 +29,7 @@ const stubChromeVersionResult = (channel, result) => { const stubRepoVersions = ({ betaVersion, stableVersion }) => { mockfs({ - './browser-versions.json': JSON.stringify({ - 'chrome:beta': betaVersion, - 'chrome:stable': stableVersion, - }), + './.circleci/workflows.yml': `chrome-stable-version: &chrome-stable-version "${stableVersion}"\nchrome-beta-version: &chrome-beta-version "${betaVersion}"\n`, }) } @@ -245,11 +242,10 @@ describe('update browser version github action', () => { context('.updateBrowserVersionsFile', () => { it('updates browser-versions.json with specified versions, leaving other entries in place', () => { - sinon.stub(fs, 'readFileSync').returns(`{ - "chrome:beta": "1.1", - "chrome:stable": "1.0", - "chrome:other": "0.4" - }`) + stubRepoVersions({ + betaVersion: '1.1', + stableVersion: '1.0', + }) sinon.stub(fs, 'writeFileSync') @@ -258,12 +254,7 @@ describe('update browser version github action', () => { latestStableVersion: '2.0', }) - expect(fs.writeFileSync).to.be.calledWith('./browser-versions.json', `{ - "chrome:beta": "2.1", - "chrome:stable": "2.0", - "chrome:other": "0.4" -} -`) + expect(fs.writeFileSync).to.be.calledWith('./.circleci/workflows.yml', `chrome-stable-version: &chrome-stable-version "2.0"\nchrome-beta-version: &chrome-beta-version "2.1"\n`, 'utf8') }) }) diff --git a/yarn.lock b/yarn.lock index 869ab82c6f..f0075a9ae2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -33104,16 +33104,16 @@ yaml-eslint-parser@^1.2.2: lodash "^4.17.21" yaml "^2.0.0" +yaml@2.7.0, yaml@^2.0.0, yaml@^2.3.4, yaml@^2.4.1, yaml@^2.6.0: + version "2.7.0" + resolved "https://registry.npmjs.org/yaml/-/yaml-2.7.0.tgz#aef9bb617a64c937a9a748803786ad8d3ffe1e98" + integrity sha512-+hSoy/QHluxmC9kCIJyL/uyFmLmc+e5CFR5Wa+bpIhIj85LVb9ZH2nVnqrHoSvKogwODv0ClqZkmiSSaIH5LTA== + yaml@^1.10.0: version "1.10.2" resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b" integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg== -yaml@^2.0.0, yaml@^2.3.4, yaml@^2.4.1, yaml@^2.6.0: - version "2.7.0" - resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.7.0.tgz#aef9bb617a64c937a9a748803786ad8d3ffe1e98" - integrity sha512-+hSoy/QHluxmC9kCIJyL/uyFmLmc+e5CFR5Wa+bpIhIj85LVb9ZH2nVnqrHoSvKogwODv0ClqZkmiSSaIH5LTA== - yargs-parser@13.1.1: version "13.1.1" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.1.tgz#d26058532aa06d365fe091f6a1fc06b2f7e5eca0"