mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-29 03:09:53 -05:00
463 lines
15 KiB
YAML
463 lines
15 KiB
YAML
version: 2
|
|
|
|
defaults: &defaults
|
|
parallelism: 1
|
|
working_directory: ~/cypress-monorepo
|
|
docker:
|
|
# the Docker image with Cypress dependencies and Chrome browser
|
|
- image: cypress/internal:chrome58
|
|
environment:
|
|
## this enables colors + fixes failing unit tests
|
|
TERM: xterm
|
|
|
|
npm_config_loglevel: warn
|
|
# even when running as non-root user
|
|
# need to set unsafe perm to be able to do `npm postinstall`
|
|
npm_config_unsafe-perm: true
|
|
|
|
jobs:
|
|
## code checkout and NPM installs
|
|
build:
|
|
<<: *defaults
|
|
steps:
|
|
- checkout
|
|
|
|
# print global NPM cache path
|
|
- run: echo $(npm -g bin)
|
|
|
|
## make sure the TERM is set to 'xterm' in node
|
|
## 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:
|
|
name: Checking TERM is set
|
|
command: |
|
|
echo 'term env var is:' $TERM
|
|
node -e 'assert.equal(process.env.TERM, "xterm", "need TERM to be set for Docker to work")'
|
|
node -e 'console.log("TERM %s stdout.isTTY?", process.env.TERM, process.stdout.isTTY)'
|
|
|
|
# need to restore a separate cache for each package.json
|
|
- restore_cache:
|
|
key: v5-{{ .Branch }}-cli-deps
|
|
- restore_cache:
|
|
key: v5-{{ .Branch }}-root-deps
|
|
- restore_cache:
|
|
key: v5-{{ .Branch }}-deps-coffee
|
|
- restore_cache:
|
|
key: v5-{{ .Branch }}-deps-desktop-gui
|
|
- restore_cache:
|
|
key: v5-{{ .Branch }}-deps-driver
|
|
- restore_cache:
|
|
key: v5-{{ .Branch }}-deps-example
|
|
- restore_cache:
|
|
key: v7-{{ .Branch }}-deps-electron
|
|
- restore_cache:
|
|
key: v5-{{ .Branch }}-deps-extension
|
|
- restore_cache:
|
|
key: v5-{{ .Branch }}-deps-https-proxy
|
|
- restore_cache:
|
|
key: v5-{{ .Branch }}-deps-launcher
|
|
- restore_cache:
|
|
key: v5-{{ .Branch }}-deps-reporter
|
|
- restore_cache:
|
|
key: v5-{{ .Branch }}-deps-runner
|
|
- restore_cache:
|
|
key: v5-{{ .Branch }}-deps-server
|
|
- restore_cache:
|
|
key: v5-{{ .Branch }}-deps-socket
|
|
- restore_cache:
|
|
key: v5-{{ .Branch }}-deps-static
|
|
- restore_cache:
|
|
key: v5-{{ .Branch }}-deps-ts
|
|
- restore_cache:
|
|
key: v5-{{ .Branch }}-deps-docs
|
|
|
|
# show what is already cached globally
|
|
- run: ls $(npm -g bin)
|
|
- run: ls $(npm -g bin)/../lib/node_modules
|
|
|
|
# only installs the root dependencies, without going into packages
|
|
# via postinstall script
|
|
- run: npm install --ignore-scripts
|
|
|
|
## symlink all of our sub packages in node_modules
|
|
- run: npm run link
|
|
|
|
## now install all of the sub packages node_modules
|
|
- run: npm run all install -- --serial
|
|
|
|
# save each node_modules folder per package
|
|
- save_cache:
|
|
key: v5-{{ .Branch }}-cli-deps-{{ checksum "cli/package.json" }}
|
|
paths:
|
|
- cli/node_modules
|
|
- save_cache:
|
|
key: v5-{{ .Branch }}-root-deps-{{ checksum "package.json" }}
|
|
paths:
|
|
- node_modules
|
|
- save_cache:
|
|
key: v5-{{ .Branch }}-deps-coffee-{{ checksum "packages/coffee/package.json" }}
|
|
paths:
|
|
- packages/coffee/node_modules
|
|
- save_cache:
|
|
key: v5-{{ .Branch }}-deps-desktop-gui-{{ checksum "packages/desktop-gui/package.json" }}
|
|
paths:
|
|
- packages/desktop-gui/node_modules
|
|
- save_cache:
|
|
key: v5-{{ .Branch }}-deps-driver-{{ checksum "packages/driver/package.json" }}
|
|
paths:
|
|
- packages/driver/node_modules
|
|
- save_cache:
|
|
key: v5-{{ .Branch }}-deps-example-{{ checksum "packages/example/package.json" }}
|
|
paths:
|
|
- packages/example/node_modules
|
|
- save_cache:
|
|
key: v7-{{ .Branch }}-deps-electron-{{ checksum "packages/electron/package.json" }}
|
|
paths:
|
|
- packages/electron/node_modules
|
|
- ~/.cache/electron
|
|
- ~/.electron
|
|
- save_cache:
|
|
key: v5-{{ .Branch }}-deps-extension-{{ checksum "packages/extension/package.json" }}
|
|
paths:
|
|
- packages/extension/node_modules
|
|
- save_cache:
|
|
key: v5-{{ .Branch }}-deps-https-proxy-{{ checksum "packages/https-proxy/package.json" }}
|
|
paths:
|
|
- packages/https-proxy/node_modules
|
|
- save_cache:
|
|
key: v5-{{ .Branch }}-deps-launcher-{{ checksum "packages/launcher/package.json" }}
|
|
paths:
|
|
- packages/launcher/node_modules
|
|
- save_cache:
|
|
key: v5-{{ .Branch }}-deps-reporter-{{ checksum "packages/reporter/package.json" }}
|
|
paths:
|
|
- packages/reporter/node_modules
|
|
- save_cache:
|
|
key: v5-{{ .Branch }}-deps-runner-{{ checksum "packages/runner/package.json" }}
|
|
paths:
|
|
- packages/runner/node_modules
|
|
- save_cache:
|
|
key: v5-{{ .Branch }}-deps-server-{{ checksum "packages/server/package.json" }}
|
|
paths:
|
|
- packages/server/node_modules
|
|
- save_cache:
|
|
key: v5-{{ .Branch }}-deps-socket-{{ checksum "packages/socket/package.json" }}
|
|
paths:
|
|
- packages/socket/node_modules
|
|
- save_cache:
|
|
key: v5-{{ .Branch }}-deps-static-{{ checksum "packages/static/package.json" }}
|
|
paths:
|
|
- packages/static/node_modules
|
|
- save_cache:
|
|
key: v5-{{ .Branch }}-deps-ts-{{ checksum "packages/ts/package.json" }}
|
|
paths:
|
|
- packages/ts/node_modules
|
|
- save_cache:
|
|
key: v5-{{ .Branch }}-deps-docs-{{ checksum "docs/package.json" }}
|
|
paths:
|
|
- docs/node_modules
|
|
|
|
- run: npm run stop-only
|
|
## now go build all of subpackages
|
|
- run: npm run build
|
|
|
|
## save entire folder as artifact for other jobs to continue
|
|
## hmm, do not see a good way to cache it, since all code
|
|
## might change
|
|
- save_cache:
|
|
key: cypress-monorepo-{{ .Branch }}-{{ .Revision }}
|
|
paths:
|
|
- /home/person/cypress-monorepo
|
|
|
|
lint:
|
|
<<: *defaults
|
|
steps:
|
|
- restore_cache:
|
|
key: cypress-monorepo-{{ .Branch }}-{{ .Revision }}
|
|
- run: npm run lint
|
|
- run: npm run all lint
|
|
|
|
"unit-tests":
|
|
<<: *defaults
|
|
parallelism: 2
|
|
steps:
|
|
- restore_cache:
|
|
key: cypress-monorepo-{{ .Branch }}-{{ .Revision }}
|
|
- run: npm run all test -- --package cli
|
|
- run: npm run all test -- --package coffee
|
|
- run: npm run all test -- --package desktop-gui
|
|
- run: npm run all test -- --package electron
|
|
- run: npm run all test -- --package extension
|
|
- run: npm run all test -- --package https-proxy
|
|
- run: npm run all test -- --package launcher
|
|
# how to pass Mocha reporter through zunder?
|
|
- run: npm run all test -- --package reporter
|
|
- run: npm run all test -- --package runner
|
|
- run: npm run all test -- --package socket
|
|
- run: npm run all test -- --package static
|
|
- store_test_results:
|
|
path: /tmp/cypress-monorepo
|
|
|
|
"server-unit-tests":
|
|
<<: *defaults
|
|
parallelism: 2
|
|
steps:
|
|
- restore_cache:
|
|
key: cypress-monorepo-{{ .Branch }}-{{ .Revision }}
|
|
- run: npm run all test-unit -- --package server
|
|
- store_test_results:
|
|
path: /tmp/cypress-monorepo
|
|
|
|
"server-integration-tests":
|
|
<<: *defaults
|
|
parallelism: 2
|
|
steps:
|
|
- restore_cache:
|
|
key: cypress-monorepo-{{ .Branch }}-{{ .Revision }}
|
|
- run: npm run all test-integration -- --package server
|
|
- store_test_results:
|
|
path: /tmp/cypress-monorepo
|
|
|
|
"server-e2e-tests-1":
|
|
<<: *defaults
|
|
steps:
|
|
- restore_cache:
|
|
key: cypress-monorepo-{{ .Branch }}-{{ .Revision }}
|
|
- run: cd packages/server && npm run test-e2e -- --parallel 4 --index 0
|
|
- store_test_results:
|
|
path: /tmp/cypress-monorepo
|
|
|
|
"server-e2e-tests-2":
|
|
<<: *defaults
|
|
steps:
|
|
- restore_cache:
|
|
key: cypress-monorepo-{{ .Branch }}-{{ .Revision }}
|
|
- run: cd packages/server && npm run test-e2e -- --parallel 4 --index 1
|
|
- store_test_results:
|
|
path: /tmp/cypress-monorepo
|
|
|
|
"server-e2e-tests-3":
|
|
<<: *defaults
|
|
steps:
|
|
- restore_cache:
|
|
key: cypress-monorepo-{{ .Branch }}-{{ .Revision }}
|
|
- run: cd packages/server && npm run test-e2e -- --parallel 4 --index 2
|
|
- store_test_results:
|
|
path: /tmp/cypress-monorepo
|
|
|
|
"server-e2e-tests-4":
|
|
<<: *defaults
|
|
steps:
|
|
- restore_cache:
|
|
key: cypress-monorepo-{{ .Branch }}-{{ .Revision }}
|
|
- run: cd packages/server && npm run test-e2e -- --parallel 4 --index 3
|
|
- store_test_results:
|
|
path: /tmp/cypress-monorepo
|
|
|
|
#
|
|
# Documentation jobs
|
|
#
|
|
"docs-tests":
|
|
<<: *defaults
|
|
steps:
|
|
- restore_cache:
|
|
key: cypress-monorepo-{{ .Branch }}-{{ .Revision }}
|
|
- run: cd docs && npm run deps
|
|
- run: cd docs && npm run lint
|
|
- run: cd docs && npm run test
|
|
# the docs should already have been built
|
|
# but we at least will generate the build info
|
|
- run: cd docs && npm run save-build-json
|
|
- run: cd docs && ls public
|
|
- run: cd docs && cat public/build.json
|
|
# - run: cd docs && npm run build
|
|
# start docs server and run e2e tests
|
|
- run:
|
|
name: Start docs server
|
|
command: cd docs && npm run start
|
|
background: true
|
|
- run: sleep 20
|
|
- restore_cache:
|
|
key: cypress-tool-{{ .Branch }}
|
|
- run: cd docs && npm run cypress
|
|
# cache cypress-cli and Cypress itself
|
|
# see where our global cache is by version
|
|
- run: echo $(npm -g bin)
|
|
- save_cache:
|
|
key: cypress-tool-{{ .Branch }}
|
|
paths:
|
|
- /usr/local/bin/cypress
|
|
- /usr/local/lib/node_modules/cypress-cli
|
|
- /home/person/.cypress
|
|
|
|
"deploy-docs-staging":
|
|
<<: *defaults
|
|
steps:
|
|
- restore_cache:
|
|
key: cypress-monorepo-{{ .Branch }}-{{ .Revision }}
|
|
- run: cd docs && NODE_ENV=staging npm run build
|
|
- run: cd docs && ls public
|
|
- run: cd docs && npm run save-build-json
|
|
- run: cd docs && npm run deploy-prebuilt -- --environment staging
|
|
- run:
|
|
name: Print deployed version
|
|
command: cd docs && cat public/build.json
|
|
- run:
|
|
name: Test deployed docs
|
|
command: cd docs && CYPRESS_baseUrl=https://docs-staging.cypress.io npm run cypress
|
|
|
|
"deploy-docs-production":
|
|
<<: *defaults
|
|
steps:
|
|
- restore_cache:
|
|
key: cypress-monorepo-{{ .Branch }}-{{ .Revision }}
|
|
- run: cd docs && NODE_ENV=production npm run build
|
|
# because we already built docs for production
|
|
# use script that just deploys without rebuilding the production docs
|
|
- run: cd docs && npm run save-build-json
|
|
- run: cd docs && npm run deploy-prebuilt -- --environment production --scrape
|
|
- run: cd docs && cat public/build.json
|
|
|
|
## TODO: commenting out for now until these run
|
|
# "driver-unit-tests":
|
|
# <<: *defaults
|
|
# parallelism: 2
|
|
# steps:
|
|
# - restore_cache:
|
|
# key: cypress-monorepo-{{ .Branch }}-{{ .Revision }}
|
|
# - run: chrome --version
|
|
# - run: npm run all test-unit -- --package driver
|
|
|
|
"driver-integration-tests-1":
|
|
<<: *defaults
|
|
steps:
|
|
- restore_cache:
|
|
key: cypress-monorepo-{{ .Branch }}-{{ .Revision }}
|
|
- run:
|
|
command: cd packages/driver && npm start
|
|
background: true
|
|
- run: cd packages/driver && xvfb-run -as "-screen 0 1280x720x16" npm run test-integration -- --parallel 4 --index 0
|
|
|
|
"driver-integration-tests-2":
|
|
<<: *defaults
|
|
steps:
|
|
- restore_cache:
|
|
key: cypress-monorepo-{{ .Branch }}-{{ .Revision }}
|
|
- run:
|
|
command: cd packages/driver && npm start
|
|
background: true
|
|
- run: cd packages/driver && xvfb-run -as "-screen 0 1280x720x16" npm run test-integration -- --parallel 4 --index 1
|
|
|
|
"driver-integration-tests-3":
|
|
<<: *defaults
|
|
steps:
|
|
- restore_cache:
|
|
key: cypress-monorepo-{{ .Branch }}-{{ .Revision }}
|
|
- run:
|
|
command: cd packages/driver && npm start
|
|
background: true
|
|
- run: cd packages/driver && xvfb-run -as "-screen 0 1280x720x16" npm run test-integration -- --parallel 4 --index 2
|
|
|
|
"driver-integration-tests-4":
|
|
<<: *defaults
|
|
steps:
|
|
- restore_cache:
|
|
key: cypress-monorepo-{{ .Branch }}-{{ .Revision }}
|
|
- run:
|
|
command: cd packages/driver && npm start
|
|
background: true
|
|
- run: cd packages/driver && xvfb-run -as "-screen 0 1280x720x16" npm run test-integration -- --parallel 4 --index 3
|
|
|
|
"build-binary":
|
|
<<: *defaults
|
|
steps:
|
|
- restore_cache:
|
|
key: cypress-monorepo-{{ .Branch }}-{{ .Revision }}
|
|
- run: echo "Building version 0.0.0-$CIRCLE_BRANCH-${CIRCLE_SHA1:0:7}"
|
|
- run: npm run binary-build -- --platform linux --version "0.0.0-$CIRCLE_BRANCH-${CIRCLE_SHA1:0:7}"
|
|
- run: ls -la build/linux/Cypress
|
|
|
|
workflows:
|
|
version: 2
|
|
build_and_test:
|
|
jobs:
|
|
- build
|
|
- lint:
|
|
requires:
|
|
- build
|
|
- unit-tests:
|
|
requires:
|
|
- build
|
|
- server-unit-tests:
|
|
requires:
|
|
- build
|
|
- server-integration-tests:
|
|
requires:
|
|
- build
|
|
- server-e2e-tests-1:
|
|
requires:
|
|
- build
|
|
- server-e2e-tests-2:
|
|
requires:
|
|
- build
|
|
- server-e2e-tests-3:
|
|
requires:
|
|
- build
|
|
- server-e2e-tests-4:
|
|
requires:
|
|
- build
|
|
## TODO: temporarily commenting out
|
|
# - driver-unit-tests:
|
|
# requires:
|
|
# - build
|
|
- driver-integration-tests-1:
|
|
requires:
|
|
- build
|
|
- driver-integration-tests-2:
|
|
requires:
|
|
- build
|
|
- driver-integration-tests-3:
|
|
requires:
|
|
- build
|
|
- driver-integration-tests-4:
|
|
requires:
|
|
- build
|
|
- build-binary:
|
|
requires:
|
|
- build
|
|
# test and deploy documentation site
|
|
- docs-tests:
|
|
requires:
|
|
- build
|
|
|
|
- deploy-docs-staging:
|
|
filters:
|
|
branches:
|
|
only:
|
|
# allow deploying to staging from "develop"
|
|
# and branches starting with special prefix
|
|
- develop
|
|
- /docs-.*/
|
|
requires:
|
|
- docs-tests
|
|
|
|
- deploy-docs-production:
|
|
filters:
|
|
branches:
|
|
only: master
|
|
requires:
|
|
- docs-tests
|
|
|
|
#
|
|
# things to run in the 4th CI container
|
|
#
|
|
# - run:
|
|
# name: Example e2e tests
|
|
# command: |
|
|
# if [ $CIRCLE_NODE_INDEX == 3 ]; then
|
|
# # ./bin/cypress --project=./packages/example --path-to-cypress
|
|
# # xvfb-run -as "-screen 0 1280x720x16" npm start -- --project=./packages/example
|
|
# fi
|