Skip to content

Commit 253ebd2

Browse files
aduh95panva
authored andcommitted
tools: add cache to lint-js-and-md
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com> PR-URL: #66412 Refs: #64972 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Mike McCready <66998419+MikeMcC399@users.noreply.github.com>
1 parent 52b68e0 commit 253ebd2

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
@@ -93,13 +93,29 @@ jobs:
9393
with:
9494
persist-credentials: false
9595
- name: Use Node.js ${{ env.NODE_VERSION }}
96+
id: setup-node
9697
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
9798
with:
9899
node-version: ${{ env.NODE_VERSION }}
100+
cache: npm
101+
cache-dependency-path: |
102+
tools/doc/package-lock.json
103+
tools/eslint/package-lock.json
104+
tools/lint-md/package-lock.json
105+
- name: Cache ESLint results
106+
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
107+
env:
108+
# ESLint only invalidates its cache on config changes, so the key also
109+
# covers the custom rules and the files they read.
110+
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') }}
111+
with:
112+
path: .eslintcache
113+
key: ${{ env.cache-prefix }}-${{ github.sha }}
114+
restore-keys: ${{ env.cache-prefix }}-
99115
- name: Lint JavaScript files
100116
run: |
101117
set +e
102-
NODE=$(command -v node) make lint-js
118+
NODE=$(command -v node) make lint-js ESLINT_CACHE_FLAGS='--cache --cache-strategy content'
103119
EXIT_CODE="$?"
104120
if [ "$EXIT_CODE" != "0" ]; then
105121
echo
@@ -129,7 +145,7 @@ jobs:
129145
- name: Lint markdown files
130146
run: |
131147
echo "::add-matcher::.github/workflows/remark-lint-problem-matcher.json"
132-
NODE=$(command -v node) make lint-md
148+
NODE=$(command -v node) make lint-md ESLINT_CACHE_FLAGS='--cache --cache-strategy content'
133149
env:
134150
NODE_RELEASED_VERSIONS: ${{ steps.get-released-versions.outputs.NODE_RELEASED_VERSIONS }}
135151

‎Makefile‎

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

15251525

1526-
1526+
ESLINT_CACHE_FLAGS ?= --cache
15271527
LINT_JS_TARGETS = eslint.config.mjs benchmark doc lib test tools
15281528

1529-
run-lint-js = tools/eslint/node_modules/eslint/bin/eslint.js --cache \
1529+
run-lint-js = tools/eslint/node_modules/eslint/bin/eslint.js $(ESLINT_CACHE_FLAGS) \
15301530
--max-warnings=0 --report-unused-disable-directives \
15311531
--concurrency auto $(LINT_JS_TARGETS)
15321532
run-lint-js-fix = $(run-lint-js) --fix

0 commit comments

Comments
 (0)