-
Notifications
You must be signed in to change notification settings - Fork 22
Test Scala 3 support using sbt-projectmatrix #179
Changes from all commits
8b08f4c
2fb596f
71a5b9b
af681b4
dbab6b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,9 +10,9 @@ jobs: | |
- uses: olafurpg/setup-scala@v11 | ||
- uses: coursier/cache-action@v6 | ||
- name: Lint | ||
run: sbt scalafmtCheckAll "rules/scalafix --check" | ||
run: sbt scalafmtCheckAll "rules2_12/scalafix --check" | ||
- name: Test | ||
run: sbt coverage +tests/test +rules/coverageReport | ||
run: sbt coverage tests/test coverageAggregate | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
- uses: codecov/codecov-action@v1 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
lazy val v = _root_.scalafix.sbt.BuildInfo | ||
|
||
lazy val rulesCrossVersions = Seq(v.scala213, v.scala212, v.scala211) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FTR, we might cross-build scalafix & rules to Scala3 in the future, but for the moment it's not a priority as the vast majority of the rules don't need to match the sources they are fixing - see scalacenter/scalafix#1316 & scalacenter/sbt-scalafix#214. |
||
lazy val scala3Version = "3.0.0" | ||
|
||
inThisBuild( | ||
List( | ||
organization := "com.github.liancheng", | ||
|
@@ -13,81 +16,146 @@ inThisBuild( | |
url("https://github.com/liancheng") | ||
) | ||
), | ||
scalaVersion := v.scala212, | ||
crossScalaVersions := List(v.scala211, v.scala212, v.scala213), | ||
scalacOptions ++= List( | ||
"-deprecation", | ||
"-Yrangepos", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
"-P:semanticdb:synthetics:on" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this wasn't useful (nor documented) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess scalac-semanticdb does not honor the documented default of false as synthestics are present without this on Scala 2.
|
||
), | ||
conflictManager := ConflictManager.strict, | ||
dependencyOverrides ++= List( | ||
"org.scala-lang.modules" %% "scala-xml" % "1.2.0", | ||
"org.slf4j" % "slf4j-api" % "1.7.25", | ||
"com.lihaoyi" %% "sourcecode" % "0.2.1", | ||
"org.scala-lang.modules" %% "scala-collection-compat" % "2.1.6" | ||
"-deprecation" | ||
), | ||
addCompilerPlugin(scalafixSemanticdb), | ||
semanticdbEnabled := true, | ||
// semanticdbTargetRoot makes it hard to have several input modules | ||
semanticdbIncludeInJar := true, | ||
semanticdbVersion := scalafixSemanticdb.revision, | ||
scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.5.0", | ||
// Super shell output often messes up Scalafix test output. | ||
useSuperShell := false | ||
) | ||
) | ||
|
||
skip in publish := true | ||
|
||
lazy val rules = project | ||
lazy val `scalafix-organize-imports` = project | ||
.in(file(".")) | ||
.aggregate( | ||
rules.projectRefs ++ | ||
input.projectRefs ++ | ||
output.projectRefs ++ | ||
tests.projectRefs: _* | ||
) | ||
Comment on lines
+34
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. required with https://github.com/sbt/sbt-projectmatrix to keep aggregation working (for |
||
.settings( | ||
publish / skip := true | ||
) | ||
lazy val rules = projectMatrix | ||
.settings( | ||
moduleName := "organize-imports", | ||
dependencyOverrides += "com.lihaoyi" %% "sourcecode" % "0.2.1", | ||
conflictManager := ConflictManager.strict, | ||
dependencyOverrides ++= List( | ||
"org.scala-lang.modules" %% "scala-collection-compat" % "2.1.6", | ||
"com.lihaoyi" %% "sourcecode" % "0.2.1" | ||
), | ||
libraryDependencies += "ch.epfl.scala" %% "scalafix-core" % v.scalafixVersion, | ||
scalacOptions ++= List("-Ywarn-unused"), | ||
scalafixOnCompile := true | ||
) | ||
.defaultAxes(VirtualAxis.jvm) | ||
.jvmPlatform(rulesCrossVersions) | ||
|
||
lazy val shared = project.settings(skip in publish := true) | ||
lazy val shared = projectMatrix | ||
.settings( | ||
publish / skip := true, | ||
coverageEnabled := false | ||
) | ||
.defaultAxes(VirtualAxis.jvm) | ||
.jvmPlatform(scalaVersions = rulesCrossVersions :+ scala3Version) | ||
|
||
lazy val input = project | ||
lazy val input = projectMatrix | ||
.dependsOn(shared) | ||
.settings(skip in publish := true) | ||
.settings( | ||
publish / skip := true, | ||
coverageEnabled := false | ||
) | ||
.defaultAxes(VirtualAxis.jvm) | ||
.jvmPlatform(scalaVersions = rulesCrossVersions :+ scala3Version) | ||
|
||
lazy val output = project | ||
lazy val output = projectMatrix | ||
.dependsOn(shared) | ||
.settings(skip in publish := true) | ||
.settings( | ||
publish / skip := true, | ||
coverageEnabled := false | ||
) | ||
.defaultAxes(VirtualAxis.jvm) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's pity that the default it's not |
||
.jvmPlatform(scalaVersions = rulesCrossVersions :+ scala3Version) | ||
|
||
lazy val inputUnusedImports = project | ||
lazy val inputUnusedImports = projectMatrix | ||
.dependsOn(shared) | ||
.settings( | ||
skip in publish := true, | ||
publish / skip := true, | ||
coverageEnabled := false, | ||
scalacOptions += { | ||
if (scalaVersion.value.startsWith("2.11.")) | ||
"-Ywarn-unused-import" | ||
else | ||
"-Ywarn-unused" | ||
} | ||
) | ||
.defaultAxes(VirtualAxis.jvm) | ||
.jvmPlatform(scalaVersions = rulesCrossVersions :+ scala3Version) | ||
|
||
lazy val tests = project | ||
lazy val testsAggregate = Project("tests", file("target/testsAggregate")) | ||
.aggregate(tests.projectRefs: _*) | ||
Comment on lines
+99
to
+100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aggregation dummy project to maintain backward compatibility on CI statements and for convenience for |
||
|
||
lazy val tests = projectMatrix | ||
.dependsOn(rules) | ||
.enablePlugins(ScalafixTestkitPlugin) | ||
.settings( | ||
skip in publish := true, | ||
scalacOptions ++= List("-Ywarn-unused"), | ||
publish / skip := true, | ||
coverageEnabled := false, | ||
libraryDependencies += | ||
"ch.epfl.scala" % "scalafix-testkit" % v.scalafixVersion % Test cross CrossVersion.full, | ||
(compile in Compile) := (compile in Compile) | ||
.dependsOn( | ||
compile in (input, Compile), | ||
compile in (inputUnusedImports, Compile) | ||
) | ||
.value, | ||
scalafixTestkitOutputSourceDirectories := sourceDirectories.in(output, Compile).value, | ||
scalafixTestkitInputSourceDirectories := ( | ||
sourceDirectories.in(input, Compile).value ++ | ||
sourceDirectories.in(inputUnusedImports, Compile).value | ||
), | ||
scalafixTestkitInputClasspath := ( | ||
fullClasspath.in(input, Compile).value ++ | ||
fullClasspath.in(inputUnusedImports, Compile).value | ||
).distinct | ||
scalafixTestkitOutputSourceDirectories := | ||
TargetAxis.resolve(output, Compile / unmanagedSourceDirectories).value, | ||
scalafixTestkitInputSourceDirectories := { | ||
val inputSrc = TargetAxis.resolve( | ||
input, | ||
Compile / unmanagedSourceDirectories | ||
).value | ||
val inputUnusedImportsSrc = TargetAxis.resolve( | ||
inputUnusedImports, | ||
Compile / unmanagedSourceDirectories | ||
).value | ||
inputSrc ++ inputUnusedImportsSrc | ||
}, | ||
scalafixTestkitInputClasspath := { | ||
val inputClasspath = TargetAxis.resolve( | ||
input, | ||
Compile / fullClasspath | ||
).value | ||
val inputUnusedImportsClasspath = TargetAxis.resolve( | ||
inputUnusedImports, | ||
Compile / fullClasspath | ||
).value | ||
inputClasspath ++ inputUnusedImportsClasspath | ||
}, | ||
scalafixTestkitInputScalacOptions := | ||
TargetAxis.resolve(inputUnusedImports, Compile / scalacOptions).value, | ||
scalafixTestkitInputScalaVersion := | ||
TargetAxis.resolve(inputUnusedImports, Compile / scalaVersion).value | ||
) | ||
.defaultAxes( | ||
rulesCrossVersions.map(VirtualAxis.scalaABIVersion) :+ VirtualAxis.jvm: _* | ||
) | ||
.customRow( | ||
scalaVersions = Seq(v.scala212), | ||
axisValues = Seq(TargetAxis(scala3Version), VirtualAxis.jvm), | ||
settings = Seq() | ||
) | ||
.customRow( | ||
scalaVersions = Seq(v.scala213), | ||
axisValues = Seq(TargetAxis(v.scala213), VirtualAxis.jvm), | ||
settings = Seq() | ||
) | ||
.customRow( | ||
scalaVersions = Seq(v.scala212), | ||
axisValues = Seq(TargetAxis(v.scala212), VirtualAxis.jvm), | ||
settings = Seq() | ||
) | ||
.customRow( | ||
scalaVersions = Seq(v.scala211), | ||
axisValues = Seq(TargetAxis(v.scala211), VirtualAxis.jvm), | ||
settings = Seq() | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a no-op against master as
rules/scalafix
is running with the defaultscalaVersion
there - namely 2.12