Skip to content

Commit

Permalink
Fix compiler bridge build setup and build essential versions in CI (#…
Browse files Browse the repository at this point in the history
…3179)

Fixed the build setup to build compiler brigdes. There were missing
dependencies. I added all transitive dependencies of the source package
to the compile classpath.

Also extended the CI setup to build essential compiler bridges with each
CI run to detect any issues as early as possible.

Fix #2576

Pull request: #3179
  • Loading branch information
lefou authored May 22, 2024
1 parent cfe3df7 commit 2bb9c12
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 23 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ jobs:
./mill -i -k __.ivyDepsTree
./mill -i -k __.ivyDepsTree --withRuntime
uses: ./.github/workflows/run-mill-action.yml
with:
java-version: ${{ matrix.java-version }}
Expand Down Expand Up @@ -86,11 +85,19 @@ jobs:
- java-version: 17
millargs: docs.githubPages


uses: ./.github/workflows/run-mill-action.yml
with:
java-version: ${{ matrix.java-version }}
millargs: ${{ matrix.millargs }}

compiler-bridge:
uses: ./.github/workflows/run-mill-action.yml
with:
java-version: '8'
millargs: bridge.__.publishLocal
env-bridge-versions: 'essential'

format-check:
uses: ./.github/workflows/run-mill-action.yml
with:
Expand Down Expand Up @@ -145,7 +152,7 @@ jobs:
publish-sonatype:
# when in master repo, publish all tags and manual runs on main
if: github.repository == 'com-lihaoyi/mill' && (startsWith( github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch' ) )
needs: [linux, windows, format-check, bincompat-check, scalafix-check, itest]
needs: [linux, windows, compiler-bridge, format-check, bincompat-check, scalafix-check, itest]

runs-on: ubuntu-latest

Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/run-mill-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@ on:
timeout-minutes:
default: 90
type: number
env-bridge-versions:
default: 'none'
type: string

jobs:
build:

runs-on: ${{ inputs.os }}
continue-on-error: ${{ inputs.continue-on-error }}
timeout-minutes: ${{ inputs.timeout-minutes }}
env:
MILL_COMPILER_BRIDGE_VERSIONS: ${{ inputs.env-bridge-versions }}

steps:
- uses: actions/checkout@v4
Expand Down
45 changes: 24 additions & 21 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ object Deps {
val jarjarabrams = ivy"com.eed3si9n.jarjarabrams::jarjar-abrams-core:1.14.0"
val requests = ivy"com.lihaoyi::requests:0.8.2"


/** Used to manage transitive versions. */
val transitiveDeps = Seq(
ivy"org.apache.ant:ant:1.10.14",
Expand Down Expand Up @@ -236,10 +235,13 @@ def millBinPlatform: T[String] = T {

def baseDir = build.millSourcePath

val essentialBridgeScalaVersions =
Seq(Deps.scalaVersion, Deps.scalaVersionForScoverageWorker1, Deps.workerScalaVersion212)
// published compiler bridges
val bridgeScalaVersions = Seq(
// Our version of Zinc doesn't work with Scala 2.12.0 and 2.12.4 compiler
// bridges. We skip 2.12.1 because it's so old not to matter, and we need a
// non-supported scala versionm for testing purposes. We skip 2.13.0-2 because
// non-supported scala version for testing purposes. We skip 2.13.0-2 because
// scaladoc fails on windows
/*"2.12.0",*/ /*2.12.1",*/ "2.12.2",
"2.12.3", /*"2.12.4",*/ "2.12.5",
Expand All @@ -257,7 +259,8 @@ val bridgeScalaVersions = Seq(
"2.12.17",
"2.12.18",
"2.12.19",
/*"2.13.0", "2.13.1", "2.13.2",*/ "2.13.3",
/*"2.13.0", "2.13.1", "2.13.2",*/
"2.13.3",
"2.13.4",
"2.13.5",
"2.13.6",
Expand All @@ -277,9 +280,10 @@ val bridgeScalaVersions = Seq(
// if given.
val compilerBridgeScalaVersions =
interp.watchValue(sys.env.get("MILL_COMPILER_BRIDGE_VERSIONS")) match {
case None => Seq.empty[String]
case Some("all") => bridgeScalaVersions
case Some(versions) => versions.split(',').map(_.trim).toSeq
case None | Some("") | Some("none") => Seq.empty[String]
case Some("all") => (essentialBridgeScalaVersions ++ bridgeScalaVersions).distinct
case Some("essential") => essentialBridgeScalaVersions
case Some(versions) => versions.split(',').map(_.trim()).filterNot(_.isEmpty).toSeq
}
val bridgeVersion = "0.0.1"

Expand Down Expand Up @@ -525,7 +529,8 @@ trait BridgeModule extends MillPublishJavaModule with CrossScalaModule {
def pomSettings = commonPomSettings(artifactName())
def crossFullScalaVersion = true
def ivyDeps = Agg(
ivy"org.scala-sbt:compiler-interface:${Versions.zinc}",
ivy"org.scala-sbt:compiler-interface:${Deps.zinc.version}",
ivy"org.scala-sbt:util-interface:${Deps.zinc.version}",
ivy"org.scala-lang:scala-compiler:${crossScalaVersion}"
)

Expand All @@ -534,23 +539,21 @@ trait BridgeModule extends MillPublishJavaModule with CrossScalaModule {
Seq(PathRef(T.dest))
}

def generatedSources = T {
import mill.scalalib.api.ZincWorkerUtil.{grepJar, scalaBinaryVersion}
val resolvedJars = resolveDeps(
T.task {
Agg(ivy"org.scala-sbt::compiler-bridge:${Deps.zinc.dep.version}").map(bindDependency())
},
def compilerBridgeIvyDeps: T[Agg[Dep]] = Agg(
ivy"org.scala-sbt::compiler-bridge:${Deps.zinc.version}".exclude("*" -> "*")
)

def compilerBridgeSourceJars: T[Agg[PathRef]] = T {
resolveDeps(
T.task { compilerBridgeIvyDeps().map(bindDependency()) },
sources = true
)()
}

val bridgeJar = grepJar(
resolvedJars,
s"compiler-bridge_${scalaBinaryVersion(scalaVersion())}",
Deps.zinc.dep.version,
true
)

mill.api.IO.unpackZip(bridgeJar.path, os.rel)
def generatedSources = T {
compilerBridgeSourceJars().foreach { jar =>
mill.api.IO.unpackZip(jar.path, os.rel)
}

Seq(PathRef(T.dest))
}
Expand Down

0 comments on commit 2bb9c12

Please sign in to comment.