Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,28 @@ jobs:

- name: Configure pagefile for Windows
if: contains(runner.os, 'windows')
uses: al-cheb/configure-pagefile-action@v1.4
uses: al-cheb/configure-pagefile-action@a3b6ebd6b634da88790d9c58d4b37a7f4a7b8708 # v1.4
with:
minimum-size: 2GB
maximum-size: 8GB
disk-root: 'C:'

- name: Checkout current branch (full)
uses: actions/checkout@v5
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0

- name: Setup Java (zulu@8)
if: matrix.java == 'zulu@8'
uses: actions/setup-java@v5
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
with:
distribution: zulu
java-version: 8
cache: sbt

- name: Setup GraalVM (graal_graalvm@17)
if: matrix.java == 'graal_graalvm@17'
uses: graalvm/setup-graalvm@v1
uses: graalvm/setup-graalvm@2a2412009026a83f51d179f92dc2b3fd4c8142df # v1.4.1
with:
java-version: 17
distribution: graalvm
Expand All @@ -65,14 +65,14 @@ jobs:

- name: Setup Java (corretto@17)
if: matrix.java == 'corretto@17'
uses: actions/setup-java@v5
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
with:
distribution: corretto
java-version: 17
cache: sbt

- name: Setup sbt
uses: sbt/setup-sbt@v1
uses: sbt/setup-sbt@3e125ece5c3e5248e18da9ed8d2cce3d335ec8dd # v1.1.14

- name: Check that workflows are up to date
shell: bash
Expand All @@ -90,7 +90,7 @@ jobs:
run: tar cf targets.tar target project/target

- name: Upload target directories
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }}
path: targets.tar
Expand All @@ -112,28 +112,28 @@ jobs:

- name: Configure pagefile for Windows
if: contains(runner.os, 'windows')
uses: al-cheb/configure-pagefile-action@v1.4
uses: al-cheb/configure-pagefile-action@a3b6ebd6b634da88790d9c58d4b37a7f4a7b8708 # v1.4
with:
minimum-size: 2GB
maximum-size: 8GB
disk-root: 'C:'

- name: Checkout current branch (full)
uses: actions/checkout@v5
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0

- name: Setup Java (zulu@8)
if: matrix.java == 'zulu@8'
uses: actions/setup-java@v5
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
with:
distribution: zulu
java-version: 8
cache: sbt

- name: Setup GraalVM (graal_graalvm@17)
if: matrix.java == 'graal_graalvm@17'
uses: graalvm/setup-graalvm@v1
uses: graalvm/setup-graalvm@2a2412009026a83f51d179f92dc2b3fd4c8142df # v1.4.1
with:
java-version: 17
distribution: graalvm
Expand All @@ -143,17 +143,17 @@ jobs:

- name: Setup Java (corretto@17)
if: matrix.java == 'corretto@17'
uses: actions/setup-java@v5
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
with:
distribution: corretto
java-version: 17
cache: sbt

- name: Setup sbt
uses: sbt/setup-sbt@v1
uses: sbt/setup-sbt@3e125ece5c3e5248e18da9ed8d2cce3d335ec8dd # v1.1.14

- name: Download target directories (2.12.20)
uses: actions/download-artifact@v5
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
name: target-${{ matrix.os }}-2.12.20-${{ matrix.java }}

Expand Down
16 changes: 11 additions & 5 deletions src/main/scala/sbtghactions/GenerativePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ ${indent(rendered.mkString("\n"), 1)}"""
import use.{ref, params}

val decl = ref match {
case UseRef.Public(owner, repo, ref) =>
s"uses: $owner/$repo@$ref"
case UseRef.Public(owner, repo, rev, ref) =>
s"uses: $owner/$repo@$rev # $ref"

case UseRef.Local(path) =>
val cleaned = if (path.startsWith("./"))
Expand Down Expand Up @@ -640,7 +640,8 @@ ${indent(jobs.map(compileJob(_, sbt)).mkString("\n\n"), 1)}
UseRef.Public(
"actions",
"upload-artifact",
"v4"),
"ea165f8d65b6e75b540449e92b4886f43607fa02",
"v4.6.2"),
name = Some(s"Upload target directories"),
params = Map(
"name" -> s"target-$${{ matrix.os }}-$${{ matrix.scala }}-$${{ matrix.java }}",
Expand All @@ -661,7 +662,8 @@ ${indent(jobs.map(compileJob(_, sbt)).mkString("\n\n"), 1)}
UseRef.Public(
"actions",
"download-artifact",
"v5"),
"634f93cb2916e3fdff6788551b99b062d0335ce0",
"v5.0.0"),
name = Some(s"Download target directories ($v)"),
params = Map(
"name" -> s"target-$${{ matrix.os }}-$v-$${{ matrix.java }}"))
Expand All @@ -686,7 +688,11 @@ ${indent(jobs.map(compileJob(_, sbt)).mkString("\n\n"), 1)}
val optionalPagefileFix = githubWorkflowWindowsPagefileFix.value.map(pageFileFix =>
WorkflowStep.Use(
name = Some("Configure pagefile for Windows"),
ref = UseRef.Public("al-cheb", "configure-pagefile-action", "v1.4"),
ref = UseRef.Public(
"al-cheb",
"configure-pagefile-action",
"a3b6ebd6b634da88790d9c58d4b37a7f4a7b8708",
"v1.4"),
params = Map(
"minimum-size" -> s"${pageFileFix.minSize}",
"maximum-size" -> s"${pageFileFix.maxSize}"
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/sbtghactions/UseRef.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package sbtghactions
sealed trait UseRef extends Product with Serializable

object UseRef {
final case class Public(owner: String, repo: String, ref: String) extends UseRef
final case class Public(owner: String, repo: String, rev: String, ref: String) extends UseRef

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing as ref is now always rendered as a comment, I think it makes to keep ref as the actual reference used (be it a hash, tag, or branch name), and instead introduce comment: Option[String] = None. This way we'd retain source compatibility, also allowing users to opt-in to reference actions by a hash + comment, if they aren't already.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure - I think it's actually a feature that users would have to review the call site to make sure the third argument is a rev. I could see making the fourth parameter a comment: Option[String] though, no strong preference.

final case class Local(path: String) extends UseRef
final case class Docker(image: String, tag: String, host: Option[String] = None) extends UseRef
}
45 changes: 38 additions & 7 deletions src/main/scala/sbtghactions/WorkflowStep.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,31 @@ object WorkflowStep {
val DefaultSbtStepPreamble: List[String] = List(s"++ $${{ matrix.scala }}")

val CheckoutFull: WorkflowStep = Use(
UseRef.Public("actions", "checkout", "v5"),
UseRef.Public(
"actions",
"checkout",
"08c6903cd8c0fde910a37f88322edcfb5dd907a8",
"v5.0.0"),
Comment on lines -36 to +40
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sympathetic to having an immutable and repeatable CI configuration, but the downside to embedding git sha into *.scala code this way is that now the upgrade burden would shift to the sbt-github-actions maintainer and/or simply this would be left forgotten as the actions might ship fixes and patches.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jup - this PR was more of a 'straw man' to get the conversation going than something I'd expect to get merged in this form.

What would be the way forward here? Perhaps we could have an option that makes githubWorkflowCheck more lenient and allow dependabot to update versions (but not the rest of the workflow)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the limited number of upstream actions, we could probably run some weekly cron job that check them out and maintain a JSON file of action, version, and gitsha, maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, but that'd kind of pressure us into releasing a new version of sbt-github-actions each time that job finds something to update - I'm not sure we'd want that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea so even in the JSON metadata world maybe it's better to default to v4 style and let the user opt into git shas. That way for the most users we won't be the bottleneck to release the patches.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we could keep using tags/branches but 'accept' the hashes in the check, like #207 ?

name = Some("Checkout current branch (full)"),
params = Map("fetch-depth" -> "0"))

val Checkout: WorkflowStep = Use(UseRef.Public("actions", "checkout", "v5"), name = Some("Checkout current branch (fast)"))
val Checkout: WorkflowStep = Use(
UseRef.Public(
"actions",
"checkout",
"08c6903cd8c0fde910a37f88322edcfb5dd907a8",
"v5.0.0"),
name = Some("Checkout current branch (fast)"))

def SetupJava(versions: List[JavaSpec]): List[WorkflowStep] =
versions map {
case jv @ JavaSpec(JavaSpec.Distribution.GraalVM(Graalvm.Version(graalVersion)), version) =>
WorkflowStep.Use(
UseRef.Public("graalvm", "setup-graalvm", "v1"),
UseRef.Public(
"graalvm",
"setup-graalvm",
"2a2412009026a83f51d179f92dc2b3fd4c8142df",
"v1.4.1"),
name = Some(s"Setup GraalVM (${jv.render})"),
cond = Some(s"matrix.java == '${jv.render}'"),
params = ListMap(
Expand All @@ -54,7 +68,11 @@ object WorkflowStep {
"cache" -> "sbt"))
case jv @ JavaSpec(JavaSpec.Distribution.GraalVM(Graalvm.Distribution(distribution)), version) =>
WorkflowStep.Use(
UseRef.Public("graalvm", "setup-graalvm", "v1"),
UseRef.Public(
"graalvm",
"setup-graalvm",
"2a2412009026a83f51d179f92dc2b3fd4c8142df",
"v1.4.1"),
name = Some(s"Setup GraalVM (${jv.render})"),
cond = Some(s"matrix.java == '${jv.render}'"),
params = ListMap(
Expand All @@ -65,7 +83,11 @@ object WorkflowStep {
"cache" -> "sbt"))
case jv @ JavaSpec(dist, version) =>
WorkflowStep.Use(
UseRef.Public("actions", "setup-java", "v5"),
UseRef.Public(
"actions",
"setup-java",
"dded0888837ed1f317902acf8a20df0ad188d165",
"v5.0.0"),
name = Some(s"Setup Java (${jv.render})"),
cond = Some(s"matrix.java == '${jv.render}'"),
params = ListMap(
Expand All @@ -76,15 +98,24 @@ object WorkflowStep {

def SetupSbt(runnerVersion: Option[String] = None): WorkflowStep =
Use(
ref = UseRef.Public("sbt", "setup-sbt", "v1"),
ref = UseRef.Public(
"sbt",
"setup-sbt",
"3e125ece5c3e5248e18da9ed8d2cce3d335ec8dd",
"v1.1.14"),
params = runnerVersion match {
case Some(v) => Map("sbt-runner-version" -> v)
case None => Map()
},
name = Some("Setup sbt"),
)

val Tmate: WorkflowStep = Use(UseRef.Public("mxschmitt", "action-tmate", "v2"), name = Some("Setup tmate session"))
val Tmate: WorkflowStep = Use(
UseRef.Public(
"mxschmitt",
"action-tmate",
"ece3d66d6d54a01594acd0ee2e79d1bfb2df136d",
"v2"), name = Some("Setup tmate session"))

def ComputeVar(name: String, cmd: String): WorkflowStep =
Run(
Expand Down
22 changes: 11 additions & 11 deletions src/sbt-test/sbtghactions/check-and-regenerate/expected-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@ jobs:

steps:
- name: Checkout current branch (full)
uses: actions/checkout@v5
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0

- name: Setup Java (zulu@8)
if: matrix.java == 'zulu@8'
uses: actions/setup-java@v5
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
with:
distribution: zulu
java-version: 8
cache: sbt

- name: Setup GraalVM (graal_22.3.0@17)
if: matrix.java == 'graal_22.3.0@17'
uses: graalvm/setup-graalvm@v1
uses: graalvm/setup-graalvm@2a2412009026a83f51d179f92dc2b3fd4c8142df # v1.4.1
with:
version: 22.3.0
java-version: 17
Expand All @@ -60,7 +60,7 @@ jobs:
cache: sbt

- name: Setup sbt
uses: sbt/setup-sbt@v1
uses: sbt/setup-sbt@3e125ece5c3e5248e18da9ed8d2cce3d335ec8dd # v1.1.14

- name: Check that workflows are up to date
run: sbt '++ ${{ matrix.scala }}' githubWorkflowCheck
Expand All @@ -74,7 +74,7 @@ jobs:
run: tar cf targets.tar target project/target

- name: Upload target directories
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }}
path: targets.tar
Expand All @@ -93,21 +93,21 @@ jobs:

steps:
- name: Checkout current branch (full)
uses: actions/checkout@v5
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0

- name: Setup Java (zulu@8)
if: matrix.java == 'zulu@8'
uses: actions/setup-java@v5
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
with:
distribution: zulu
java-version: 8
cache: sbt

- name: Setup GraalVM (graal_22.3.0@17)
if: matrix.java == 'graal_22.3.0@17'
uses: graalvm/setup-graalvm@v1
uses: graalvm/setup-graalvm@2a2412009026a83f51d179f92dc2b3fd4c8142df # v1.4.1
with:
version: 22.3.0
java-version: 17
Expand All @@ -116,10 +116,10 @@ jobs:
cache: sbt

- name: Setup sbt
uses: sbt/setup-sbt@v1
uses: sbt/setup-sbt@3e125ece5c3e5248e18da9ed8d2cce3d335ec8dd # v1.1.14

- name: Download target directories (2.13.10)
uses: actions/download-artifact@v5
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
name: target-${{ matrix.os }}-2.13.10-${{ matrix.java }}

Expand All @@ -129,7 +129,7 @@ jobs:
rm targets.tar

- name: Download target directories (2.12.17)
uses: actions/download-artifact@v5
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
name: target-${{ matrix.os }}-2.12.17-${{ matrix.java }}

Expand Down
Loading
Loading