Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
run: sbt '++ ${{ matrix.scala }}' githubWorkflowCheck

- shell: bash
run: sbt '++ ${{ matrix.scala }}' '+ test' scripted
run: sbt '++ ${{ matrix.scala }}' '+ test' '+ scripted'

- name: Clean up Ivy Local repo
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ThisBuild / crossScalaVersions := Seq(scala212)
ThisBuild / scalaVersion := scala212

ThisBuild / githubWorkflowOSes := Seq("ubuntu-latest", "macos-latest", "windows-latest")
ThisBuild / githubWorkflowBuild := Seq(WorkflowStep.Sbt(List("+ test", "scripted")))
ThisBuild / githubWorkflowBuild := Seq(WorkflowStep.Sbt(List("+ test", "+ scripted")))
ThisBuild / githubWorkflowBuildPostamble += WorkflowStep.Run(
commands = List("""rm -rf "$HOME/.ivy2/local""""),
name = Some("Clean up Ivy Local repo")
Expand Down
2 changes: 2 additions & 0 deletions src/main/scala/sbtghactions/GenerativeKeys.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import scala.concurrent.duration.FiniteDuration

trait GenerativeKeys {

@transient
lazy val githubWorkflowGenerate = taskKey[Unit]("Generates (and overwrites if extant) a ci.yml and clean.yml actions description according to configuration")
@transient
lazy val githubWorkflowCheck = taskKey[Unit]("Checks to see if the ci.yml and clean.yml files are equivalent to what would be generated and errors if otherwise")

lazy val githubWorkflowDir = settingKey[File]("Where to place the workflow directory which contains the generated ci.yml and clean.yml files. (default: baseDirectory.value / \".github\")")
Expand Down
14 changes: 14 additions & 0 deletions src/sbt-test/sbtghactions/check-and-regenerate/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,17 @@ ThisBuild / githubWorkflowPublish :=
ThisBuild / githubWorkflowBuildTimeout := Some(2.hours)

ThisBuild / githubWorkflowPublishTimeout := Some(1.hour)

TaskKey[Unit]("patchIfSbt2") := {
if (sbtBinaryVersion.value == "2") {
val yml = file("expected-ci.yml")
val targetPath = IO.relativize(baseDirectory.value, target.value).get.replace(java.io.File.separatorChar, '/')
IO.write(
yml,
IO.read(yml).replace(
"run: tar cf targets.tar target project/target",
s"run: tar cf targets.tar ${targetPath} project/target"
)
)
}
}
1 change: 1 addition & 0 deletions src/sbt-test/sbtghactions/check-and-regenerate/test
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ $ copy-file .github/workflows/ci.yml .github/workflows/clean.yml
-> githubWorkflowCheck
> githubWorkflowGenerate
> githubWorkflowCheck
> patchIfSbt2
$ copy-file expected-ci.yml .github/workflows/ci.yml
> githubWorkflowCheck
$ copy-file expected-clean.yml .github/workflows/clean.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,17 @@ version := "0.0.1"
ThisBuild / crossScalaVersions := Seq("2.13.10", "2.12.17")
ThisBuild / scalaVersion := crossScalaVersions.value.head
ThisBuild / githubWorkflowOSes := Seq("windows-latest")

TaskKey[Unit]("patchIfSbt2") := {
if (sbtBinaryVersion.value == "2") {
val yml = file(".github/workflows/ci.yml")
val targetPath = IO.relativize(baseDirectory.value, target.value).get.replace(java.io.File.separatorChar, '/')
IO.write(
yml,
IO.read(yml).replace(
"run: tar cf targets.tar target project/target",
s"run: tar cf targets.tar ${targetPath} project/target"
)
)
}
}
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
> patchIfSbt2
> githubWorkflowCheck
14 changes: 14 additions & 0 deletions src/sbt-test/sbtghactions/no-clean/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,17 @@ version := "0.0.1"
ThisBuild / crossScalaVersions := Seq("2.13.10", "2.12.17")
ThisBuild / scalaVersion := crossScalaVersions.value.head
ThisBuild / githubWorkflowIncludeClean := false

TaskKey[Unit]("patchIfSbt2") := {
if (sbtBinaryVersion.value == "2") {
val yml = file(".github/workflows/ci.yml")
val targetPath = IO.relativize(baseDirectory.value, target.value).get.replace(java.io.File.separatorChar, '/')
IO.write(
yml,
IO.read(yml).replace(
"run: tar cf targets.tar target project/target",
s"run: tar cf targets.tar ${targetPath} project/target"
)
)
}
}
1 change: 1 addition & 0 deletions src/sbt-test/sbtghactions/no-clean/test
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
> patchIfSbt2
> githubWorkflowCheck
16 changes: 16 additions & 0 deletions src/sbt-test/sbtghactions/non-existent-target/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ ThisBuild / scalaVersion := crossScalaVersions.value.head
ThisBuild / githubWorkflowBuild := Seq(WorkflowStep.Sbt(List("withTarget/compile")))

lazy val root = project.in(file(".")).aggregate(withTarget, withoutTarget)
.settings(
TaskKey[Unit]("patchIfSbt2") := {
if (sbtBinaryVersion.value == "2") {
val yml = file(".github/workflows/ci.yml")
val targetPath = IO.relativize(baseDirectory.value, target.value).get.replace(java.io.File.separatorChar, '/')
val withTargetPath = IO.relativize(baseDirectory.value, (withTarget / target).value).get.replace(java.io.File.separatorChar, '/')
IO.write(
yml,
IO.read(yml).replace(
"run: tar cf targets.tar target withTarget/target project/target",
s"run: tar cf targets.tar ${targetPath} ${withTargetPath} project/target"
)
)
}
}
)

lazy val withTarget = project.in(file("withTarget"))

Expand Down
1 change: 1 addition & 0 deletions src/sbt-test/sbtghactions/non-existent-target/test
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
> patchIfSbt2
> githubWorkflowCheck
16 changes: 16 additions & 0 deletions src/sbt-test/sbtghactions/sbt-native-thin-client/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ThisBuild / scalaVersion := "2.12.19"

ThisBuild / githubWorkflowBuild ++= List(
WorkflowStep.Sbt(List("lots")),
WorkflowStep.Sbt(List("of")),
Expand All @@ -10,3 +12,17 @@ ThisBuild / githubWorkflowBuild ++= List(
)

ThisBuild / githubWorkflowUseSbtThinClient := true

TaskKey[Unit]("patchIfSbt2") := {
if (sbtBinaryVersion.value == "2") {
val yml = file(".github/workflows/ci.yml")
val targetPath = IO.relativize(baseDirectory.value, target.value).get.replace(java.io.File.separatorChar, '/')
IO.write(
yml,
IO.read(yml).replace(
"run: tar cf targets.tar target project/target",
s"run: tar cf targets.tar ${targetPath} project/target"
)
)
}
}
1 change: 1 addition & 0 deletions src/sbt-test/sbtghactions/sbt-native-thin-client/test
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
> patchIfSbt2
> githubWorkflowCheck
14 changes: 14 additions & 0 deletions src/sbt-test/sbtghactions/suppressed-scala-version/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,17 @@ ThisBuild / githubWorkflowScalaVersions -= "2.12.17"
ThisBuild / githubWorkflowTargetTags += "v*"

ThisBuild / githubWorkflowPublishTargetBranches += RefPredicate.Equals(Ref.Tag("test"))

TaskKey[Unit]("patchIfSbt2") := {
if (sbtBinaryVersion.value == "2") {
val yml = file("expected-ci.yml")
val targetPath = IO.relativize(baseDirectory.value, target.value).get.replace(java.io.File.separatorChar, '/')
IO.write(
yml,
IO.read(yml).replace(
"run: tar cf targets.tar target project/target",
s"run: tar cf targets.tar ${targetPath} project/target"
)
)
}
}
1 change: 1 addition & 0 deletions src/sbt-test/sbtghactions/suppressed-scala-version/test
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
> githubWorkflowGenerate
> githubWorkflowCheck
> patchIfSbt2
$ copy-file expected-ci.yml .github/workflows/ci.yml
$ copy-file expected-clean.yml .github/workflows/clean.yml
> githubWorkflowCheck
Loading