Skip to content

Commit 585e18e

Browse files
authored
Merge pull request #899 from lrytz/cross-jvm
jvm -> scala version in sbt, not yml
2 parents 0f490e6 + d71ce9e commit 585e18e

File tree

3 files changed

+53
-74
lines changed

3 files changed

+53
-74
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ on:
55
push:
66

77
jobs:
8-
core:
8+
test:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
java: [8, 17, 25]
13-
scala: [2.12.x, 2.13.x, 3.3.x]
12+
java: [8, 17]
1413
runs-on: ubuntu-latest
1514
steps:
1615
- uses: actions/checkout@v6
@@ -20,18 +19,17 @@ jobs:
2019
java-version: ${{matrix.java}}
2120
cache: sbt
2221
- uses: sbt/setup-sbt@v1
23-
- run: sbt ++${{matrix.scala}} coreJVM/test coreNative/test cliJVM/test coreJVM/mimaReportBinaryIssues
22+
- run: sbt +test +mimaReportBinaryIssues
23+
# use of an old sbt version, as a smoke test. only on 2.12.
24+
- run: sbt ++2.12.x 'set sbtplugin/scriptedSbt := "1.5.8"' 'sbtplugin/scripted sbt-mima-plugin/minimal'
25+
if: matrix.java == 8
2426

25-
sbtplugin:
26-
needs: core
27+
scripted:
28+
needs: test
2729
strategy:
2830
fail-fast: false
2931
matrix:
30-
include:
31-
- scala: 2.12.x
32-
java: 8
33-
- scala: 3.8.x
34-
java: 17
32+
java: [8, 17]
3533
runs-on: ubuntu-latest
3634
steps:
3735
- uses: actions/checkout@v6
@@ -41,11 +39,10 @@ jobs:
4139
java-version: ${{matrix.java}}
4240
cache: sbt
4341
- uses: sbt/setup-sbt@v1
44-
# set ThisBuild/scalaVersion because sbtplugin depends on core, but core stays on 2.12 with `++3.8.x`
45-
- run: sbt ++${{matrix.scala}} 'set ThisBuild/scalaVersion := (sbtplugin/scalaVersion).value' sbtplugin/mimaReportBinaryIssues sbtplugin/scripted
42+
- run: sbt +sbtplugin/scripted
4643

47-
testFunctional:
48-
needs: core
44+
functional-tests:
45+
needs: test
4946
strategy:
5047
fail-fast: false
5148
matrix:
@@ -59,10 +56,10 @@ jobs:
5956
java-version: 8
6057
cache: sbt
6158
- uses: sbt/setup-sbt@v1
62-
- run: sbt "functional-tests/runMain com.typesafe.tools.mima.lib.UnitTests -${{matrix.scala}}"
59+
- run: sbt ++2.12.x "functional-tests/runMain com.typesafe.tools.mima.lib.UnitTests -${{matrix.scala}}"
6360

64-
testIntegration:
65-
needs: core
61+
integration-tests:
62+
needs: test
6663
runs-on: ubuntu-latest
6764
steps:
6865
- uses: actions/checkout@v6
@@ -72,4 +69,4 @@ jobs:
7269
java-version: 8
7370
cache: sbt
7471
- uses: sbt/setup-sbt@v1
75-
- run: sbt integration-tests/test
72+
- run: sbt ++2.12.x integration-tests/test

.github/workflows/release.yml

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,12 @@ on:
44
push:
55
tags: ["*"]
66

7-
env:
8-
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
9-
PGP_SECRET: ${{ secrets.PGP_SECRET }}
10-
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
11-
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
12-
137
jobs:
14-
release-core-cli:
15-
strategy:
16-
fail-fast: false
17-
matrix:
18-
scala: [2.12.x, 2.13.x, 3.3.x]
19-
runs-on: ubuntu-latest
20-
steps:
21-
- uses: actions/checkout@v6
22-
with:
23-
fetch-depth: 0
24-
- uses: actions/setup-java@v5
25-
with:
26-
distribution: temurin
27-
java-version: 8
28-
cache: sbt
29-
- uses: sbt/setup-sbt@v1
30-
- run: sbt ++${{matrix.scala}} coreJVM/publishSigned coreNative/publishSigned cliJVM/publishSigned
31-
32-
release-sbtplugin:
8+
release:
339
strategy:
3410
fail-fast: false
3511
matrix:
36-
include:
37-
- scala: 2.12.x
38-
java: 8
39-
- scala: 3.8.x
40-
java: 17
12+
java: [8, 17]
4113
runs-on: ubuntu-latest
4214
steps:
4315
- uses: actions/checkout@v6
@@ -49,5 +21,9 @@ jobs:
4921
java-version: ${{matrix.java}}
5022
cache: sbt
5123
- uses: sbt/setup-sbt@v1
52-
# set ThisBuild/scalaVersion because sbtplugin depends on core, but core stays on 2.12 with `++3.8.x`
53-
- run: sbt ++${{matrix.scala}} 'set ThisBuild/scalaVersion := (sbtplugin/scalaVersion).value' sbtplugin/publishSigned
24+
- run: sbt ci-release
25+
env:
26+
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
27+
PGP_SECRET: ${{ secrets.PGP_SECRET }}
28+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
29+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}

build.sbt

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import mimabuild._
1+
import mimabuild.*
2+
3+
import scala.util.Properties
24

35
inThisBuild(Seq(
46
organization := "com.typesafe",
@@ -11,9 +13,18 @@ inThisBuild(Seq(
1113
),
1214
scmInfo := Some(ScmInfo(url("https://github.com/lightbend-labs/mima"), "scm:git:git@github.com:lightbend-labs/mima.git")),
1315
versionScheme := Some("early-semver"),
14-
scalaVersion := scala212,
1516
))
1617

18+
lazy val commonSettings: Seq[Setting[_]] = Seq(
19+
// in order to build `sbtplugin`, the `scalaVersion` of `core.jvm` has to match (2.12 or 3.8)
20+
scalaVersion := crossScalaVersions.value.headOption.getOrElse((LocalProject("sbtplugin") / scalaVersion).value),
21+
publish / skip := crossScalaVersions.value.isEmpty,
22+
publishLocal / skip := false, // sbtplugin/scripted requires publishLocal
23+
scalacOptions ++= compilerOptions(scalaVersion.value),
24+
)
25+
26+
def java8or17[T](if8: => T, if17: => T): T = if (Properties.isJavaAtLeast("17")) if17 else if8
27+
1728
def compilerOptions(scalaVersion: String): Seq[String] =
1829
Seq(
1930
"-feature",
@@ -36,23 +47,22 @@ def compilerOptions(scalaVersion: String): Seq[String] =
3647
// Keep in sync with TestCli
3748
val scala212 = "2.12.21"
3849
val scala213 = "2.13.18"
39-
val scala3 = "3.3.7" // keep at LTS
50+
val scala3_3 = "3.3.7" // keep at LTS
4051
val scala3_8 = "3.8.1" // keep at 3.8 for sbt 2 plugin
4152

42-
val root = project.in(file(".")).settings(
53+
val root = project.in(file(".")).settings(commonSettings).settings(
4354
name := "mima",
4455
crossScalaVersions := Nil,
4556
mimaFailOnNoPrevious := false,
46-
publish / skip := true,
4757
)
58+
4859
aggregateProjects(core.jvm, core.native, cli.jvm, sbtplugin, functionalTests, integrationTests)
4960

5061
val munit = Def.setting("org.scalameta" %%% "munit" % "1.2.2")
5162

52-
val core = crossProject(JVMPlatform, NativePlatform).crossType(CrossType.Pure).settings(
63+
val core = crossProject(JVMPlatform, NativePlatform).crossType(CrossType.Pure).settings(commonSettings).settings(
5364
name := "mima-core",
54-
crossScalaVersions ++= Seq(scala213, scala3),
55-
scalacOptions ++= compilerOptions(scalaVersion.value),
65+
crossScalaVersions := java8or17(Seq(scala212, scala213, scala3_3), Nil),
5666
libraryDependencies += munit.value % Test,
5767
MimaSettings.mimaSettings,
5868
apiMappings ++= {
@@ -69,28 +79,24 @@ val core = crossProject(JVMPlatform, NativePlatform).crossType(CrossType.Pure).s
6979

7080
val cli = crossProject(JVMPlatform)
7181
.crossType(CrossType.Pure)
82+
.settings(commonSettings)
7283
.settings(
7384
name := "mima-cli",
74-
crossScalaVersions ++= Seq(scala213, scala3),
75-
scalacOptions ++= compilerOptions(scalaVersion.value),
85+
crossScalaVersions := java8or17(Seq(scala212, scala213, scala3_3), Nil),
7686
libraryDependencies += munit.value % Test,
77-
MimaSettings.mimaSettings,
78-
// cli has no previous release,
79-
// but also we don't care about its binary compatibility as it's meant to be used standalone
80-
mimaPreviousArtifacts := Set.empty
87+
mimaFailOnNoPrevious := false,
8188
)
8289
.dependsOn(core)
8390

84-
val sbtplugin = project.enablePlugins(SbtPlugin).dependsOn(core.jvm).settings(
91+
val sbtplugin = project.enablePlugins(SbtPlugin).dependsOn(core.jvm).settings(commonSettings).settings(
8592
name := "sbt-mima-plugin",
86-
crossScalaVersions ++= Seq(scala3_8),
93+
crossScalaVersions := java8or17(Seq(scala212), Seq(scala3_8)),
8794
(pluginCrossBuild / sbtVersion) := {
8895
scalaBinaryVersion.value match {
8996
case "2.12" => "1.5.8"
9097
case _ => "2.0.0-RC9"
9198
}
9299
},
93-
scalacOptions ++= compilerOptions(scalaVersion.value),
94100
// drop the previous value to drop running Test/compile
95101
scriptedDependencies := Def.task(()).dependsOn(publishLocal, core.jvm / publishLocal).value,
96102
scriptedLaunchOpts += s"-Dplugin.version=${version.value}",
@@ -104,26 +110,26 @@ val sbtplugin = project.enablePlugins(SbtPlugin).dependsOn(core.jvm).settings(
104110
val testFunctional = taskKey[Unit]("Run the functional test")
105111
val functionalTests = Project("functional-tests", file("functional-tests"))
106112
.dependsOn(core.jvm)
113+
.settings(commonSettings)
107114
.settings(
108-
crossScalaVersions += scala213,
115+
crossScalaVersions := java8or17(Seq(scala212, scala213), Nil),
116+
publish / skip := true,
109117
libraryDependencies += "io.get-coursier" %% "coursier" % "2.1.24",
110118
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value,
111119
libraryDependencies += munit.value,
112-
scalacOptions ++= compilerOptions(scalaVersion.value),
113120
testFunctional := (Test / test).value,
114121
Test / mainClass := Some("com.typesafe.tools.mima.lib.UnitTests"),
115122
mimaFailOnNoPrevious := false,
116-
publish / skip := true,
117123
)
118124

119125
val integrationTests = Project("integration-tests", file("integration-tests"))
120126
.dependsOn(functionalTests % "compile->compile")
127+
.settings(commonSettings)
121128
.settings(
122-
crossScalaVersions += scala213,
129+
crossScalaVersions := java8or17(Seq(scala212, scala213), Nil),
130+
publish / skip := true,
123131
libraryDependencies += munit.value,
124-
scalacOptions ++= compilerOptions(scalaVersion.value),
125132
Test / unmanagedSourceDirectories := Seq((functionalTests / baseDirectory).value / "src" / "it" / "scala"),
126133
Test / testOptions += Tests.Argument(TestFrameworks.MUnit, "-b"), // disable buffering => immediate output
127134
mimaFailOnNoPrevious := false,
128-
publish / skip := true,
129135
)

0 commit comments

Comments
 (0)