From d2fd08c03104f2f66c088516145fe239ef04737c Mon Sep 17 00:00:00 2001 From: Steffen Neubauer Date: Tue, 7 Nov 2023 17:40:50 +0100 Subject: [PATCH] chore: disable cache restore when package-lock.json changed (#5358) * chore: disable cache restore when package-lock.json changed * improvement: separate "npm run build" and "npm run clean-build" * improvement: fix typo * fix: syntax error --- .circleci/continue-config.yml | 4 +++- package.json | 3 ++- scripts/check-docs.sh | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.circleci/continue-config.yml b/.circleci/continue-config.yml index 9c97089828..a881d946d1 100644 --- a/.circleci/continue-config.yml +++ b/.circleci/continue-config.yml @@ -105,7 +105,9 @@ commands: keys: # Prefer using the NPM cache for the package-lock hash, but fall back to any other cache too - npm-v4-<>-{{ checksum "package-lock.json" }} - - npm-v4-<> + # If you uncomment the next line, we also restore caches if package-lock.json changed in case there is no exact match. + # We decided not to do that for now for enhanced safety: Every time we update the lock file, we build the caches from scratch. Might be a little paranoid, but hardens against possible NPM bugs. + #- npm-v4-<> - run: npm ci --prefer-offline --cache ~/.npm --no-audit diff --git a/package.json b/package.json index a77678944f..effdbf9dcf 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,8 @@ "scripts": { "add-licenses": "copyright-header --license-file support/license-header.txt --syntax support/license-syntax.yaml --add-path core/src:core/test --output-dir .", "bootstrap": "npm install", - "build": "npm run clean && npm run bootstrap && ./scripts/run-script.ts build", + "build": "./scripts/run-script.ts build", + "clean-build": "npm run clean && npm run bootstrap && ./scripts/run-script.ts build", "check-all": "npm run check-package-lock && npm run lint && npm run check-docs", "check-docs": "./scripts/check-docs.sh", "check-package-licenses": "./scripts/check-package-licenses.ts", diff --git a/scripts/check-docs.sh b/scripts/check-docs.sh index f745034607..a2b6f93578 100755 --- a/scripts/check-docs.sh +++ b/scripts/check-docs.sh @@ -3,7 +3,7 @@ # Needs to generate clean docs before we can validate they are up to date npm run generate-docs -git diff --quiet HEAD -- docs/ || (echo 'generated docs are not up-to-date! run \"npm run build && npm run generate-docs\" and commit the changes\n' && exit 1) +git diff --quiet HEAD -- docs/ || (echo 'generated docs are not up-to-date! run \"npm run clean-build && npm run generate-docs\" and commit the changes.\n' && exit 1) # Use "|| true" so we don't exit on empty modified_docs=$(git diff --name-status main docs README.md) || true