version: 2.1 ######################### # Aliases ######################### aliases: - &store_test_results store_test_results: path: ~/repo/test - &persist_to_workspace persist_to_workspace: root: ~/repo paths: ['.'] - &attach_workspace attach_workspace: at: . ######################### # Executors ######################### orbs: win: circleci/windows@2.2.0 executors: node: docker: - image: circleci/node:10-browsers working_directory: ~/repo ######################### # Commands ######################### commands: yarn_install: steps: - run: name: Installing Dependencies command: yarn install --frozen-lockfile --check-files yarn_lint: steps: - run: name: Linting command: yarn lint yarn_react_integration: steps: - run: name: Upgrade to most recent release in React's Next channel command: yarn upgrade react@next react-dom@next -W --dev # upgrade (vs add) will skip re-building Next.js, which doesn't bundle React internals (so this is OK!) yarn_info: steps: - run: name: React Versions command: yarn why react && yarn why react-dom test_all: steps: - run: google-chrome --version - run: chromedriver --version - run: name: Run All Tests command: | node run-tests.js --timings -c 3 $( circleci tests glob "test/**/*.test.*" | \ circleci tests split --split-by=timings ) environment: NEXT_TELEMETRY_DISABLED: '1' test_safari: steps: - run: name: Test Safari command: | yarn testsafari --forceExit test/integration/production/ environment: NEXT_TELEMETRY_DISABLED: '1' BROWSERSTACK: 'true' test_firefox: steps: - run: name: Test Firefox command: | yarn testfirefox --forceExit test/integration/production/ environment: NEXT_TELEMETRY_DISABLED: '1' save_npm_token: steps: - run: name: Potentially save npm token command: | ([[ ! -z $NPM_TOKEN ]] && echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc) || echo "Did not write npm token" publish_canary: steps: - run: name: Potentially publish canary release command: | if \ ls ~/.npmrc >/dev/null 2>&1 && \ [[ $(git describe --exact-match 2> /dev/null || :) =~ -canary ]]; \ then yarn run lerna publish from-git --npm-tag canary --yes else echo "Did not publish" fi publish_stable: steps: - run: name: Potentially publish stable release command: | if \ ls ~/.npmrc >/dev/null 2>&1 && \ [[ ! $(git describe --exact-match 2> /dev/null || :) =~ -canary ]]; \ then yarn run lerna publish from-git --yes else echo "Did not publish" fi ######################### # Jobs ######################### jobs: build: executor: node steps: - checkout - yarn_install - *persist_to_workspace build-react-canary: executor: node steps: - *attach_workspace - yarn_react_integration - *persist_to_workspace lint: executor: node steps: - *attach_workspace - yarn_lint test: parallelism: 6 executor: node steps: - *attach_workspace - yarn_info - test_all - *store_test_results test-safari: executor: node steps: - *attach_workspace - test_safari test-firefox: executor: node steps: - *attach_workspace - test_firefox deploy: executor: node steps: - *attach_workspace - save_npm_token - publish_canary - publish_stable ######################### # Workflows ######################### workflows: version: 2 build-test-and-deploy: jobs: - build - test-firefox: requires: - build - test: requires: - build - test-safari: requires: - build filters: branches: only: - master - canary - lint: requires: - build - deploy: requires: - test filters: branches: only: - master - canary q12h-react-canary: triggers: - schedule: cron: '0 0,12 * * *' filters: branches: only: - canary jobs: - build - build-react-canary: requires: - build - test: requires: - build-react-canary