Skip to content

Commit 31efb6f

Browse files
authored
CI: use caching for JavaScript workflows (#3167)
* build: use actions/setup-node@v2 with caching This attempts to use the "cache: yarn" directive, as described in https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-dependencies * build: use cache: yarn in js-lint workflow * fix: checkout before using yarn.lock in js-lint The issue came up when trying to use a yarn.lock, when there was none. /usr/local/bin/yarn cache dir /home/runner/.cache/yarn/v6 Error: Dependencies lock file is not found in /home/runner/work/webpacker/webpacker. Supported file patterns: yarn.lock
1 parent 4f5331a commit 31efb6f

File tree

2 files changed

+5
-27
lines changed

2 files changed

+5
-27
lines changed

.github/workflows/jest.yml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,14 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v2
1717
- name: Use Node.js ${{ matrix.node }}
18-
uses: actions/setup-node@v1
18+
uses: actions/setup-node@v2
1919
with:
2020
node-version: ${{ matrix.node }}
21+
cache: yarn
2122

2223
- name: Install yarn maybe
2324
run: which yarn || npm install -g yarn
2425

25-
- name: Get yarn cache directory path
26-
id: yarn-cache-dir-path
27-
run: echo "::set-output name=dir::$(yarn cache dir)"
28-
29-
- uses: actions/cache@v2
30-
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
31-
with:
32-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
33-
key: ${{ runner.os }}-${{ matrix.node }}-yarn-${{ hashFiles('**/yarn.lock') }}
34-
restore-keys: |
35-
${{ runner.os }}-${{ matrix.node }}-yarn-
36-
3726
- name: Install dependencies
3827
run: yarn --frozen-lockfile
3928

.github/workflows/js-lint.yml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,16 @@ jobs:
1414
runs-on: ${{ matrix.os }}
1515

1616
steps:
17+
- uses: actions/checkout@v2
1718
- name: Use Node.js ${{ matrix.node }}
18-
uses: actions/setup-node@v1
19+
uses: actions/setup-node@v2
1920
with:
2021
node-version: ${{ matrix.node }}
22+
cache: yarn
2123

2224
- name: Install yarn maybe
2325
run: which yarn || npm install -g yarn
2426

25-
- uses: actions/checkout@v2
26-
- name: Get yarn cache directory path
27-
id: yarn-cache-dir-path
28-
run: echo "::set-output name=dir::$(yarn cache dir)"
29-
30-
- uses: actions/cache@v2
31-
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
32-
with:
33-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
34-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
35-
restore-keys: |
36-
${{ runner.os }}-yarn-
37-
3827
- name: Install dependencies
3928
run: yarn --frozen-lockfile
4029

0 commit comments

Comments
 (0)