diff --git a/.circleci/config.yml b/.circleci/config.yml index 8c504c13300b5d..18a1a4492887b4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,14 +1,14 @@ aliases: - - &restore-node-cache + - &restore-yarn-cache keys: - - v2-dependencies-{{ arch }}-{{ checksum "package.json" }} + - v1-yarn-{{ arch }}-{{ checksum "package.json" }} # Fallback in case checksum fails - - v2-dependencies-{{ arch }}- - - - &save-node-cache + - v1-yarn-{{ arch }}- + - &save-yarn-cache paths: - node_modules - key: v2-dependencies-{{ arch }}-{{ checksum "package.json" }} + - ~/.cache/yarn + key: v1-yarn-{{ arch }}-{{ checksum "package.json" }} - &restore-cache-analysis keys: @@ -60,6 +60,16 @@ aliases: - ~/watchman key: v1-watchman-{{ arch }}-v4.9.0 + - &yarn + | + yarn install --non-interactive --cache-folder ~/.cache/yarn + + - &install-yarn + | + curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - + echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list + sudo apt-get update && sudo apt-get install yarn + - &install-node-dependencies | npm install --no-package-lock --no-spin --no-progress @@ -77,18 +87,18 @@ aliases: curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - sudo apt-get install -y nodejs - - &run-node-tests - | - npm test -- --maxWorkers=2 - + - &run-js-tests + | + yarn test --maxWorkers=2 + - &run-lint-checks - | - npm run lint + | + yarn lint - &run-flow-checks - | - npm run flow -- check - + | + yarn flow check + - &filter-only-master-stable branches: only: @@ -203,9 +213,9 @@ jobs: - image: circleci/node:8 steps: - checkout - - restore-cache: *restore-node-cache - - run: *install-node-dependencies - - save-cache: *save-node-cache + - restore-cache: *restore-yarn-cache + - run: *yarn + - save-cache: *save-yarn-cache - run: *run-lint-checks - run: *run-flow-checks @@ -216,10 +226,10 @@ jobs: - image: circleci/node:8 steps: - checkout - - restore-cache: *restore-node-cache - - run: *install-node-dependencies - - save-cache: *save-node-cache - - run: *run-node-tests + - restore-cache: *restore-yarn-cache + - run: *yarn + - save-cache: *save-yarn-cache + - run: *run-js-tests # Runs JavaScript tests on Node 6 test-js-node-6: @@ -228,10 +238,10 @@ jobs: - image: circleci/node:6 steps: - checkout - - restore-cache: *restore-node-cache - - run: *install-node-dependencies - - save-cache: *save-node-cache - - run: *run-node-tests + - restore-cache: *restore-yarn-cache + - run: *yarn + - save-cache: *save-yarn-cache + - run: *run-js-tests # Runs unit tests on iOS devices test-objc-ios: @@ -243,9 +253,9 @@ jobs: - xcrun instruments -w "iPhone 5s (10.3.1)" || true steps: - checkout - - restore-cache: *restore-node-cache - - run: *install-node-dependencies - - save-cache: *save-node-cache + - restore-cache: *restore-yarn-cache + - run: *yarn + - save-cache: *save-yarn-cache - run: ./scripts/objc-test-ios.sh # Runs unit tests on tvOS devices @@ -258,9 +268,9 @@ jobs: - xcrun instruments -w "Apple TV 1080p (10.0)" || true steps: - checkout - - restore-cache: *restore-node-cache - - run: *install-node-dependencies - - save-cache: *save-node-cache + - restore-cache: *restore-yarn-cache + - run: *yarn + - save-cache: *save-yarn-cache - run: ./scripts/objc-test-tvos.sh # Runs end to end tests @@ -273,9 +283,9 @@ jobs: - xcrun instruments -w "iPhone 5s (10.3.1)" || true steps: - checkout - - restore-cache: *restore-node-cache - - run: *install-node-dependencies - - save-cache: *save-node-cache + - restore-cache: *restore-yarn-cache + - run: *yarn + - save-cache: *save-yarn-cache - run: node ./scripts/run-ci-e2e-tests.js --ios --js --retries 3; # Checks podspec @@ -285,9 +295,9 @@ jobs: xcode: "9.0" steps: - checkout - - restore-cache: *restore-node-cache - - run: *install-node-dependencies - - save-cache: *save-node-cache + - restore-cache: *restore-yarn-cache + - run: *yarn + - save-cache: *save-yarn-cache - run: ./scripts/process-podspecs.sh # Publishes new version onto npm @@ -310,9 +320,10 @@ jobs: - run: *install-buck - save-cache: *save-cache-buck - run: *install-node - - restore-cache: *restore-node-cache - - run: *install-node-dependencies - - save-cache: *save-node-cache + - run: *install-yarn + - restore-cache: *restore-yarn-cache + - run: *yarn + - save-cache: *save-yarn-cache - run: buck fetch ReactAndroid/src/test/java/com/facebook/react/modules - run: buck fetch ReactAndroid/src/main/java/com/facebook/react - run: buck fetch ReactAndroid/src/main/java/com/facebook/react/shell @@ -372,9 +383,10 @@ jobs: # The JavaScript Bundle is required for instrumentation tests. - run: *install-node - - restore-cache: *restore-node-cache - - run: *install-node-dependencies - - save-cache: *save-node-cache + - run: *install-yarn + - restore-cache: *restore-yarn-cache + - run: *yarn + - save-cache: *save-yarn-cache - run: *build-js-bundle # Wait for AVD to finish booting before running tests @@ -398,14 +410,14 @@ jobs: steps: - checkout - restore-cache: *restore-cache-analysis - - run: *install-node-dependencies + - run: *yarn - run: - name: Install Dependencies + name: Install Additional Dependencies command: | if [ -n "$CIRCLE_PULL_REQUEST" ]; then - npm install github@0.2.4 + yarn add github@0.2.4 cd danger - npm install --no-package-lock --no-spin --no-progress + yarn install --non-interactive --cache-folder ~/.cache/yarn else echo "Skipping dependency installation." fi @@ -414,7 +426,7 @@ jobs: name: Analyze Pull Request command: | if [ -n "$CIRCLE_PULL_REQUEST" ]; then - cd danger && DANGER_GITHUB_API_TOKEN="e622517d9f1136ea8900""07c6373666312cdfaa69" npm run danger + cd danger && DANGER_GITHUB_API_TOKEN="e622517d9f1136ea8900""07c6373666312cdfaa69" yarn danger else echo "Skipping pull request analysis." fi @@ -422,8 +434,8 @@ jobs: - run: name: Analyze Code command: | - if [ -n "$CIRCLE_PULL_REQUEST" ]; then - cat <(echo eslint; npm run lint --silent -- --format=json; echo flow; npm run flow --silent -- check --json) | GITHUB_TOKEN="af6ef0d15709bc91d""06a6217a5a826a226fb57b7" CI_USER=$CIRCLE_PROJECT_USERNAME CI_REPO=$CIRCLE_PROJECT_REPONAME PULL_REQUEST_NUMBER=$CIRCLE_PR_NUMBER node bots/code-analysis-bot.js + if [ -n "$CIRCLE_PR_NUMBER" ]; then + cat <(echo eslint; yarn --silent lint --format=json; echo flow; yarn --silent flow check --json) | GITHUB_TOKEN="af6ef0d15709bc91d""06a6217a5a826a226fb57b7" CI_USER=$CIRCLE_PROJECT_USERNAME CI_REPO=$CIRCLE_PROJECT_REPONAME PULL_REQUEST_NUMBER=$CIRCLE_PR_NUMBER node bots/code-analysis-bot.js else echo "Skipping code analysis." fi