Commit 253ebd24295 for nodejs
commit 253ebd2429590aa0717e6ccdd2a3409f481cf034
Author: Antoine du Hamel <duhamelantoine1995@gmail.com>
Date: Wed Sep 30 14:33:59 2026 +0200
tools: add cache to `lint-js-and-md`
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66412
Refs: https://github.com/nodejs/node/issues/64972
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Mike McCready <66998419+MikeMcC399@users.noreply.github.com>
diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml
index 848fffc117a..ae8eeef2a66 100644
--- a/.github/workflows/linters.yml
+++ b/.github/workflows/linters.yml
@@ -93,13 +93,29 @@ jobs:
with:
persist-credentials: false
- name: Use Node.js ${{ env.NODE_VERSION }}
+ id: setup-node
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ env.NODE_VERSION }}
+ cache: npm
+ cache-dependency-path: |
+ tools/doc/package-lock.json
+ tools/eslint/package-lock.json
+ tools/lint-md/package-lock.json
+ - name: Cache ESLint results
+ uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ env:
+ # ESLint only invalidates its cache on config changes, so the key also
+ # covers the custom rules and the files they read.
+ cache-prefix: eslint-${{ runner.os }}-${{ steps.setup-node.outputs.node-version }}-${{ hashFiles('eslint.config.mjs', '*/eslint.config_partial.mjs', 'tools/eslint/*', 'tools/eslint-rules/**', 'doc/api/errors.md', 'doc/api/deprecations.md') }}
+ with:
+ path: .eslintcache
+ key: ${{ env.cache-prefix }}-${{ github.sha }}
+ restore-keys: ${{ env.cache-prefix }}-
- name: Lint JavaScript files
run: |
set +e
- NODE=$(command -v node) make lint-js
+ NODE=$(command -v node) make lint-js ESLINT_CACHE_FLAGS='--cache --cache-strategy content'
EXIT_CODE="$?"
if [ "$EXIT_CODE" != "0" ]; then
echo
@@ -129,7 +145,7 @@ jobs:
- name: Lint markdown files
run: |
echo "::add-matcher::.github/workflows/remark-lint-problem-matcher.json"
- NODE=$(command -v node) make lint-md
+ NODE=$(command -v node) make lint-md ESLINT_CACHE_FLAGS='--cache --cache-strategy content'
env:
NODE_RELEASED_VERSIONS: ${{ steps.get-released-versions.outputs.NODE_RELEASED_VERSIONS }}
diff --git a/Makefile b/Makefile
index 0582e926d1f..31d7d911c98 100644
--- a/Makefile
+++ b/Makefile
@@ -1523,10 +1523,10 @@ format-md: tools/lint-md/node_modules/remark-parse/package.json ## Format the ma
@$(call available-node,$(run-format-md))
-
+ESLINT_CACHE_FLAGS ?= --cache
LINT_JS_TARGETS = eslint.config.mjs benchmark doc lib test tools
-run-lint-js = tools/eslint/node_modules/eslint/bin/eslint.js --cache \
+run-lint-js = tools/eslint/node_modules/eslint/bin/eslint.js $(ESLINT_CACHE_FLAGS) \
--max-warnings=0 --report-unused-disable-directives \
--concurrency auto $(LINT_JS_TARGETS)
run-lint-js-fix = $(run-lint-js) --fix