Skip to content

Commit 0127315

Browse files
committed
Add Dependency Caching to Github Actions
1 parent 1c42261 commit 0127315

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

.github/workflows/build.yml

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ jobs:
2323
uses: actions/setup-node@v2
2424
with:
2525
node-version: ${{ env.NODE_VERSION }}
26+
- name: Get yarn cache directory path
27+
id: yarn-cache-dir-path
28+
run: echo "::set-output name=dir::$(yarn cache dir)"
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 }}-yarn-${{ hashFiles('**/yarn.lock') }}
34+
restore-keys: |
35+
${{ runner.os }}-yarn-
2636
- name: Install Dependencies
2737
run: yarn --immutable
2838
- name: Lint Code
@@ -37,6 +47,16 @@ jobs:
3747
uses: actions/setup-node@v2
3848
with:
3949
node-version: ${{ env.NODE_VERSION }}
50+
- name: Get yarn cache directory path
51+
id: yarn-cache-dir-path
52+
run: echo "::set-output name=dir::$(yarn cache dir)"
53+
- uses: actions/cache@v2
54+
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
55+
with:
56+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
57+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
58+
restore-keys: |
59+
${{ runner.os }}-yarn-
4060
- name: Install Dependencies
4161
run: yarn
4262
- name: Run Unit Tests
@@ -60,10 +80,18 @@ jobs:
6080
uses: actions/setup-node@v2
6181
with:
6282
node-version: ${{ env.NODE_VERSION }}
63-
83+
- name: Get yarn cache directory path
84+
id: yarn-cache-dir-path
85+
run: echo "::set-output name=dir::$(yarn cache dir)"
86+
- uses: actions/cache@v2
87+
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
88+
with:
89+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
90+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
91+
restore-keys: |
92+
${{ runner.os }}-yarn-
6493
- name: Install Dependencies
6594
run: yarn --immutable
66-
6795
- name: Test on Linux System
6896
if: runner.os == 'Linux'
6997
run: xvfb-run -a yarn nx run extension-integrationtest:integrationtest --configuration=test
@@ -85,6 +113,16 @@ jobs:
85113
uses: actions/setup-node@v2
86114
with:
87115
node-version: ${{ env.NODE_VERSION }}
116+
- name: Get yarn cache directory path
117+
id: yarn-cache-dir-path
118+
run: echo "::set-output name=dir::$(yarn cache dir)"
119+
- uses: actions/cache@v2
120+
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
121+
with:
122+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
123+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
124+
restore-keys: |
125+
${{ runner.os }}-yarn-
88126
- name: Install Dependencies
89127
run: yarn --immutable
90128

0 commit comments

Comments
 (0)