Skip to content

Commit

Permalink
Prevent cross-talk in scripted tests when running multiple builds
Browse files Browse the repository at this point in the history
Scripted tests use the scala build generated by `publishLocal`.
Make sure every build has a different Scala version, otherwise
two builds running on the same machine override each others
`2.13.15-bin-SNAPSHOT` artifacts.
  • Loading branch information
lrytz committed Aug 8, 2024
1 parent 6590783 commit ab2d882
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ lazy val sbtTest = project.in(file("test") / "sbt-test")
sbtTestDirectory := baseDirectory.value,

scriptedBatchExecution := true, // set to `false` to execute each test in a separate sbt instance
scriptedParallelInstances := (if (insideCI.value) 1 else 2), // default is 1; races cause spurious failures
scriptedParallelInstances := 2,

// hide sbt output of scripted tests
scriptedBufferLog := true,
Expand Down
3 changes: 3 additions & 0 deletions project/ScriptCommands.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ object ScriptCommands {
* The optional argument is the Artifactory snapshot repository URL. */
def setupValidateTest = setup("setupValidateTest") { args =>
Seq(
// include sha to prevent multiple builds running on the same jenkins worker from overriding each other
// sbtTest/scripted uses publishLocal
Global / baseVersionSuffix := "SHA-TEST-SNAPSHOT",
LocalProject("test") / IntegrationTest / testOptions ++= Seq(Tests.Argument("--show-log"), Tests.Argument("--show-diff"))
) ++ (args match {
case Seq(url) => Seq(Global / resolvers += "scala-pr" at url)
Expand Down
11 changes: 6 additions & 5 deletions project/VersionUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,12 @@ object VersionUtil {
}

val (canonicalV, mavenSuffix, osgiV, release) = suffix match {
case "SNAPSHOT" => (s"$base-$date-$sha", s"-$cross-SNAPSHOT", s"$base.v$date-$sha", false)
case "SHA-SNAPSHOT" => (s"$base-$date-$sha", s"-$cross-$sha-SNAPSHOT", s"$base.v$date-$sha", false)
case "SHA" => (s"$base-$sha", s"-$cross-$sha", s"$base.v$date-$sha", false)
case "" => (s"$base", "", s"$base.v$date-VFINAL-$sha", true)
case _ => (s"$base-$suffix", s"-$suffix", s"$base.v$date-$suffix-$sha", true)
case "SNAPSHOT" => (s"$base-$date-$sha", s"-$cross-SNAPSHOT", s"$base.v$date-$sha", false)
case "SHA-SNAPSHOT" => (s"$base-$date-$sha", s"-$cross-$sha-SNAPSHOT", s"$base.v$date-$sha", false)
case "SHA-TEST-SNAPSHOT" => (s"$base-$date-$sha", s"-$cross-$sha-TEST-SNAPSHOT", s"$base.v$date-$sha", false)
case "SHA" => (s"$base-$sha", s"-$cross-$sha", s"$base.v$date-$sha", false)
case "" => (s"$base", "", s"$base.v$date-VFINAL-$sha", true)
case _ => (s"$base-$suffix", s"-$suffix", s"$base.v$date-$suffix-$sha", true)
}


Expand Down

0 comments on commit ab2d882

Please sign in to comment.