-
Notifications
You must be signed in to change notification settings - Fork 22
Test Scala 3 support using sbt-projectmatrix #179
Conversation
9f677e2
to
40d8a32
Compare
7fc599c
to
795ff11
Compare
I will rework this against scalacenter/sbt-scalafix#219 once it's merged, as most of the quirks have been abstracted there. |
21e5ede
to
2032a12
Compare
@@ -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 comment
The 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.
scalacOptions ++= List( | ||
"-deprecation", | ||
"-Yrangepos", | ||
"-P:semanticdb:synthetics:on" |
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 wasn't useful (nor documented)
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.
I guess scalac-semanticdb does not honor the documented default of false as synthestics are present without this on Scala 2.
~/git/projects/scalafix-organize-imports$ metap ./input/target/scala-2.12/classes/META-INF/semanticdb/input/src/main/scala/fix/ExplicitlyImportedImplicits.scala.semanticdb | tail -n3
Synthetics:
[14:2..14:6) => *(intImplicit)
[15:2..15:6) => *(stringImplicit)
build.sbt
Outdated
), | ||
conflictManager := ConflictManager.strict, | ||
// conflictManager := ConflictManager.strict, |
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.
[error] (shared3 / update) lmcoursier.internal.shaded.coursier.error.conflict.StrictRule: Rule Strict(Set(ModuleMatcher(*:*)), Set(), false, true, false) not satisfied: lmcoursier.internal.shaded.coursier.params.rule.Strict$EvictedDependencies: Unsatisfied rule Strict(*:*): Found evicted dependencies:
[error]
[error] org.jsoup:jsoup:1.13.1 (1.10.2 wanted)
[error] └─ com.vladsch.flexmark:flexmark-html-parser:0.42.12 wants org.jsoup:jsoup:1.10.2
[error] └─ org.scala-lang:scaladoc_3:3.0.0
[error]
[error] org.jsoup:jsoup:1.13.1 (1.7.2 wanted)
[error] └─ nl.big-o:liqp:0.6.7 wants org.jsoup:jsoup:1.7.2
[error] └─ org.scala-lang:scaladoc_3:3.0.0
[error]
[error] org.antlr:antlr-runtime:3.5.1 (3.5 wanted)
[error] └─ org.antlr:ST4:4.0.7 wants org.antlr:antlr-runtime:3.5
[error] └─ org.antlr:antlr:3.5.1
[error] └─ nl.big-o:liqp:0.6.7
[error] └─ org.scala-lang:scaladoc_3:3.0.0
[error]
[error] com.fasterxml.jackson.core:jackson-core:2.9.8 (2.2.3 wanted)
[error] └─ com.fasterxml.jackson.core:jackson-databind:2.2.3 wants com.fasterxml.jackson.core:jackson-core:2.2.3
[error] └─ nl.big-o:liqp:0.6.7
[error] └─ org.scala-lang:scaladoc_3:3.0.0
[error]
[error] com.fasterxml.jackson.core:jackson-core:2.9.8 (2.2.3 wanted)
[error] └─ nl.big-o:liqp:0.6.7 wants com.fasterxml.jackson.core:jackson-core:2.2.3
[error] └─ org.scala-lang:scaladoc_3:3.0.0
can you advise on your policy to handle this?
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.
I usually just try to pick the newest version when possible.
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.
Actually, I wonder if the conflict manager should only be set on rules
since that's where it matters?
This is a failure in shared
not related to scalafix bump, but to the cross-building to Scala 3. It seems to come from org.scala-lang:scala3-library_3:3.0.0
itself as it brings inconsistent transitive dependencies, and I am not sure it's relevant to silence this in this project?
# https://get-coursier.io/docs/cli-installation
$ cs resolve -t org.scala-lang:scaladoc_3:3.0.0 | grep incompatibility
Result:
│ └─ org.jsoup:jsoup:1.10.2 -> 1.13.1 (possible incompatibility)
│ ├─ com.fasterxml.jackson.core:jackson-core:2.2.3 -> 2.9.8 (possible incompatibility)
│ │ └─ com.fasterxml.jackson.core:jackson-core:2.2.3 -> 2.9.8 (possible incompatibility)
│ └─ org.jsoup:jsoup:1.7.2 -> 1.13.1 (possible incompatibility)
Or maybe we should report upstream?
Scalafix 0.9.28 with proper support for Scala 3 in testing will be released tomorrow, but this builds against a master immutable SNAPSHOT, so it's ready for review. |
.aggregate( | ||
rules.projectRefs ++ | ||
input.projectRefs ++ | ||
output.projectRefs ++ | ||
tests.projectRefs: _* | ||
) |
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.
required with https://github.com/sbt/sbt-projectmatrix to keep aggregation working (for scalafmtAll
for example)
c8942f6
to
70b8db1
Compare
lazy val testsAggregate = Project("tests", file("target/testsAggregate")) | ||
.aggregate(tests.projectRefs: _*) |
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.
Aggregation dummy project to maintain backward compatibility on CI statements and for convenience for sbt ~tests/test
abc77aa
to
8c4ff44
Compare
Codecov Report
@@ Coverage Diff @@
## master #179 +/- ##
==========================================
- Coverage 91.63% 91.01% -0.63%
==========================================
Files 4 4
Lines 263 267 +4
Branches 12 14 +2
==========================================
+ Hits 241 243 +2
- Misses 22 24 +2
Continue to review full report at Codecov.
|
a843e90
to
6762446
Compare
Hey @bjaglin, thanks a bunch for working on this! Honestly, I don't have enough context or confidence to review this PR, so please feel free to nominate other reviewers you believe are suitable. I'm happy to help merge this PR when you think it's ready. One feedback from me is that it would be great if you can provide a summary of end-user-facing changes introduced by this PR, and follow-up work needed to get better Scala 3 support (e.g., support for |
@mlachkar, can you have a look?
Good point, before merging this, I am planning to
|
@bjaglin, the Codecov failure is cosmetic. The test coverage drop is less than 1% and can be ignored. I can tune Codecov GitHub check threshold to get rid of it. But we don't necessarily need to block on this. I'm OK with merging this PR before getting this addressed. |
I tried to release it locally and run within Metals, but getting:
Should it work with Scalafix 0.9.29 ? |
scalafix-organize-imports 0.5.0 should work with Scalafix 0.9.28+ - this PR is just about testing that it works (and providing a proper error or fixing the few cases where it does not). The problem is that Metals tries to classload Scalafix with the same binary version as the project sources, and as discussed in scalacenter/scalafix#1316, cross-building scalafix-core and rules against 3.0 is only the end goal. For now, you should classload 2.12 or 2.13, indifferently. The reason for classloading a matching scala binary version was for the built-in rule using the presentation compiler ( |
Och, I totally missed that. It does actually work for Scala 3 if I use 2.13 binary version for it. Thanks! I think we can do with that for the time being, since we don't yet support any other rules. |
Got it working! scalameta/metals#2857 |
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 PR adds tests for scala 3, and doesn't impacts the scala 2 behavior of this rule.
I think it's nice to have tests for scala 3, but we can maybe add some documentation as mentioned by @bjaglin to explain what won't work (ie removeUnusued.)
publish / skip := true, | ||
coverageEnabled := false | ||
) | ||
.defaultAxes(VirtualAxis.jvm) |
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.
It's pity that the default it's not VirtualAxis.jvm
: so we wouldn't need to specify it everytime
* Check Scala 2.x input/output with Scala 2.x rule (as before) * Check Scala 3 input/output with Scala 2.12 rule * Disable coverage (even after `coverage` command) on input/output projects as scoverage is not available in Scala 3 and coverage there is not useful there anyway * Limit strict conflictManager to rules to workaround false positives caused by org.scala-lang:scaladoc_3:3.0.0
@liancheng I rebased against master but there is still something fishy in the |
I finally got the time to look into the failures, and document them as known limitations - see the last 3 commits separately. @liancheng I suggest we merge this to unlock iterating in other PRs, what do you think? |
@bjaglin Sorry for the late response, daily workload fell into hell mode recently... I'm merging this PR. Thanks for the awesome work! |
Towards #178
See scalacenter/scalafix.g8#19 for a background on the preliminary commits
This does not add nor fix any Scala 3 behavior (apart from some error handling), which means existing versions of
OrganizeImports
should work out of the box once sbt-scalafix & scalafix 0.9.28 are out, thanks to the amazing work of scalameta & dotty maintainers!This PR does ensures through testing that it works for the vast majority of the use cases (limited to the Scala 2 dialect / features obviously). Apart from the expected failures of the
RemoveUnused
tests, only 2 were failing - I disabled them for now by moving them toscala-2
. It's likely that the bugs should be reported in scalameta.Note that it should be trivial to start dropping new input/output tests into
scala-3
folders after this is merged.Impact of using sbt-projectmatrix