Skip to content

Commit 677d954

Browse files
authored
Improve deps caching in github action (#420)
By using a separate cache per action / deps alias and using the hash of the `deps.edn` as a cache key to keep the cache from growing unbounded.
1 parent 2ff3c42 commit 677d954

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

.github/workflows/main.yml

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
uses: actions/setup-java@v1
1414
with:
1515
java-version: '11.0.7'
16+
cache: 'maven'
1617

1718
- name: 🔧 Install clojure
1819
uses: DeLaGuardo/setup-clojure@master
@@ -26,14 +27,13 @@ jobs:
2627
bb run --prn -current-branch
2728
2829
- name: 🗝 maven cache
29-
uses: actions/cache@v2
30+
uses: actions/cache@v3
3031
with:
3132
path: |
3233
~/.m2
3334
~/.gitlibs
34-
key: ${{ runner.os }}-maven-${{ github.sha }}
35-
restore-keys: |
36-
${{ runner.os }}-maven-
35+
~/.deps.clj
36+
key: ${{ runner.os }}-maven-build-viewer-${{ hashFiles('deps.edn') }}
3737

3838
- name: Build and upload viewer resources
3939
env:
@@ -85,15 +85,13 @@ jobs:
8585
bb: latest
8686

8787
- name: 🗝 maven cache
88-
uses: actions/cache@v2
88+
uses: actions/cache@v3
8989
with:
9090
path: |
9191
~/.m2
9292
~/.gitlibs
9393
~/.deps.clj
94-
key: ${{ runner.os }}-maven-${{ github.sha }}
95-
restore-keys: |
96-
${{ runner.os }}-maven-
94+
key: ${{ runner.os }}-maven-test-${{ hashFiles('deps.edn') }}
9795

9896
- name: 🧪 Run tests
9997
run: bb test:clj :kaocha/reporter '[kaocha.report/documentation]'
@@ -118,14 +116,13 @@ jobs:
118116
bb: latest
119117

120118
- name: 🗝 maven cache
121-
uses: actions/cache@v2
119+
uses: actions/cache@v3
122120
with:
123121
path: |
124122
~/.m2
125123
~/.gitlibs
126-
key: ${{ runner.os }}-maven-${{ github.sha }}
127-
restore-keys: |
128-
${{ runner.os }}-maven-
124+
~/.deps.clj
125+
key: ${{ runner.os }}-maven-build-${{ hashFiles('deps.edn') }}
129126

130127
- name: 🗝 Clerk Cache
131128
uses: actions/cache@v2
@@ -180,14 +177,13 @@ jobs:
180177
cli: '1.10.3.943'
181178

182179
- name: 🗝 maven cache
183-
uses: actions/cache@v2
180+
uses: actions/cache@v3
184181
with:
185182
path: |
186183
~/.m2
187184
~/.gitlibs
188-
key: ${{ runner.os }}-maven-${{ github.sha }}
189-
restore-keys: |
190-
${{ runner.os }}-maven-
185+
~/.deps.clj
186+
key: ${{ runner.os }}-maven-ssr-${{ hashFiles('deps.edn') }}
191187

192188
- name: 🎨 Setup Tailwindcss
193189
run: yarn global add tailwindcss @tailwindcss/typography
@@ -231,6 +227,16 @@ jobs:
231227
with:
232228
bb: latest
233229

230+
- name: 🗝 maven cache
231+
uses: actions/cache@v3
232+
with:
233+
path: |
234+
~/.m2
235+
~/.gitlibs
236+
~/.deps.clj
237+
key: ${{ runner.os }}-maven-ui-tests-${{ hashFiles('deps.edn') }}
238+
239+
234240
- name: Run Playwright tests against static assets
235241
run: |
236242
bb test:static-app ${{ github.sha }}
@@ -250,14 +256,13 @@ jobs:
250256
bb: latest
251257

252258
- name: 🗝 maven cache
253-
uses: actions/cache@v2
259+
uses: actions/cache@v3
254260
with:
255261
path: |
256262
~/.m2
257263
~/.gitlibs
258-
key: ${{ runner.os }}-maven-${{ github.sha }}
259-
restore-keys: |
260-
${{ runner.os }}-maven-
264+
~/.deps.clj
265+
key: ${{ runner.os }}-maven-deploy-${{ hashFiles('deps.edn') }}
261266

262267
- name: Install SSH key and start ssh-agent
263268
uses: webfactory/[email protected]

0 commit comments

Comments
 (0)