Skip to content

Commit 29eab9d

Browse files
authored
Merge pull request #300 from pjfanning/setup-java-cache
Setup java cache
2 parents be4f759 + 661d02c commit 29eab9d

File tree

3 files changed

+13
-73
lines changed

3 files changed

+13
-73
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
distribution: jdkfile
4949
java-version: 8
5050
jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }}
51+
cache: sbt
5152

5253
- name: Download Java (temurin@17)
5354
id: download-java-temurin-17
@@ -64,18 +65,7 @@ jobs:
6465
distribution: jdkfile
6566
java-version: 17
6667
jdkFile: ${{ steps.download-java-temurin-17.outputs.jdkFile }}
67-
68-
- name: Cache sbt
69-
uses: actions/cache@v3
70-
with:
71-
path: |
72-
~/.sbt
73-
~/.ivy2/cache
74-
~/.coursier/cache/v1
75-
~/.cache/coursier/v1
76-
~/AppData/Local/Coursier/Cache/v1
77-
~/Library/Caches/Coursier/v1
78-
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
68+
cache: sbt
7969

8070
- name: Check that workflows are up to date
8171
run: sbt githubWorkflowCheck
@@ -145,6 +135,7 @@ jobs:
145135
distribution: jdkfile
146136
java-version: 8
147137
jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }}
138+
cache: sbt
148139

149140
- name: Download Java (temurin@17)
150141
id: download-java-temurin-17
@@ -161,18 +152,7 @@ jobs:
161152
distribution: jdkfile
162153
java-version: 17
163154
jdkFile: ${{ steps.download-java-temurin-17.outputs.jdkFile }}
164-
165-
- name: Cache sbt
166-
uses: actions/cache@v3
167-
with:
168-
path: |
169-
~/.sbt
170-
~/.ivy2/cache
171-
~/.coursier/cache/v1
172-
~/.cache/coursier/v1
173-
~/AppData/Local/Coursier/Cache/v1
174-
~/Library/Caches/Coursier/v1
175-
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
155+
cache: sbt
176156

177157
- name: Download target directories (2.12.17, sbt-typelevelJVM)
178158
uses: actions/download-artifact@v3
@@ -238,6 +218,7 @@ jobs:
238218
distribution: jdkfile
239219
java-version: 8
240220
jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }}
221+
cache: sbt
241222

242223
- name: Download Java (temurin@17)
243224
id: download-java-temurin-17
@@ -254,18 +235,7 @@ jobs:
254235
distribution: jdkfile
255236
java-version: 17
256237
jdkFile: ${{ steps.download-java-temurin-17.outputs.jdkFile }}
257-
258-
- name: Cache sbt
259-
uses: actions/cache@v3
260-
with:
261-
path: |
262-
~/.sbt
263-
~/.ivy2/cache
264-
~/.coursier/cache/v1
265-
~/.cache/coursier/v1
266-
~/AppData/Local/Coursier/Cache/v1
267-
~/Library/Caches/Coursier/v1
268-
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
238+
cache: sbt
269239

270240
- name: Submit Dependencies
271241
uses: scalacenter/sbt-dependency-submission@v2
@@ -299,6 +269,7 @@ jobs:
299269
distribution: jdkfile
300270
java-version: 8
301271
jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }}
272+
cache: sbt
302273

303274
- name: Download Java (temurin@17)
304275
id: download-java-temurin-17
@@ -315,18 +286,7 @@ jobs:
315286
distribution: jdkfile
316287
java-version: 17
317288
jdkFile: ${{ steps.download-java-temurin-17.outputs.jdkFile }}
318-
319-
- name: Cache sbt
320-
uses: actions/cache@v3
321-
with:
322-
path: |
323-
~/.sbt
324-
~/.ivy2/cache
325-
~/.coursier/cache/v1
326-
~/.cache/coursier/v1
327-
~/AppData/Local/Coursier/Cache/v1
328-
~/Library/Caches/Coursier/v1
329-
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
289+
cache: sbt
330290

331291
- name: Generate site
332292
run: sbt '++${{ matrix.scala }}' docs/tlSite

github-actions/src/main/scala/org/typelevel/sbt/gha/GenerativePlugin.scala

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -654,29 +654,7 @@ ${indent(jobs.map(compileJob(_, sbt)).mkString("\n\n"), 1)}
654654
Seq()
655655
}
656656
},
657-
githubWorkflowGeneratedCacheSteps := {
658-
val hashes = githubWorkflowDependencyPatterns.value map { glob =>
659-
s"$${{ hashFiles('$glob') }}"
660-
}
661-
662-
Seq(
663-
WorkflowStep.Use(
664-
UseRef.Public("actions", "cache", "v3"),
665-
name = Some("Cache sbt"),
666-
params = Map(
667-
"path" -> Seq(
668-
"~/.sbt",
669-
"~/.ivy2/cache",
670-
"~/.coursier/cache/v1",
671-
"~/.cache/coursier/v1",
672-
"~/AppData/Local/Coursier/Cache/v1",
673-
"~/Library/Caches/Coursier/v1"
674-
).mkString("\n"),
675-
"key" -> s"$${{ runner.os }}-sbt-cache-v2-${hashes.mkString("-")}"
676-
)
677-
)
678-
)
679-
},
657+
githubWorkflowGeneratedCacheSteps := Seq(),
680658
githubWorkflowJobSetup := {
681659
val autoCrlfOpt = if (githubWorkflowOSes.value.exists(_.contains("windows"))) {
682660
List(

github-actions/src/main/scala/org/typelevel/sbt/gha/WorkflowStep.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ object WorkflowStep {
6767
params = Map(
6868
"distribution" -> "jdkfile",
6969
"java-version" -> version,
70-
"jdkFile" -> s"$${{ steps.$id.outputs.jdkFile }}"
70+
"jdkFile" -> s"$${{ steps.$id.outputs.jdkFile }}",
71+
"cache" -> "sbt"
7172
)
7273
)
7374
)
@@ -77,7 +78,8 @@ object WorkflowStep {
7778
UseRef.Public("actions", "setup-java", "v3"),
7879
name = Some(s"Setup Java (${jv.render})"),
7980
cond = Some(s"matrix.java == '${jv.render}'"),
80-
params = Map("distribution" -> dist.rendering, "java-version" -> version)
81+
params =
82+
Map("distribution" -> dist.rendering, "java-version" -> version, "cache" -> "sbt")
8183
) :: Nil
8284
}
8385

0 commit comments

Comments
 (0)