Skip to content

Commit

Permalink
Speed up yarn cache in circle (facebook#19566)
Browse files Browse the repository at this point in the history
  • Loading branch information
rickhanlonii authored Aug 11, 2020
1 parent ce37bfa commit c8d9b88
Showing 1 changed file with 52 additions and 71 deletions.
123 changes: 52 additions & 71 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,11 @@ aliases:
- &environment
TZ: /usr/share/zoneinfo/America/Los_Angeles

- &restore_yarn_cache
- &restore_node_modules
restore_cache:
name: Restore node_modules cache
keys:
- v2-node-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}
- v2-node-{{ arch }}-{{ .Branch }}-
- v2-node-{{ arch }}-
- &run_yarn
run:
name: Install Packages
command: yarn --frozen-lockfile
- v2-node-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}-node-modules

- &TEST_PARALLELISM 20

Expand All @@ -30,8 +24,7 @@ aliases:
steps:
- checkout
- attach_workspace: *attach_workspace
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run: node ./scripts/rollup/consolidateBundleSizes.js
- run: ./scripts/circleci/pack_and_store_artifact.sh
- store_artifacts:
Expand Down Expand Up @@ -59,22 +52,37 @@ jobs:
- run:
name: Nodejs Version
command: node --version
- *restore_yarn_cache
- *run_yarn
- restore_cache:
name: Restore yarn cache
key: v2-node-{{ arch }}-{{ checksum "yarn.lock" }}-yarn
- run:
name: Install Packages
command: yarn --frozen-lockfile --cache-folder ~/.cache/yarn
- save_cache:
name: Save node_modules cache
key: v2-node-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}
# Store the yarn cache globally for all lock files with this same
# checksum. This will speed up the setup job for all PRs where the
# lockfile is the same.
name: Save yarn cache for future installs
key: v2-node-{{ arch }}-{{ checksum "yarn.lock" }}-yarn
paths:
- ~/.cache/yarn
- save_cache:
# Store node_modules for all jobs in this workflow so that they don't
# need to each run a yarn install for each job. This will speed up
# all jobs run on this branch with the same lockfile.
name: Save node_modules cache
# This cache key is per branch, a yarn install in setup is required.
key: v2-node-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}-node-modules
paths:
- node_modules

yarn_lint:
docker: *docker
environment: *environment

steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run: node ./scripts/prettier/index
- run: node ./scripts/tasks/eslint
- run: ./scripts/circleci/check_license.sh
Expand All @@ -87,8 +95,7 @@ jobs:

steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run: node ./scripts/tasks/flow-ci

RELEASE_CHANNEL_stable_yarn_test:
Expand All @@ -98,8 +105,7 @@ jobs:

steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run: yarn test --release-channel=stable --ci

yarn_test:
Expand All @@ -108,8 +114,7 @@ jobs:
parallelism: *TEST_PARALLELISM
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run: yarn test --ci

RELEASE_CHANNEL_stable_yarn_test_www:
Expand All @@ -118,8 +123,7 @@ jobs:
parallelism: *TEST_PARALLELISM
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run: yarn test --release-channel=www-classic --ci

RELEASE_CHANNEL_stable_yarn_test_www_variant:
Expand All @@ -128,8 +132,7 @@ jobs:
parallelism: *TEST_PARALLELISM
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run: yarn test --release-channel=www-classic --variant --ci

RELEASE_CHANNEL_stable_yarn_test_prod_www:
Expand All @@ -138,8 +141,7 @@ jobs:
parallelism: *TEST_PARALLELISM
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run: yarn test --release-channel=www-classic --prod --ci

RELEASE_CHANNEL_stable_yarn_test_prod_www_variant:
Expand All @@ -148,8 +150,7 @@ jobs:
parallelism: *TEST_PARALLELISM
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run: yarn test --release-channel=www-classic --prod --variant --ci

yarn_test_www:
Expand All @@ -158,8 +159,7 @@ jobs:
parallelism: *TEST_PARALLELISM
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run: yarn test --release-channel=www-modern --ci

yarn_test_www_variant:
Expand All @@ -168,8 +168,7 @@ jobs:
parallelism: *TEST_PARALLELISM
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run: yarn test --release-channel=www-modern --variant --ci

yarn_test_prod_www:
Expand All @@ -178,8 +177,7 @@ jobs:
parallelism: *TEST_PARALLELISM
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run: yarn test --release-channel=www-modern --prod --ci

yarn_test_prod_www_variant:
Expand All @@ -188,8 +186,7 @@ jobs:
parallelism: *TEST_PARALLELISM
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run: yarn test --release-channel=www-modern --prod --variant --ci

RELEASE_CHANNEL_stable_yarn_test_persistent:
Expand All @@ -199,8 +196,7 @@ jobs:

steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run: yarn test --release-channel=stable --persistent --ci

RELEASE_CHANNEL_stable_yarn_test_prod:
Expand All @@ -210,8 +206,7 @@ jobs:

steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run: yarn test --release-channel=stable --prod --ci

yarn_test_prod:
Expand All @@ -220,8 +215,7 @@ jobs:
parallelism: *TEST_PARALLELISM
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run: yarn test --release-channel=experimental --prod --ci

RELEASE_CHANNEL_stable_yarn_build:
Expand All @@ -230,8 +224,7 @@ jobs:
parallelism: *TEST_PARALLELISM
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run:
environment:
RELEASE_CHANNEL: stable
Expand All @@ -257,8 +250,7 @@ jobs:
parallelism: 20
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run:
environment:
RELEASE_CHANNEL: experimental
Expand All @@ -285,8 +277,7 @@ jobs:
steps:
- checkout
- attach_workspace: *attach_workspace
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run:
environment:
RELEASE_CHANNEL: experimental
Expand All @@ -305,8 +296,7 @@ jobs:
steps:
- checkout
- attach_workspace: *attach_workspace
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
# This runs in the process_artifacts job, too, but it's faster to run
# this step in both jobs instead of running the jobs sequentially
- run: node ./scripts/rollup/consolidateBundleSizes.js
Expand All @@ -321,8 +311,7 @@ jobs:
steps:
- checkout
- attach_workspace: *attach_workspace
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
# This runs in the process_artifacts job, too, but it's faster to run
# this step in both jobs instead of running the jobs sequentially
- run: node ./scripts/rollup/consolidateBundleSizes.js
Expand All @@ -337,8 +326,7 @@ jobs:
steps:
- checkout
- attach_workspace: *attach_workspace
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run: yarn lint-build
- run: scripts/circleci/check_minified_errors.sh

Expand All @@ -348,8 +336,7 @@ jobs:
steps:
- checkout
- attach_workspace: *attach_workspace
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run:
environment:
RELEASE_CHANNEL: stable
Expand All @@ -363,8 +350,7 @@ jobs:
steps:
- checkout
- attach_workspace: *attach_workspace
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run: yarn test --release-channel=stable --build --ci

yarn_test_build:
Expand All @@ -374,8 +360,7 @@ jobs:
steps:
- checkout
- attach_workspace: *attach_workspace
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run: yarn test --release-channel=experimental --build --ci

yarn_test_build_devtools:
Expand All @@ -384,8 +369,7 @@ jobs:
steps:
- checkout
- attach_workspace: *attach_workspace
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run: yarn test --project=devtools --build --ci

RELEASE_CHANNEL_stable_yarn_test_dom_fixtures:
Expand All @@ -394,7 +378,7 @@ jobs:
steps:
- checkout
- attach_workspace: *attach_workspace
- *restore_yarn_cache
- *restore_node_modules
- run:
name: Run DOM fixture tests
environment:
Expand All @@ -410,8 +394,7 @@ jobs:
environment: *environment
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run:
name: Run fuzz tests
command: |
Expand All @@ -425,8 +408,7 @@ jobs:
steps:
- checkout
- attach_workspace: *attach_workspace
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run: yarn test --release-channel=stable --build --prod --ci

yarn_test_build_prod:
Expand All @@ -436,8 +418,7 @@ jobs:
steps:
- checkout
- attach_workspace: *attach_workspace
- *restore_yarn_cache
- *run_yarn
- *restore_node_modules
- run: yarn test --release-channel=experimental --build --prod --ci

workflows:
Expand Down

0 comments on commit c8d9b88

Please sign in to comment.