Skip to content

Commit

Permalink
chore: install specific Node version on Mac before building binary (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Aug 11, 2020
1 parent 21748fa commit dc523eb
Show file tree
Hide file tree
Showing 6 changed files with 184 additions and 99 deletions.
110 changes: 94 additions & 16 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ macBuildFilters: &macBuildFilters
only:
- develop
- v5.0-release
- install-node-on-circleci-mac

defaults: &defaults
parallelism: 1
Expand Down Expand Up @@ -60,12 +61,37 @@ executors:
# https://circleci.com/docs/2.0/testing-ios/#supported-xcode-versions
mac:
macos:
## Node 12.12.0 (yarn 1.19.1)
# Executor should have Node >= required version
xcode: "11.2.1"
environment:
PLATFORM: mac

commands:
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:
- run:
name: Install NVM
# TODO: determine why we get the missing .nvmrc file error
command: |
export NODE_VERSION=$(cat .node-version)
echo "Installing Node $NODE_VERSION"
cp .node-version .nvmrc
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.35.3/install.sh | bash
- run:
# https://github.com/nvm-sh/nvm#nvmrc
name: Install Node
command: |
. ./scripts/load-nvm.sh
echo "before nvm install"
nvm install
echo "before nvm use"
nvm use
echo "before nvm alias default"
nvm alias default
node --version
install-latest-chrome:
description: Install latest Google Chrome (stable)
parameters:
Expand Down Expand Up @@ -367,6 +393,7 @@ jobs:
<<: *defaults
steps:
- checkout
- install-required-node
- run:
name: Print working folder
command: echo $PWD
Expand All @@ -375,20 +402,36 @@ jobs:
command: echo $(yarn global bin)
- run:
name: print Node version
command: node -v
command: |
. ./scripts/load-nvm.sh
echo "nvm use default"
nvm use default
node -v
- run:
name: print yarn version
command: yarn -v
- run: yarn check-node-version
- run:
name: check Node version
command: |
. ./scripts/load-nvm.sh
yarn check-node-version
## 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
- run: yarn check-terminal
- run:
name: Check terminal
command: |
. ./scripts/load-nvm.sh
yarn check-terminal
- run: yarn stop-only-all
- run:
name: Stop .only
command: |
. ./scripts/load-nvm.sh
yarn stop-only-all
- restore_cache:
name: Restore yarn cache
Expand All @@ -399,7 +442,11 @@ jobs:
- run: ls $(yarn global bin)/../lib/node_modules

# try several times, because flaky NPM installs ...
- run: yarn --frozen-lockfile || yarn --frozen-lockfile
- run:
name: install and build
command: |
. ./scripts/load-nvm.sh
yarn --frozen-lockfile || yarn --frozen-lockfile
- run:
name: Top level packages
command: yarn list --depth=0 || true
Expand All @@ -417,8 +464,13 @@ jobs:
steps:
- attach_workspace:
at: ~/
## this will catch .only's in js/coffee as well
- run: yarn lint
- install-required-node
## this will catch ".only"s in js/coffee as well
- run:
name: Linting 🧹
command: |
. ./scripts/load-nvm.sh
yarn lint
- run:
name: cypress info (dev)
command: node cli/bin/cypress info --dev
Expand Down Expand Up @@ -530,10 +582,18 @@ jobs:
steps:
- attach_workspace:
at: ~/
# make sure mocha runs
- run: yarn test-mocha
- install-required-node
- run:
name: Mocha tests
command: |
. ./scripts/load-nvm.sh
yarn test-mocha
# test binary build code
- run: yarn test-scripts
- run:
name: Test scripts
command: |
. ./scripts/load-nvm.sh
yarn test-scripts
server-unit-tests:
<<: *defaults
Expand Down Expand Up @@ -969,6 +1029,7 @@ jobs:
- attach_workspace:
at: ~/
- run: $(yarn bin)/print-arch
- install-required-node
- run:
environment:
DEBUG: electron-builder,electron-osx-sign*
Expand All @@ -977,8 +1038,15 @@ jobs:
# if this is a forked pull request, the NEXT_DEV_VERSION environment variable
# won't be set and we will use default version, since we are not going to
# upload the dev binary build anywhere
command: yarn binary-build --platform $PLATFORM --version ${NEXT_DEV_VERSION:-0.0.0-development}
- run: yarn binary-zip --platform $PLATFORM
command: |
. ./scripts/load-nvm.sh
node --version
yarn binary-build --platform $PLATFORM --version ${NEXT_DEV_VERSION:-0.0.0-development}
- run:
name: Zip the binary
command: |
. ./scripts/load-nvm.sh
yarn binary-zip --platform $PLATFORM
# Cypress binary file should be zipped to cypress.zip
- run: ls -l *.zip
- store-npm-logs
Expand Down Expand Up @@ -1011,6 +1079,7 @@ jobs:
steps:
- clone-repo-and-checkout-release-branch:
repo: cypress-example-kitchensink
- install-required-node
- run:
name: Install prod dependencies
command: yarn --production
Expand All @@ -1022,7 +1091,9 @@ jobs:
background: true
- run:
name: Run Kitchensink example project
command: yarn cypress:run --project /tmp/cypress-example-kitchensink
command: |
. ./scripts/load-nvm.sh
yarn cypress:run --project /tmp/cypress-example-kitchensink
- store_artifacts:
path: /tmp/cypress-example-kitchensink/cypress/screenshots
- store_artifacts:
Expand Down Expand Up @@ -1072,13 +1143,20 @@ jobs:
steps:
- attach_workspace:
at: ~/
- run: yarn check-next-dev-version
- install-required-node
- run:
name: Check next dev version
command: |
. ./scripts/load-nvm.sh
yarn check-next-dev-version
- run:
name: bump NPM version
command: yarn version --no-git-tag-version --new-version ${NEXT_DEV_VERSION:-0.0.0-development}
- run:
name: build NPM package
command: yarn build --scope cypress
command: |
. ./scripts/load-nvm.sh
yarn build --scope cypress
- run:
command: ls -la types
working_directory: cli/build
Expand Down
3 changes: 2 additions & 1 deletion electron-builder.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"./build/mac/Cypress.app/Contents/Resources/app/packages/server/node_modules/trash/lib/macos-trash",
"./build/mac/Cypress.app/Contents/Resources/app/packages/server/node_modules/babel-plugin-add-module-exports/node_modules/fsevents/build/Release/.node",
"./build/mac/Cypress.app/Contents/Resources/app/packages/server/node_modules/babel-plugin-add-module-exports/node_modules/fsevents/build/Release/fse.node",
"./build/mac/Cypress.app/Contents/Resources/app/packages/server/node_modules/fsevents/fsevents.node"
"./build/mac/Cypress.app/Contents/Resources/app/packages/server/node_modules/fsevents/fsevents.node",
"./build/mac/Cypress.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Helpers/chrome_crashpad_handler"
]
},
"linux": {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@
"debug": "4.1.1",
"decaffeinate": "6.0.9",
"del": "3.0.0",
"electron-builder": "22.6.1",
"electron-notarize": "0.2.1",
"electron-builder": "22.8.0",
"electron-notarize": "1.0.0",
"enzyme-adapter-react-16": "1.12.1",
"eslint": "6.8.0",
"eslint-plugin-cypress": "2.11.1",
Expand Down
13 changes: 0 additions & 13 deletions scripts/check-node-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,10 @@ const assert = require('assert')

// TODO make this check a 3rd party little tool

// on CircleCI Mac machine, we need to use on of the laer executors
// that already has Node 10 / 11
const isMac = () => {
return os.platform() === 'darwin'
}

const isWindows = () => {
return os.platform() === 'win32'
}

if (isMac() && process.env.CIRCLECI) {
// eslint-disable-next-line no-console
console.log('Skipping Node version check on CircleCI Mac')

return
}

// if we're windows + in appveyor...
if (isWindows() && process.env.APPVEYOR) {
// check to ensure that the cpuArch + nodeArch are in sync
Expand Down
11 changes: 11 additions & 0 deletions scripts/load-nvm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# loads previously installed NVM
# USE:
# - run:
# name: check Node version
# command: |
# . ./scripts/load-nvm.sh
# yarn check-node-version

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
export NODE_VERSION=$(cat .node-version)

0 comments on commit dc523eb

Please sign in to comment.