Skip to content

Commit b1b5127

Browse files
ci: cache node modules between runners
1 parent 5f40fed commit b1b5127

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

.github/workflows/build-and-test.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,17 @@ jobs:
2525
node-version: ${{ inputs.node-version }}
2626
cache: 'yarn'
2727

28+
- name: Cache dependencies
29+
uses: actions/cache@v3
30+
id: node-modules-cache
31+
with:
32+
path: '**/node_modules'
33+
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
34+
restore-keys: |
35+
${{ runner.os }}-modules-
36+
2837
- name: Install dependencies
38+
if: steps.node-modules-cache.outputs.cache-hit != 'true'
2939
run: yarn install
3040

3141
- name: Validate PR commits with commitlint
@@ -44,7 +54,17 @@ jobs:
4454
node-version: ${{ inputs.node-version }}
4555
cache: 'yarn'
4656

57+
- name: Cache dependencies
58+
uses: actions/cache@v3
59+
id: node-modules-cache
60+
with:
61+
path: '**/node_modules'
62+
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
63+
restore-keys: |
64+
${{ runner.os }}-modules-
65+
4766
- name: Install dependencies
67+
if: steps.node-modules-cache.outputs.cache-hit != 'true'
4868
run: yarn install
4969

5070
- name: Build
@@ -64,7 +84,17 @@ jobs:
6484
node-version: ${{ inputs.node-version }}
6585
cache: 'yarn'
6686

87+
- name: Cache dependencies
88+
uses: actions/cache@v3
89+
id: node-modules-cache
90+
with:
91+
path: '**/node_modules'
92+
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
93+
restore-keys: |
94+
${{ runner.os }}-modules-
95+
6796
- name: Install dependencies
97+
if: steps.node-modules-cache.outputs.cache-hit != 'true'
6898
run: yarn install
6999

70100
- name: Lint
@@ -83,7 +113,17 @@ jobs:
83113
node-version: ${{ inputs.node-version }}
84114
cache: 'yarn'
85115

116+
- name: Cache dependencies
117+
uses: actions/cache@v3
118+
id: node-modules-cache
119+
with:
120+
path: '**/node_modules'
121+
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
122+
restore-keys: |
123+
${{ runner.os }}-modules-
124+
86125
- name: Install dependencies
126+
if: steps.node-modules-cache.outputs.cache-hit != 'true'
87127
run: yarn install
88128

89129
- name: Generate test SSL certificates

0 commit comments

Comments
 (0)