Skip to content

Commit 02b6e51

Browse files
committed
tools: add cache to lint-js-and-md
Signed-off-by: Antoine du Hamel <[email protected]> PR-URL: #66412 Refs: #64972 Reviewed-By: Filip Skokan <[email protected]> Reviewed-By: Mike McCready <[email protected]>
1 parent fd57ae0 commit 02b6e51

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

‎.github/workflows/linters.yml‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,29 @@ jobs:
9191
with:
9292
persist-credentials: false
9393
- name: Use Node.js ${{ env.NODE_VERSION }}
94+
id: setup-node
9495
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
9596
with:
9697
node-version: ${{ env.NODE_VERSION }}
98+
cache: npm
99+
cache-dependency-path: |
100+
tools/doc/package-lock.json
101+
tools/eslint/package-lock.json
102+
tools/lint-md/package-lock.json
103+
- name: Cache ESLint results
104+
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
105+
env:
106+
# ESLint only invalidates its cache on config changes, so the key also
107+
# covers the custom rules and the files they read.
108+
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') }}
109+
with:
110+
path: .eslintcache
111+
key: ${{ env.cache-prefix }}-${{ github.sha }}
112+
restore-keys: ${{ env.cache-prefix }}-
97113
- name: Lint JavaScript files
98114
run: |
99115
set +e
100-
NODE=$(command -v node) make lint-js
116+
NODE=$(command -v node) make lint-js ESLINT_CACHE_FLAGS='--cache --cache-strategy content'
101117
EXIT_CODE="$?"
102118
if [ "$EXIT_CODE" != "0" ]; then
103119
echo
@@ -127,7 +143,7 @@ jobs:
127143
- name: Lint markdown files
128144
run: |
129145
echo "::add-matcher::.github/workflows/remark-lint-problem-matcher.json"
130-
NODE=$(command -v node) make lint-md
146+
NODE=$(command -v node) make lint-md ESLINT_CACHE_FLAGS='--cache --cache-strategy content'
131147
env:
132148
NODE_RELEASED_VERSIONS: ${{ steps.get-released-versions.outputs.NODE_RELEASED_VERSIONS }}
133149
lint-py:

‎Makefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,10 +1411,10 @@ format-md: tools/lint-md/node_modules/remark-parse/package.json ## Format the ma
14111411
@$(call available-node,$(run-format-md))
14121412

14131413

1414-
1414+
ESLINT_CACHE_FLAGS ?= --cache
14151415
LINT_JS_TARGETS = eslint.config.mjs benchmark doc lib test tools
14161416

1417-
run-lint-js = tools/eslint/node_modules/eslint/bin/eslint.js --cache \
1417+
run-lint-js = tools/eslint/node_modules/eslint/bin/eslint.js $(ESLINT_CACHE_FLAGS) \
14181418
--max-warnings=0 --report-unused-disable-directives \
14191419
--concurrency auto $(LINT_JS_TARGETS)
14201420
run-lint-js-fix = $(run-lint-js) --fix

0 commit comments

Comments
 (0)