From a8ed5fa1a8d35cacbb2e9a6b32b8aeba6e33bd21 Mon Sep 17 00:00:00 2001 From: AtofStryker Date: Fri, 24 Jan 2025 09:42:58 -0500 Subject: [PATCH] chore: use the circle browsers image to install needed browsers instead of sourcing them from the internal cypress docker images. --- .circleci/workflows.yml | 156 +++++++++++++++++++++++++++++++--------- 1 file changed, 124 insertions(+), 32 deletions(-) diff --git a/.circleci/workflows.yml b/.circleci/workflows.yml index 5eaf04b31f14..18548a557b98 100644 --- a/.circleci/workflows.yml +++ b/.circleci/workflows.yml @@ -1,5 +1,8 @@ version: 2.1 +orbs: + browser-tools: circleci/browser-tools@1.5.0 + defaults: &defaults parallelism: 1 working_directory: ~/cypress @@ -32,7 +35,7 @@ mainBuildFilters: &mainBuildFilters - 'update-v8-snapshot-cache-on-develop' - 'chore/update_vue_test_utils' - 'publish-binary' - - 'chore/fix_windows_kitchensink' + - 'chore/browser_spike' # 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 @@ -44,7 +47,7 @@ macWorkflowFilters: &darwin-workflow-filters # 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/update_vue_test_utils', << pipeline.git.branch >> ] - - equal: [ 'cacie/fix-hook-test-stack-analysis', << pipeline.git.branch >> ] + - equal: [ 'chore/browser_spike', << pipeline.git.branch >> ] - matches: pattern: /^release\/\d+\.\d+\.\d+$/ value: << pipeline.git.branch >> @@ -56,7 +59,7 @@ linuxArm64WorkflowFilters: &linux-arm64-workflow-filters # 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/update_binary_branch', << pipeline.git.branch >> ] - - equal: [ 'cacie/fix-hook-test-stack-analysis', << pipeline.git.branch >> ] + - equal: [ 'chore/browser_spike', << pipeline.git.branch >> ] - matches: pattern: /^release\/\d+\.\d+\.\d+$/ value: << pipeline.git.branch >> @@ -80,7 +83,7 @@ windowsWorkflowFilters: &windows-workflow-filters # 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: [ 'ryanm/chore/electron-33-upgrade', << pipeline.git.branch >> ] - - equal: [ 'chore/fix_windows_kitchensink', << pipeline.git.branch >> ] + - equal: [ 'chore/browser_spike', << pipeline.git.branch >> ] - matches: pattern: /^release\/\d+\.\d+\.\d+$/ value: << pipeline.git.branch >> @@ -89,7 +92,7 @@ executors: # the Docker image with Cypress dependencies and Chrome browser cy-doc: docker: - - image: cypress/browsers-internal:node20.18.1-bullseye-chrome131-ff133 + - image: cypress/base-internal:20.18.1-bullseye-downstream # by default, we use "medium" to balance performance + CI costs. bump or reduce on a per-job basis if needed. resource_class: medium environment: @@ -98,7 +101,7 @@ executors: kitchensink-executor: docker: - - image: cypress/browsers-internal:node20.18.1-bullseye-chrome131-ff133 + - image: cypress/base-internal:20.18.1-bullseye-downstream # by default, we use "medium" to balance performance + CI costs. bump or reduce on a per-job basis if needed. resource_class: medium environment: @@ -108,7 +111,7 @@ executors: # Docker image with non-root "node" user non-root-docker-user: docker: - - image: cypress/browsers-internal:node20.18.1-bullseye-chrome131-ff133 + - image: cypress/base-internal:20.18.1-bullseye-downstream user: node environment: PLATFORM: linux @@ -156,7 +159,7 @@ commands: name: Set environment variable to determine whether or not to persist artifacts command: | echo "Setting SHOULD_PERSIST_ARTIFACTS variable" - echo 'if ! [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "chore/update_vue_test_utils" && "$CIRCLE_BRANCH" != chore/fix_windows_kitchensink ]]; then + echo 'if ! [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "chore/browser_spike" && "$CIRCLE_BRANCH" != cacie/fix-hook-test-stack-analysis ]]; then export SHOULD_PERSIST_ARTIFACTS=true fi' >> "$BASH_ENV" # You must run `setup_should_persist_artifacts` command and be using bash before running this command @@ -513,27 +516,69 @@ commands: source ./scripts/ensure-node.sh yarn check-node-version - install-chrome: - description: Install Google Chrome + install-browsers: + description: Install Google Chrome or Firefox parameters: - channel: - description: browser channel to install + executor: + description: The executor in use. Only used if Windows for workaround purposes + type: executor + default: cy-doc + install-chrome: + description: whether or not to install google chrome + type: boolean + default: false + google-chrome-channel: + description: Google Chrome channel to install + type: string + # can be stable, beta, dev, or canary + default: stable + google-chrome-version: + description: Google Chrome version to install type: string - version: - description: browser version to install + # latest can also be used here + default: 131.0.6778.108 + install-firefox: + description: whether or not to install firefox + type: boolean + default: false + firefox-version: + description: Firefox version to install type: string + # latest can also be used here + default: 134.0.2 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`" + - when: + condition: + not: + equal: [ *windows-executor, << parameters.executor >> ] + # see https://circleci.com/developer/orbs/orb/circleci/browser-tool + steps: + - when: + condition: + equal: [ true, << parameters.install-firefox >> ] + steps: + - browser-tools/install-firefox: + # https://download-installer.cdn.mozilla.net/pub/firefox/releases/ + version: << parameters.firefox-version >> + - when: + condition: + equal: [ true, << parameters.install-chrome >> ] + steps: + - browser-tools/install-chrome: + # https://www.ubuntuupdates.org/package/google_chrome/stable/main/base/google-chrome-stable + channel: << parameters.google-chrome-channel >> + chrome-version: << parameters.google-chrome-version >> + - when: + condition: + equal: [ 'beta', << parameters.google-chrome-channel>> ] + steps: + - run: + # 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 + command: | + rm /usr/bin/google-chrome # This code builds better-sqlite3 on Debian 10 (Buster). This is necessary because Debian 10 has the oldest glibc version (2.28) that we support. # @@ -576,7 +621,7 @@ commands: install-chrome-channel: description: chrome channel to install type: string - default: '' + default: 'stable' inject-document-domain: description: run subset of tests with injectDocumentDomain config enabled type: boolean @@ -585,11 +630,25 @@ commands: steps: - restore_cached_workspace - when: - condition: <> + condition: + equal: [ chrome, << parameters.browser >> ] + steps: + - install-browsers: + install-chrome: true + - when: + condition: + equal: [ chrome:beta, << parameters.browser >> ] + steps: + - install-browsers: + install-chrome: true + google-chrome-channel: << parameters.install-chrome-channel >> + google-chrome-version: latest + - when: + condition: + equal: [ firefox, << parameters.browser >> ] steps: - - install-chrome: - channel: <> - version: $(node ./scripts/get-browser-version.js chrome:<>) + - install-browsers: + install-firefox: true - when: condition: equal: [ webkit, << parameters.browser >> ] @@ -685,6 +744,10 @@ commands: - run: name: reinstall dependencies to work around cache issue (Windows only) command: rm -rf node_modules && yarn + - install-browsers: + install-chrome: true + install-firefox: true + executor: << parameters.executor >> - windows-install-chrome: browser: <> - run: @@ -758,6 +821,9 @@ commands: equal: [ webkit, << parameters.browser >> ] steps: - install-webkit-deps + - install-browsers: + install-chrome: true + install-firefox: true - run: name: Run system tests environment: @@ -934,6 +1000,8 @@ commands: # 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 + - install-browsers: + install-chrome: true - run: name: Print Cypress version working_directory: /tmp/<> @@ -1026,6 +1094,10 @@ commands: description: Server start command for repo type: string default: "npm start --if-present" + executor: + description: The executor in use. Only used if Windows for workaround purposes + type: executor + default: cy-doc steps: - run: name: Install yarn if not already installed @@ -1119,7 +1191,10 @@ commands: command: | npm i -g wait-on npx wait-on <> --timeout 120000 - + - install-browsers: + install-chrome: true + install-firefox: true + executor: << parameters.executor >> - windows-install-chrome: browser: <> - when: @@ -1666,6 +1741,9 @@ jobs: parallelism: 1 steps: - restore_cached_workspace + - install-browsers: + install-chrome: true + executor: << parameters.executor >> - when: condition: # several snapshots fails for windows due to paths. @@ -1774,6 +1852,8 @@ jobs: parallelism: 1 steps: - restore_cached_workspace + - install-browsers: + install-chrome: true - run: yarn test-integration --scope=@packages/server - verify-mocha-results: expectedResultCount: 1 @@ -1785,6 +1865,9 @@ jobs: <<: *defaults steps: - restore_cached_workspace + - install-browsers: + install-chrome: true + install-firefox: true - run: command: yarn workspace @packages/server test-performance - verify-mocha-results: @@ -1853,7 +1936,9 @@ jobs: parallelism: 1 working_directory: ~/cypress docker: - - image: cypress/browsers-internal:node20.18.1-bullseye-chrome131-ff133 + #here + # - image: cypress/browsers-internal:node20.18.1-bullseye-chrome131-ff133 + - image: cypress/base-internal:20.18.1-bullseye-downstream environment: # needed to inform the bootstrap-docker-container.sh script to link the binary in the system-test project directory REPO_DIR: /root/cypress @@ -2126,6 +2211,8 @@ jobs: steps: - restore_cached_workspace - restore_cached_system_tests_deps + - install-browsers: + install-chrome: true - run: command: | CYPRESS_CONFIG_ENV=production \ @@ -2148,6 +2235,8 @@ jobs: steps: - restore_cached_workspace - restore_cached_system_tests_deps + - install-browsers: + install-chrome: true - run: command: | CYPRESS_CONFIG_ENV=production \ @@ -2258,6 +2347,8 @@ jobs: steps: - restore_cached_workspace - restore_cached_system_tests_deps + - install-browsers: + install-chrome: true - run: command: yarn cypress:run working_directory: npm/puppeteer @@ -2731,6 +2822,7 @@ jobs: - test-binary-against-repo: repo: cypress-example-kitchensink browser: chrome + executor: << parameters.executor >> test-binary-against-todomvc-firefox: <<: *defaults