Skip to content

Commit

Permalink
Merge pull request #300 from pjfanning/setup-java-cache
Browse files Browse the repository at this point in the history
Setup java cache
  • Loading branch information
armanbilge committed Oct 21, 2022
2 parents be4f759 + 661d02c commit 29eab9d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 73 deletions.
56 changes: 8 additions & 48 deletions .github/workflows/ci.yml
Expand Up @@ -48,6 +48,7 @@ jobs:
distribution: jdkfile
java-version: 8
jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }}
cache: sbt

- name: Download Java (temurin@17)
id: download-java-temurin-17
Expand All @@ -64,18 +65,7 @@ jobs:
distribution: jdkfile
java-version: 17
jdkFile: ${{ steps.download-java-temurin-17.outputs.jdkFile }}

- name: Cache sbt
uses: actions/cache@v3
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
cache: sbt

- name: Check that workflows are up to date
run: sbt githubWorkflowCheck
Expand Down Expand Up @@ -145,6 +135,7 @@ jobs:
distribution: jdkfile
java-version: 8
jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }}
cache: sbt

- name: Download Java (temurin@17)
id: download-java-temurin-17
Expand All @@ -161,18 +152,7 @@ jobs:
distribution: jdkfile
java-version: 17
jdkFile: ${{ steps.download-java-temurin-17.outputs.jdkFile }}

- name: Cache sbt
uses: actions/cache@v3
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
cache: sbt

- name: Download target directories (2.12.17, sbt-typelevelJVM)
uses: actions/download-artifact@v3
Expand Down Expand Up @@ -238,6 +218,7 @@ jobs:
distribution: jdkfile
java-version: 8
jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }}
cache: sbt

- name: Download Java (temurin@17)
id: download-java-temurin-17
Expand All @@ -254,18 +235,7 @@ jobs:
distribution: jdkfile
java-version: 17
jdkFile: ${{ steps.download-java-temurin-17.outputs.jdkFile }}

- name: Cache sbt
uses: actions/cache@v3
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
cache: sbt

- name: Submit Dependencies
uses: scalacenter/sbt-dependency-submission@v2
Expand Down Expand Up @@ -299,6 +269,7 @@ jobs:
distribution: jdkfile
java-version: 8
jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }}
cache: sbt

- name: Download Java (temurin@17)
id: download-java-temurin-17
Expand All @@ -315,18 +286,7 @@ jobs:
distribution: jdkfile
java-version: 17
jdkFile: ${{ steps.download-java-temurin-17.outputs.jdkFile }}

- name: Cache sbt
uses: actions/cache@v3
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
cache: sbt

- name: Generate site
run: sbt '++${{ matrix.scala }}' docs/tlSite
Expand Down
Expand Up @@ -654,29 +654,7 @@ ${indent(jobs.map(compileJob(_, sbt)).mkString("\n\n"), 1)}
Seq()
}
},
githubWorkflowGeneratedCacheSteps := {
val hashes = githubWorkflowDependencyPatterns.value map { glob =>
s"$${{ hashFiles('$glob') }}"
}

Seq(
WorkflowStep.Use(
UseRef.Public("actions", "cache", "v3"),
name = Some("Cache sbt"),
params = Map(
"path" -> Seq(
"~/.sbt",
"~/.ivy2/cache",
"~/.coursier/cache/v1",
"~/.cache/coursier/v1",
"~/AppData/Local/Coursier/Cache/v1",
"~/Library/Caches/Coursier/v1"
).mkString("\n"),
"key" -> s"$${{ runner.os }}-sbt-cache-v2-${hashes.mkString("-")}"
)
)
)
},
githubWorkflowGeneratedCacheSteps := Seq(),
githubWorkflowJobSetup := {
val autoCrlfOpt = if (githubWorkflowOSes.value.exists(_.contains("windows"))) {
List(
Expand Down
Expand Up @@ -67,7 +67,8 @@ object WorkflowStep {
params = Map(
"distribution" -> "jdkfile",
"java-version" -> version,
"jdkFile" -> s"$${{ steps.$id.outputs.jdkFile }}"
"jdkFile" -> s"$${{ steps.$id.outputs.jdkFile }}",
"cache" -> "sbt"
)
)
)
Expand All @@ -77,7 +78,8 @@ object WorkflowStep {
UseRef.Public("actions", "setup-java", "v3"),
name = Some(s"Setup Java (${jv.render})"),
cond = Some(s"matrix.java == '${jv.render}'"),
params = Map("distribution" -> dist.rendering, "java-version" -> version)
params =
Map("distribution" -> dist.rendering, "java-version" -> version, "cache" -> "sbt")
) :: Nil
}

Expand Down

0 comments on commit 29eab9d

Please sign in to comment.