Skip to content

Commit

Permalink
Merge pull request #140 from eed3si9n/wip/graalvm
Browse files Browse the repository at this point in the history
Switch to using graalvm/setup-graalvm@v1
  • Loading branch information
eed3si9n authored Jan 12, 2023
2 parents c19fa4e + 1be9f1f commit 376f03c
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 191 deletions.
42 changes: 12 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,16 @@ jobs:
with:
distribution: temurin
java-version: 8
cache: sbt

- name: Setup GraalVM (graal_20.3.1@11)
if: matrix.java == 'graal_20.3.1@11'
uses: DeLaGuardo/setup-graalvm@5.0
uses: graalvm/setup-graalvm@v1
with:
graalvm: 20.3.1
java: java11

- 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-v3-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
version: 20.3.1
java-version: 11
components: native-image
cache: sbt

- name: Check that workflows are up to date
run: sbt ++${{ matrix.scala }} githubWorkflowCheck
Expand Down Expand Up @@ -94,25 +85,16 @@ jobs:
with:
distribution: temurin
java-version: 8
cache: sbt

- name: Setup GraalVM (graal_20.3.1@11)
if: matrix.java == 'graal_20.3.1@11'
uses: DeLaGuardo/[email protected]
with:
graalvm: 20.3.1
java: java11

- name: Cache sbt
uses: actions/cache@v3
uses: graalvm/setup-graalvm@v1
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-v3-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
version: 20.3.1
java-version: 11
components: native-image
cache: sbt

- name: Download target directories (2.12.15)
uses: actions/download-artifact@v3
Expand Down
27 changes: 1 addition & 26 deletions src/main/scala/sbtghactions/GenerativePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -646,32 +646,7 @@ ${indent(jobs.map(compileJob(_, sbt)).mkString("\n\n"), 1)}
}
},

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-v3-${hashes.mkString("-")}"
)
)
)
},
githubWorkflowGeneratedCacheSteps := Nil,

githubWorkflowJobSetup := {
val autoCrlfOpt = if (githubWorkflowOSes.value.exists(_.contains("windows"))) {
Expand Down
19 changes: 13 additions & 6 deletions src/main/scala/sbtghactions/WorkflowStep.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package sbtghactions

import scala.collection.immutable.ListMap

sealed trait WorkflowStep extends Product with Serializable {
def id: Option[String]
def name: Option[String]
Expand All @@ -36,21 +38,26 @@ object WorkflowStep {
versions map {
case jv @ JavaSpec(JavaSpec.Distribution.GraalVM(graalVersion), version) =>
WorkflowStep.Use(
UseRef.Public("DeLaGuardo", "setup-graalvm", "5.0"),
UseRef.Public("graalvm", "setup-graalvm", "v1"),
name = Some(s"Setup GraalVM (${jv.render})"),
cond = Some(s"matrix.java == '${jv.render}'"),
params = Map(
"graalvm" -> graalVersion,
"java" -> s"java$version"))
params = ListMap(
"version" -> graalVersion,
"java-version" -> s"$version",
"components" -> "native-image",
// TODO: https://github.com/marketplace/actions/github-action-for-graalvm
// "github-token" -> s"$${{ secrets.GITHUB_TOKEN }}",
"cache" -> "sbt"))

case jv @ JavaSpec(dist, version) =>
WorkflowStep.Use(
UseRef.Public("actions", "setup-java", "v3"),
name = Some(s"Setup Java (${jv.render})"),
cond = Some(s"matrix.java == '${jv.render}'"),
params = Map(
params = ListMap(
"distribution" -> dist.rendering,
"java-version" -> version))
"java-version" -> version,
"cache" -> "sbt"))
}

val Tmate: WorkflowStep = Use(UseRef.Public("mxschmitt", "action-tmate", "v2"), name = Some("Setup tmate session"))
Expand Down
42 changes: 12 additions & 30 deletions src/sbt-test/sbtghactions/check-and-regenerate/expected-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,16 @@ jobs:
with:
distribution: temurin
java-version: 11
cache: sbt

- name: Setup GraalVM (graal_21.1.0@8)
if: matrix.java == 'graal_21.1.0@8'
uses: DeLaGuardo/setup-graalvm@5.0
uses: graalvm/setup-graalvm@v1
with:
graalvm: 21.1.0
java: java8

- 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-v3-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
version: 21.1.0
java-version: 8
components: native-image
cache: sbt

- name: Check that workflows are up to date
run: sbt ++${{ matrix.scala }} githubWorkflowCheck
Expand Down Expand Up @@ -104,25 +95,16 @@ jobs:
with:
distribution: temurin
java-version: 11
cache: sbt

- name: Setup GraalVM (graal_21.1.0@8)
if: matrix.java == 'graal_21.1.0@8'
uses: DeLaGuardo/[email protected]
with:
graalvm: 21.1.0
java: java8

- name: Cache sbt
uses: actions/cache@v3
uses: graalvm/setup-graalvm@v1
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-v3-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
version: 21.1.0
java-version: 8
components: native-image
cache: sbt

- name: Download target directories (2.13.6)
uses: actions/download-artifact@v3
Expand Down
26 changes: 2 additions & 24 deletions src/sbt-test/sbtghactions/no-clean/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,7 @@ jobs:
with:
distribution: temurin
java-version: 11

- 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-v3-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
cache: sbt

- name: Check that workflows are up to date
run: sbt ++${{ matrix.scala }} githubWorkflowCheck
Expand Down Expand Up @@ -87,18 +76,7 @@ jobs:
with:
distribution: temurin
java-version: 11

- 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-v3-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
cache: sbt

- name: Download target directories (2.13.6)
uses: actions/download-artifact@v3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,7 @@ jobs:
with:
distribution: temurin
java-version: 11

- 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-v3-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
cache: sbt

- name: Check that workflows are up to date
run: sbt ++${{ matrix.scala }} githubWorkflowCheck
Expand Down Expand Up @@ -86,18 +75,7 @@ jobs:
with:
distribution: temurin
java-version: 11

- 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-v3-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
cache: sbt

- name: Download target directories (2.13.6)
uses: actions/download-artifact@v3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,7 @@ jobs:
with:
distribution: temurin
java-version: 11

- 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-v3-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
cache: sbt

- name: Check that workflows are up to date
run: sbt --client '++${{ matrix.scala }}; githubWorkflowCheck'
Expand Down Expand Up @@ -103,18 +92,7 @@ jobs:
with:
distribution: temurin
java-version: 11

- 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-v3-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
cache: sbt

- name: Download target directories (2.12.14)
uses: actions/download-artifact@v3
Expand Down
26 changes: 2 additions & 24 deletions src/sbt-test/sbtghactions/suppressed-scala-version/expected-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,7 @@ jobs:
with:
distribution: temurin
java-version: 11

- 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-v3-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
cache: sbt

- name: Check that workflows are up to date
run: sbt ++${{ matrix.scala }} githubWorkflowCheck
Expand Down Expand Up @@ -88,18 +77,7 @@ jobs:
with:
distribution: temurin
java-version: 11

- 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-v3-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
cache: sbt

- name: Download target directories (2.13.6)
uses: actions/download-artifact@v3
Expand Down
9 changes: 6 additions & 3 deletions src/test/scala/sbtghactions/GenerativePluginSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -537,13 +537,16 @@ class GenerativePluginSpec extends Specification {
with:
distribution: temurin
java-version: 11
cache: sbt

- name: Setup GraalVM (graal_20.0.0@8)
if: matrix.java == 'graal_20.0.0@8'
uses: DeLaGuardo/setup-graalvm@5.0
uses: graalvm/setup-graalvm@v1
with:
graalvm: 20.0.0
java: java8"""
version: 20.0.0
java-version: 8
components: native-image
cache: sbt"""
}

"compile a job with environment variables, conditional, and needs with an sbt step" in {
Expand Down

0 comments on commit 376f03c

Please sign in to comment.