version: 2 defaults: &defaults 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 test-defaults: &test-defaults jobs: ## code checkout and NPM installs build: <<: *defaults # parallelism: 4 steps: - checkout ## 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 # 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 ## now go build all of subpackages - run: npm run build ## save entire folder as artifact for other jobs to continue - save_cache: key: cypress-monorepo-v1-{{ .Branch }} paths: - /home/person/cypress-monorepo lint: <<: *defaults steps: - restore_cache: key: cypress-monorepo-v1-{{ .Branch }} - run: npm run lint - run: npm run all lint unit-tests: <<: *defaults steps: - restore_cache: key: cypress-monorepo-v1-{{ .Branch }} - 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 - 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 sever-unit-tests: <<: *defaults steps: - restore_cache: key: cypress-monorepo-v1-{{ .Branch }} - run: npm run all test-unit -- --package server sever-integration-tests: <<: *defaults steps: - restore_cache: key: cypress-monorepo-v1-{{ .Branch }} - run: npm run all test-integration -- --package server 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 # - run: # name: Fast unit tests # command: | # if [ $CIRCLE_NODE_INDEX == 0 ]; then # npm run all test -- --package cli # npm run all test -- --package coffee # npm run all test -- --package desktop-gui # npm run all test -- --package electron # npm run all test -- --package extension # npm run all test -- --package https-proxy # npm run all test -- --package launcher # npm run all test -- --package reporter # npm run all test -- --package runner # npm run all test -- --package socket # npm run all test -- --package static # fi # - run: # name: Server unit tests # command: | # if [ $CIRCLE_NODE_INDEX == 0 ]; then # npm run all test-unit -- --package server # fi # - run: # name: Server integration tests # command: | # if [ $CIRCLE_NODE_INDEX == 0 ]; then # whoami # npm run all test-integration -- --package server # fi # # # # things to run in the 2nd CI container # # # - run: # name: Server E2E tests (electron) # command: | # if [ $CIRCLE_NODE_INDEX == 1 ]; then # npm run all test-e2e -- --package server # fi # # # # things to run in the 3rd CI container # # # - run: # name: Docs - running E2E tests # command: | # if [ $CIRCLE_NODE_INDEX == 2 ]; then # cd docs # npm run test-e2e # fi # # # # things to run in the 4th CI container # # # - run: # name: Driver unit tests # command: | # if [ $CIRCLE_NODE_INDEX == 3 ]; then # chrome --version # xvfb-run -as "-screen 0 1280x720x16" npm run all test -- --package driver # fi # # # # 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