Skip to content

Commit a3b1987

Browse files
committed
Implement Node.js caching in the GitHub Actions workflows
The `setup-node` action contains built-in support for caching [1], so this commit makes sure we use it for all Node.js-based workflows to reduce workflow execution time. Note that, contrary what one might expect [2], the `node_modules` directory is deliberately not cached because it can conflict with differing Node.js versions and because it's not useful in combination with `npm ci` usage which wipes the `node_modules` folder unconditionally. Therefore, the action instead caches the global `npm` cache directory instead which does not suffer from these problems and still provides a speed-up at installation time. [1] https://github.com/actions/setup-node?tab=readme-ov-file#caching-global-packages-data [2] actions/setup-node#416 [3] actions/cache#67
1 parent 56fe5fb commit a3b1987

9 files changed

Lines changed: 9 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
2525
with:
2626
node-version: ${{ matrix.node-version }}
27+
cache: 'npm'
2728

2829
- name: Install dependencies
2930
run: npm ci

.github/workflows/coverage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
2626
with:
2727
node-version: ${{ matrix.node-version }}
28+
cache: 'npm'
2829

2930
- name: Install dependencies
3031
run: npm ci

.github/workflows/font_tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
4747
with:
4848
node-version: ${{ matrix.node-version }}
49+
cache: 'npm'
4950

5051
- name: Install dependencies
5152
run: npm ci

.github/workflows/lint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
2525
with:
2626
node-version: ${{ matrix.node-version }}
27+
cache: 'npm'
2728

2829
- name: Install dependencies
2930
run: npm ci

.github/workflows/prefs_tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
2525
with:
2626
node-version: ${{ matrix.node-version }}
27+
cache: 'npm'
2728

2829
- name: Install dependencies
2930
run: npm ci

.github/workflows/publish_release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
2727
with:
2828
node-version: ${{ matrix.node-version }}
29+
cache: 'npm'
2930
registry-url: 'https://registry.npmjs.org'
3031

3132
- name: Install dependencies

.github/workflows/publish_website.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
2727
with:
2828
node-version: ${{ matrix.node-version }}
29+
cache: 'npm'
2930

3031
- name: Install dependencies
3132
run: npm ci

.github/workflows/types_tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
2525
with:
2626
node-version: ${{ matrix.node-version }}
27+
cache: 'npm'
2728

2829
- name: Install dependencies
2930
run: npm ci

.github/workflows/update_locales.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
2525
with:
2626
node-version: lts/*
27+
cache: 'npm'
2728

2829
- name: Install dependencies
2930
run: npm ci

0 commit comments

Comments
 (0)