Skip to content

Commit

Permalink
feat: build Cypress for darwin-arm64 (#20686)
Browse files Browse the repository at this point in the history
  • Loading branch information
flotwig authored Jun 15, 2022
1 parent ad7668e commit e18b0d5
Show file tree
Hide file tree
Showing 26 changed files with 527 additions and 375 deletions.
3 changes: 3 additions & 0 deletions __snapshots__/upload-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ exports['test runner manifest'] = {
"darwin-x64": {
"url": "https://cdn.cypress.io/desktop/3.3.0/darwin-x64/cypress.zip"
},
"darwin-arm64": {
"url": "https://cdn.cypress.io/desktop/3.3.0/darwin-arm64/cypress.zip"
},
"linux-x64": {
"url": "https://cdn.cypress.io/desktop/3.3.0/linux-x64/cypress.zip"
},
Expand Down
4 changes: 4 additions & 0 deletions __snapshots__/util-upload-spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
exports['upload util isValidPlatformArch checks given strings second 1'] = {
"name": "second",
"behavior": [
{
"given": "darwin-arm64",
"expect": true
},
{
"given": "darwin-x64",
"expect": true
Expand Down
145 changes: 91 additions & 54 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,37 @@ mainBuildFilters: &mainBuildFilters
branches:
only:
- develop
- fix-unit-tests-release

# 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-workflow-exclude-filters
unless:
or:
- false
# - equal: [ 'tgriesser/chore/fix-windows-build', << pipeline.git.branch >> ]
- 10.0-release
- use-m1-runners

# 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: &mac-workflow-filters
macWorkflowFilters: &darwin-workflow-filters
when:
or:
- equal: [ develop, << pipeline.git.branch >> ]
- equal: [ 'fix-unit-tests-release', << pipeline.git.branch >> ]
- equal: [ use-m1-runners, << 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-workflow-exclude-filters
unless:
or:
- false
# - equal: [ 'tgriesser/chore/fix-windows-build', << pipeline.git.branch >> ]

# windows is slow in CI, so we only run a certain set of tests on each commit
# add your branch to this list to run the full Windows build on your PR
fullWindowsWorkflowFilters: &full-windows-workflow-filters
filters:
branches:
only:
- develop
- 'fix-unit-tests-release'
- 'use-m1-runners'
- '*-release'
- 'win*'

Expand Down Expand Up @@ -88,7 +89,7 @@ executors:
xcode: "13.0.0"
resource_class: macos.x86.medium.gen2
environment:
PLATFORM: mac
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.
Expand All @@ -102,13 +103,18 @@ executors:
environment:
PLATFORM: windows

darwin-arm64:
machine: true
environment:
PLATFORM: darwin

commands:
verify_should_persist_artifacts:
steps:
- run:
name: Check current branch to persist artifacts
command: |
if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "fix-unit-tests-release" ]]; then
if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "use-m1-runners" ]]; then
echo "Not uploading artifacts or posting install comment for this branch."
circleci-agent step halt
fi
Expand Down Expand Up @@ -188,7 +194,7 @@ commands:
command: node scripts/circle-cache.js --action cacheKey > circle_cache_key
- run:
name: Generate platform key
command: echo $PLATFORM > 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{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-node-modules-cache-{{ checksum "circle_cache_key" }}
Expand All @@ -214,7 +220,7 @@ commands:
command: ./system-tests/scripts/cache-key.sh > system_tests_cache_key
- run:
name: Generate platform key
command: echo $PLATFORM > platform_key
command: node ./scripts/get-platform-key.js > platform_key
- restore_cache:
name: Restore system tests node_modules cache
keys:
Expand All @@ -228,7 +234,7 @@ commands:
command: ./system-tests/scripts/cache-key.sh > system_tests_cache_key
- run:
name: Generate platform key
command: echo $PLATFORM > 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:
Expand Down Expand Up @@ -276,7 +282,7 @@ commands:
command: node scripts/circle-cache.js --action cacheKey > circle_cache_key
- run:
name: Generate platform key
command: echo $PLATFORM > 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{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" }}
Expand Down Expand Up @@ -370,28 +376,20 @@ commands:
# 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)
[ -s "${HOME}/.nvm/nvm.sh" ] && \. "${HOME}/.nvm/nvm.sh" # This loads nvm
if ! type nvm > /dev/null; then
echo "Installing NVM"
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.0/install.sh | bash
[ -s "${HOME}/.nvm/nvm.sh" ] && \. "${HOME}/.nvm/nvm.sh" # This loads nvm
fi
echo "Installing Node $node_version"
nvm install ${node_version}
echo "Using Node $node_version"
nvm use ${node_version}
[[ $PLATFORM != 'windows' ]] && nvm alias default ${node_version} || sleep 2s
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: |
[ -s "${HOME}/.nvm/nvm.sh" ] && \. "${HOME}/.nvm/nvm.sh"
source ./scripts/ensure-node.sh
yarn check-node-version
install-chrome:
Expand Down Expand Up @@ -617,7 +615,7 @@ commands:
- run:
name: 'Verify Mocha Results'
command: |
[ -s "${HOME}/.nvm/nvm.sh" ] && \. "${HOME}/.nvm/nvm.sh"
source ./scripts/ensure-node.sh
yarn verify:mocha:results <<parameters.expectedResultCount>>
clone-repo-and-checkout-branch:
Expand Down Expand Up @@ -958,12 +956,12 @@ commands:
no_output_timeout: "45m"
command: |
node --version
yarn binary-build --platform $PLATFORM --version $(node ./scripts/get-next-version.js)
yarn binary-build --version $(node ./scripts/get-next-version.js)
- run:
name: Zip the binary
command: |
[[ $PLATFORM == 'linux' ]] && apt-get update && apt-get install -y zip || [[ $PLATFORM != 'linux' ]]
yarn binary-zip --platform $PLATFORM
yarn binary-zip
- store-npm-logs
- persist_to_workspace:
root: ~/
Expand Down Expand Up @@ -1039,6 +1037,15 @@ commands:
- 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
Expand Down Expand Up @@ -1080,10 +1087,10 @@ jobs:
name: Top level packages
command: yarn list --depth=0 || true
- run:
name: Check env canaries on Mac/Linux
name: Check env canaries on Linux
command: |
# Windows CircleCI does not have a way to pull per-job env
[[ $PLATFORM != 'windows' ]] && node ./scripts/circle-env.js --check-canaries || true
# Windows/Mac M1 CircleCI does not have a way to pull per-job env
[[ $PLATFORM == 'linux' ]] && node ./scripts/circle-env.js --check-canaries || true
- build-and-persist
- store-npm-logs

Expand Down Expand Up @@ -1222,11 +1229,7 @@ jobs:
parallelism: 1
steps:
- restore_cached_workspace
- run:
name: Update known_hosts with github.com keys
command: |
mkdir -p ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts
- update_known_hosts
- run: yarn test-npm-package-release-script

lint-types:
Expand Down Expand Up @@ -1793,6 +1796,11 @@ jobs:

test-kitchensink:
<<: *defaults
parameters:
<<: *defaultsParameters
resource_class:
type: string
default: medium+
steps:
- clone-repo-and-checkout-branch:
repo: cypress-example-kitchensink
Expand Down Expand Up @@ -2537,44 +2545,70 @@ linux-workflow: &linux-workflow
- create-build-artifacts
- system-tests-node-modules-install

mac-workflow: &mac-workflow
darwin-x64-workflow: &darwin-x64-workflow
jobs:
- node_modules_install:
name: darwin-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-build
name: darwin-x64-build
context: test-runner:env-canary
executor: mac
resource_class: macos.x86.medium.gen2
requires:
- darwin-node-modules-install
- darwin-x64-node-modules-install

- lint:
name: darwin-lint
name: darwin-x64-lint
executor: mac
requires:
- darwin-build
- darwin-x64-build

- create-build-artifacts:
name: darwin-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-build
- darwin-x64-build

- test-kitchensink:
name: darwin-test-kitchensink
name: darwin-x64-test-kitchensink
executor: mac
requires:
- darwin-build
- 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

windows-workflow: &windows-workflow
jobs:
Expand Down Expand Up @@ -2644,8 +2678,11 @@ workflows:
linux:
<<: *linux-workflow
<<: *linux-workflow-exclude-filters
mac:
<<: *mac-workflow
<<: *mac-workflow-filters
darwin-x64:
<<: *darwin-x64-workflow
<<: *darwin-workflow-filters
darwin-arm64:
<<: *darwin-arm64-workflow
<<: *darwin-workflow-filters
windows:
<<: *windows-workflow
12 changes: 6 additions & 6 deletions cli/__snapshots__/download_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ Otherwise, please check network connectivity and try again:
----------
URL: https://download.cypress.io/desktop?platform=OS&arch=ARCH
URL: https://download.cypress.io/desktop?platform=OS&arch=x64
404 - Not Found
----------
Platform: darwin-x64 (Foo-OsVersion)
Platform: OS-x64 (Foo-OsVersion)
Cypress Version: 1.2.3
`
Expand All @@ -42,17 +42,17 @@ https://download.cypress.io/desktop/0.20.2?platform=OS&arch=ARCH
`

exports['desktop url from template'] = `
https://download.cypress.io/desktop/0.20.2/darwin-x64/cypress.zip
https://download.cypress.io/desktop/0.20.2/OS-ARCH/cypress.zip
`

exports['desktop url from template with escaped dollar sign'] = `
https://download.cypress.io/desktop/0.20.2/darwin-x64/cypress.zip
https://download.cypress.io/desktop/0.20.2/OS-ARCH/cypress.zip
`

exports['desktop url from template wrapped in quote'] = `
https://download.cypress.io/desktop/0.20.2/darwin-x64/cypress.zip
https://download.cypress.io/desktop/0.20.2/OS-ARCH/cypress.zip
`

exports['desktop url from template with escaped dollar sign wrapped in quote'] = `
https://download.cypress.io/desktop/0.20.2/darwin-x64/cypress.zip
https://download.cypress.io/desktop/0.20.2/OS-ARCH/cypress.zip
`
Loading

4 comments on commit e18b0d5

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on e18b0d5 Jun 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.2.0/linux-x64/develop-e18b0d567e4db04c1a25a7e4f8e533a268c9e663/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on e18b0d5 Jun 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.2.0/darwin-arm64/develop-e18b0d567e4db04c1a25a7e4f8e533a268c9e663/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on e18b0d5 Jun 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.2.0/win32-x64/develop-e18b0d567e4db04c1a25a7e4f8e533a268c9e663/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on e18b0d5 Jun 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.2.0/darwin-x64/develop-e18b0d567e4db04c1a25a7e4f8e533a268c9e663/cypress.tgz

Please sign in to comment.