From a35758113cabb86488625bcbb4fc759547a81acb Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Tue, 6 Apr 2021 15:15:57 +0200 Subject: [PATCH] ci: don't save node_modules directory (#41467) Storing node_modules directory in cache causes a number of issues, such as increase in the laid out node_modules tree and also in some cases break module resolution. This is because modules are not hoisted correctly when running `yarn install`. Example of related failures https://app.circleci.com/pipelines/github/angular/angular/30441/workflows/c1a16135-f5c9-478d-a298-d720c6657d52/jobs/952138 A better cache strategy would be to save yarn cache, more information can be found in https://circleci.com/docs/2.0/caching/#yarn-node. PR Close #41467 --- .circleci/config.yml | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1263ed94b9..42415d9770 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,11 +22,11 @@ version: 2.1 # **NOTE 1 **: If you change the cache key prefix, also sync the cache_key_fallback to match. # **NOTE 2 **: Keep the static part of the cache key as prefix to enable correct fallbacks. # See https://circleci.com/docs/2.0/caching/#restoring-cache for how prefixes work in CircleCI. -var_3: &cache_key v1-angular-node-12-{{ checksum ".bazelversion" }}-{{ checksum "yarn.lock" }}-{{ checksum "WORKSPACE" }}-{{ checksum "packages/bazel/package.bzl" }}-{{ checksum "aio/yarn.lock" }} +var_3: &cache_key v4-angular-node-12-{{ checksum ".bazelversion" }}-{{ checksum "yarn.lock" }}-{{ checksum "WORKSPACE" }}-{{ checksum "packages/bazel/package.bzl" }}-{{ checksum "aio/yarn.lock" }} # We invalidate the cache if the Bazel version changes because otherwise the `bazelisk` cache # folder will contain all previously used versions and ultimately cause the cache restoring to # be slower due to its growing size. -var_4: &cache_key_fallback v1-angular-node-12-{{ checksum ".bazelversion" }} +var_4: &cache_key_fallback v4-angular-node-12-{{ checksum ".bazelversion" }} # Cache key for the `components-repo-unit-tests` job. **Note** when updating the SHA in the # cache keys also update the SHA for the "COMPONENTS_REPO_COMMIT" environment variable. @@ -232,10 +232,10 @@ jobs: - *cache_key_fallback - run: name: Running Yarn install - command: yarn install --frozen-lockfile --non-interactive + command: yarn install --frozen-lockfile --non-interactive --cache-folder ~/.cache/yarn # Yarn's requests sometimes take more than 10mins to complete. no_output_timeout: 45m - - run: yarn --cwd aio install --frozen-lockfile --non-interactive + - run: yarn --cwd aio install --frozen-lockfile --non-interactive --cache-folder ~/.cache/yarn # Make the bazel directories and add a file to them if they don't exist already so that # persist_to_workspace does not fail. - run: | @@ -424,7 +424,7 @@ jobs: - custom_attach_workspace - init_environment # Install - - run: yarn --cwd aio install --frozen-lockfile --non-interactive + - run: yarn --cwd aio install --frozen-lockfile --non-interactive --cache-folder ~/.cache/yarn - run: yarn --cwd aio extract-cli-command-docs # Run tools tests - run: yarn --cwd aio tools-test @@ -444,7 +444,7 @@ jobs: - init_environment - install_chrome_libs # Install aio - - run: yarn --cwd aio install --frozen-lockfile --non-interactive + - run: yarn --cwd aio install --frozen-lockfile --non-interactive --cache-folder ~/.cache/yarn # Run examples tests. The "CIRCLE_NODE_INDEX" will be set if "parallelism" is enabled. # Since the parallelism is set to "5", there will be five parallel CircleCI containers. # with either "0", "1", etc as node index. This can be passed to the "--shard" argument. @@ -473,7 +473,7 @@ jobs: - custom_attach_workspace - init_environment - install_chrome_libs - - run: yarn --cwd aio install --frozen-lockfile --non-interactive + - run: yarn --cwd aio install --frozen-lockfile --non-interactive --cache-folder ~/.cache/yarn - run: name: Wait for preview and run tests command: node aio/scripts/test-preview.js $CI_PULL_REQUEST $CI_COMMIT $CI_AIO_MIN_PWA_SCORE @@ -508,10 +508,9 @@ jobs: - save_cache: key: *cache_key paths: - - "node_modules" - - "aio/node_modules" - - "~/bazel_repository_cache" - - "~/.cache/bazelisk" + - ~/.cache/yarn + - ~/bazel_repository_cache + - ~/.cache/bazelisk # Build the ivy npm packages. build-ivy-npm-packages: @@ -716,7 +715,7 @@ jobs: # We temporarily ignore the "engines" because the Angular components repository has # minimum dependency on NodeJS v12 and Yarn 1.19.1, but the framework repository uses # older versions. - command: yarn --ignore-engines --cwd ${COMPONENTS_REPO_TMP_DIR} install --frozen-lockfile --non-interactive + command: yarn --ignore-engines --cwd ${COMPONENTS_REPO_TMP_DIR} install --frozen-lockfile --non-interactive --cache-folder ~/.cache/yarn - save_cache: key: *components_repo_unit_tests_cache_key paths: @@ -743,7 +742,7 @@ jobs: - init_environment - install_java # Install - - run: yarn --cwd packages/zone.js install --frozen-lockfile --non-interactive + - run: yarn --cwd packages/zone.js install --frozen-lockfile --non-interactive --cache-folder ~/.cache/yarn # Run zone.js tools tests - run: yarn --cwd packages/zone.js promisetest - run: yarn --cwd packages/zone.js promisefinallytest @@ -755,7 +754,7 @@ jobs: - run: yarn --cwd packages/zone.js jest:nodetest - run: yarn --cwd packages/zone.js electrontest - run: yarn --cwd packages/zone.js closuretest - - run: yarn --cwd packages/zone.js/test/typings install --frozen-lockfile --non-interactive + - run: yarn --cwd packages/zone.js/test/typings install --frozen-lockfile --non-interactive --cache-folder ~/.cache/yarn - run: yarn --cwd packages/zone.js/test/typings test # Windows jobs