Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup java cache #300

Merged
merged 4 commits into from Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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