Skip to content

Commit

Permalink
Merge pull request #412 from bjaglin/dropsbt13
Browse files Browse the repository at this point in the history
drop sbt 1.3.x support & speedup CI by parallelizing scripted
  • Loading branch information
bjaglin authored Sep 23, 2024
2 parents 6498424 + 8a264aa commit 112e9a5
Show file tree
Hide file tree
Showing 49 changed files with 32 additions and 43 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
- uses: coursier/setup-action@v1
with:
jvm: temurin:8
- run: rm -rf src/sbt-test/skip-sbt1.4
- run: sbt test scripted
jdk11:
name: JDK11 tests
Expand All @@ -22,6 +23,7 @@ jobs:
- uses: coursier/setup-action@v1
with:
jvm: temurin:11
- run: rm -rf src/sbt-test/skip-sbt1.4
- run: sbt test scripted
jdk17:
name: JDK17 tests
Expand All @@ -31,7 +33,10 @@ jobs:
- uses: coursier/setup-action@v1
with:
jvm: temurin:17
- run: sbt "test; scripted sbt-*/* skip-windows/*"
- run: rm -rf src/sbt-test/skip-java17+
- run: rm -rf src/sbt-test/skip-sbt1.4
- run: sbt test scripted

jdk21:
name: JDK21 tests
runs-on: ubuntu-latest
Expand All @@ -40,14 +45,17 @@ jobs:
- uses: coursier/setup-action@v1
with:
jvm: temurin:21
- run: sbt "test; scripted sbt-scalafix/* skip-windows/*"
- run: rm -rf src/sbt-test/skip-java17+
- run: sbt test scripted
windows:
name: Windows tests
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: coursier/setup-action@v1
- run: sbt ci-windows
- run: rm -r -fo src\sbt-test\skip-sbt1.4
- run: rm -r -fo src\sbt-test\skip-windows
- run: sbt test-skip-windows scripted
shell: bash
checks:
name: Scalafmt
Expand Down
9 changes: 5 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ developers := List(
)
)

commands += Command.command("ci-windows") { s =>
commands += Command.command("test-skip-windows") { s =>
"testOnly -- -l SkipWindows" ::
"scripted sbt-*/*" ::
s
}

Expand All @@ -48,15 +47,15 @@ libraryDependencies ++= List(
scalaVersion := "2.12.20"

// keep this as low as possible to avoid running into binary incompatibility such as https://github.com/sbt/sbt/issues/5049
pluginCrossBuild / sbtVersion := "1.3.1"
pluginCrossBuild / sbtVersion := "1.4.0"

scriptedSbt := {
val jdk = System.getProperty("java.specification.version").toDouble

if (jdk >= 21)
"1.9.0" // first release that supports JDK21
else
"1.3.3" // get https://github.com/sbt/sbt/issues/1673 to avoid race conditions
(pluginCrossBuild / sbtVersion).value
}

libraryDependencies += compilerPlugin(scalafixSemanticdb)
Expand All @@ -73,6 +72,8 @@ scalacOptions ++= List(
enablePlugins(ScriptedPlugin)
sbtPlugin := true
scriptedBufferLog := false
scriptedBatchExecution := true
scriptedParallelInstances := 2
scriptedLaunchOpts ++= Seq(
"-Xmx2048M",
s"-Dplugin.version=${version.value}",
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/sbt/internal/sbtscalafix/JLineAccess.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package sbt.internal.sbtscalafix

/** Helper class to access sbt's JLine instance */
object JLineAccess {
def terminalWidth: Int = sbt.internal.util.JLine.usingTerminal(_.getWidth)
def terminalWidth: Int = sbt.internal.util.Terminal.get.getWidth
}
8 changes: 1 addition & 7 deletions src/main/scala/scalafix/sbt/ScalafixEnable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,7 @@ object ScalafixEnable {
)
}
}
} ++ Seq(
semanticdbEnabled := true,
// support sbt 1.3.[0-3] which does not contain
// https://github.com/sbt/sbt/pull/5202
(semanticdbCompilerPlugin := semanticdbCompilerPlugin.value
.withRevision((semanticdbVersion).value))
)
} :+ (semanticdbEnabled := true)
settings <-
inScope(ThisScope.copy(project = Select(project.ref)))(
scalacOptionsSettings ++ enableSemanticdbPlugin
Expand Down
31 changes: 11 additions & 20 deletions src/main/scala/scalafix/sbt/ScalafixPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,7 @@ object ScalafixPlugin extends AutoPlugin {
Def.settings(
Defaults.configSettings,
sourcesInBase := false,
// local copy of https://github.com/sbt/sbt/blob/e4231ac03903e174bc9975ee00d34064a1d1f373/main/src/main/scala/sbt/Keys.scala#L400
// so that it does not break on sbt version below 1.4.0
SettingKey[Boolean]("bspEnabled") := false
bspEnabled := false
)
),
update := {
Expand Down Expand Up @@ -657,11 +655,11 @@ object ScalafixPlugin extends AutoPlugin {
): Unit = implicitly[JsonWriter[A]].write(obj, builder)
}

// we actually don't need to read anything back, see https://github.com/sbt/sbt/pull/5513
// implicit conversion of collection is only available on JsonFormat
implicit val argFormat = liftFormat(argWriter)

def diffWithPreviousRuns[T](f: (Boolean, Set[File]) => T): T = {
val tracker = Tracked.inputChanged(streams.cacheDirectory / "args") {
val tracker = Tracked.inputChangedW(streams.cacheDirectory / "args") {
(argsChanged: Boolean, _: Seq[Arg.CacheKey]) =>
val targets = paths.map(_.toFile).toSet

Expand Down Expand Up @@ -740,21 +738,14 @@ object ScalafixPlugin extends AutoPlugin {
shellArgs: ShellArgs,
config: ConfigKey
): Def.Initialize[Task[Seq[Path]]] =
Def.taskDyn {
// Dynamic task to avoid redundantly computing `unmanagedSources.value`
if (shellArgs.files.nonEmpty) {
Def.task {
shellArgs.files.map(file(_).toPath)
}
} else {
Def.task {
for {
source <- (config / scalafix / unmanagedSources).value
if source.exists()
if isScalaFile(source)
} yield source.toPath
}
}
Def.taskIf {
if (shellArgs.files.nonEmpty) shellArgs.files.map(file(_).toPath)
else
for {
source <- (config / scalafix / unmanagedSources).value
if source.exists()
if isScalaFile(source)
} yield source.toPath
}

private[sbt] val relaxScalacOptionsConfigSettings: Seq[Def.Setting[_]] =
Expand Down
1 change: 0 additions & 1 deletion src/sbt-test/sbt-1.4/build-lint/project/build.properties

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion src/sbt-test/sbt-1.5/scala-3/build.sbt

This file was deleted.

1 change: 0 additions & 1 deletion src/sbt-test/sbt-1.5/scala-3/project/build.properties

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion src/sbt-test/sbt-1.5/testkit/project/build.properties

This file was deleted.

File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/sbt-test/skip-sbt1.4/scala-3/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scalaVersion := "3.3.1"
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ lazy val scala212 = project
lazy val scala3 = project
.in(file("scala3"))
.settings(
scalaVersion := "3.0.0-RC3" // built-in support for semanticdb
scalaVersion := "3.3.1" // built-in support for semanticdb
)
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
lazy val V = _root_.scalafix.sbt.BuildInfo

lazy val rulesCrossVersions = Seq(V.scala213, V.scala212)
lazy val scala3Version = "3.0.0"
lazy val scala3Version = "3.3.1"

inThisBuild(
List(
Expand Down
File renamed without changes.

0 comments on commit 112e9a5

Please sign in to comment.