diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000000000..f92025f395b96 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,141 @@ +version: 2 + +defaults: &defaults + working_directory: ~/project/react + docker: + - image: starefossen/ruby-node:2-8 + +restore_node_modules: &restore_node_modules + restore_cache: + name: Restore node_modules cache + keys: + - v1-node-{{ .Branch }}-{{ checksum "yarn.lock" }} + - v1-node-{{ .Branch }}- + - v1-node- + +jobs: + install: + <<: *defaults + steps: + - checkout + - *restore_node_modules + - run: + name: Install Dependencies + command: yarn install + - save_cache: + name: Save yarn cache + key: v1-yarn-{{ .Branch }}-{{ checksum "yarn.lock" }} + paths: + - .cache/yarn + - save_cache: + name: Save node_modules cache + key: v1-node-{{ .Branch }}-{{ checksum "yarn.lock" }} + paths: + - node_modules/ + - run: + name: Remove node_modules to cleanup workspace + command: rm -r node_modules/ + - persist_to_workspace: + root: ~/project + paths: + - react + # For balancing + eslint_prettier_flow_check-licence-and-modules_test-print-warnings_track-stats: + <<: *defaults + steps: + - attach_workspace: + at: ~/project + - *restore_node_modules + - run: + name: eslint + command: node ./scripts/tasks/eslint + - run: + name: prettier + command: node ./scripts/prettier/index + - run: + name: flow + command: node ./scripts/tasks/flow + - run: + name: check_license + command: ./scripts/circleci/check_license.sh + - run: + name: check_modules + command: ./scripts/circleci/check_modules.sh + - run: + name: test_print_warnings + command: ./scripts/circleci/test_print_warnings.sh + - run: + name: track_stats + command: | + # skip fingerprints + mkdir -p ~/.ssh + echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config + ./scripts/circleci/track_stats.sh + + coverage: + <<: *defaults + steps: + - attach_workspace: + at: ~/project + - *restore_node_modules + - run: + name: coverage + command: ./scripts/circleci/test_coverage.sh + + jest: + <<: *defaults + steps: + - attach_workspace: + at: ~/project + - *restore_node_modules + - run: + name: jest + command: node ./scripts/tasks/jest + + build: + <<: *defaults + steps: + - attach_workspace: + at: ~/project + - *restore_node_modules + - run: + name: build + command: ./scripts/circleci/build.sh + - persist_to_workspace: + root: ~/project/react + paths: + - build + + deploy: + <<: *defaults + steps: + - attach_workspace: + at: ~/project + - *restore_node_modules + - run: + name: deploy + command: ./scripts/circleci/upload_build.sh + +workflows: + version: 2 + install-test-build-and-deploy: + jobs: + - install + - coverage: + requires: + - install + - jest: + requires: + - install + - eslint_prettier_flow_check-licence-and-modules_test-print-warnings_track-stats: + requires: + - install + - build: + requires: + - install + - deploy: + requires: + - jest + - cooverage + - eslint_prettier_flow_check-licence-and-modules_test-print-warnings_track-stats + - build diff --git a/circle.yml b/circle.yml deleted file mode 100644 index df3750ca8e2df..0000000000000 --- a/circle.yml +++ /dev/null @@ -1,40 +0,0 @@ ---- -machine: - timezone: America/Los_Angeles - node: - version: 8 - ruby: - version: 2.2.3 - environment: - TRAVIS_REPO_SLUG: facebook/react - YARN_VERSION: 1.2.1 - PATH: "${PATH}:${HOME}/.yarn/bin" - -dependencies: - pre: - # This is equivalent to $TRAVIS_COMMIT_RANGE - - echo $CIRCLE_COMPARE_URL | cut -d/ -f7 - # install yarn if it's not already installed - - | - if [[ ! -e ~/.yarn/bin/yarn || $(yarn --version) != "${YARN_VERSION}" ]]; then - curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version $YARN_VERSION - fi - override: - - yarn install - - scripts/circleci/set_up_github_keys.sh - post: - # - npm ls --depth=0 - cache_directories: - - ~/.yarn - - ~/.yarn-cache - -test: - override: - - ./scripts/circleci/test_entry_point.sh: - parallel: true - -deployment: - staging: - branch: /.*/ - commands: - - ./scripts/circleci/upload_build.sh diff --git a/scripts/circleci/test_entry_point.sh b/scripts/circleci/test_entry_point.sh deleted file mode 100755 index 96d3a4eed6ed8..0000000000000 --- a/scripts/circleci/test_entry_point.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash - -set -e - -COMMANDS_TO_RUN=() - -if [ $((1 % CIRCLE_NODE_TOTAL)) -eq "$CIRCLE_NODE_INDEX" ]; then - COMMANDS_TO_RUN+=('./scripts/circleci/test_coverage.sh') -fi - -if [ $((3 % CIRCLE_NODE_TOTAL)) -eq "$CIRCLE_NODE_INDEX" ]; then - COMMANDS_TO_RUN+=('node ./scripts/tasks/eslint') -fi - -# These seem out of order but extract-errors must be run after jest. -if [ $((0 % CIRCLE_NODE_TOTAL)) -eq "$CIRCLE_NODE_INDEX" ]; then - COMMANDS_TO_RUN+=('node ./scripts/prettier/index') - COMMANDS_TO_RUN+=('node ./scripts/tasks/flow') - COMMANDS_TO_RUN+=('node ./scripts/tasks/jest') - COMMANDS_TO_RUN+=('./scripts/circleci/build.sh') - COMMANDS_TO_RUN+=('./scripts/circleci/check_license.sh') - COMMANDS_TO_RUN+=('./scripts/circleci/check_modules.sh') - COMMANDS_TO_RUN+=('./scripts/circleci/test_print_warnings.sh') - COMMANDS_TO_RUN+=('./scripts/circleci/track_stats.sh') - # COMMANDS_TO_RUN+=('./scripts/circleci/bench.sh') -fi - -RETURN_CODES=() -FAILURE=0 - -printf "Node #%s (%s total). " "$CIRCLE_NODE_INDEX" "$CIRCLE_NODE_TOTAL" -if [ -n "${COMMANDS_TO_RUN[0]}" ]; then - echo "Preparing to run commands:" - for cmd in "${COMMANDS_TO_RUN[@]}"; do - echo "- $cmd" - done - - for cmd in "${COMMANDS_TO_RUN[@]}"; do - echo - echo "$ $cmd" - set +e - $cmd - rc=$? - set -e - RETURN_CODES+=($rc) - if [ $rc -ne 0 ]; then - FAILURE=$rc - fi - done - - echo - for i in "${!COMMANDS_TO_RUN[@]}"; do - echo "Received return code ${RETURN_CODES[i]} from: ${COMMANDS_TO_RUN[i]}" - done - exit $FAILURE -else - echo "No commands to run." -fi