Skip to content

Commit

Permalink
Use .local integration tests in windows CI (com-lihaoyi#4299)
Browse files Browse the repository at this point in the history
- Need to move from `temurin:17` to `zulu:17` to get things working on
my windows-arm laptop (temurin did not back-publish older JVMs for
windows-arm)

- Get rid of the custom `pathingJar` we defined in `dist/package.mill`
(using custom path rendering) which doesn't seem to work, in exchange
for the default `Jvm.createClasspathPassingJar` (using path-as-url
rendering) that does seem to work

- Make `def launcher` make use of `runUseArgsFile` similarly to the
various `run` tasks

- Make the integration tests use the `./mill.bat` launcher on windows,
rather than `./mill` as a shell script, as the shell script doesn't seem
to work properly when used in a windows environment
  • Loading branch information
lihaoyi authored Jan 13, 2025
1 parent 83998a5 commit 570a262
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ jobs:
millargs: '"{main,scalalib,bsp}.__.test"'

- java-version: 11
millargs: '"example.scalalib.{basic,publishing}.__.packaged.fork.test"'
millargs: '"example.scalalib.{basic,publishing}.__.local.fork.test"'

- java-version: 17
millargs: "'integration.{feature,failure}.__.packaged.fork.test'"
Expand Down
2 changes: 1 addition & 1 deletion .mill-jvm-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
temurin:17.0.6
zulu:17.0.13
24 changes: 4 additions & 20 deletions dist/package.mill
Original file line number Diff line number Diff line change
Expand Up @@ -165,31 +165,15 @@ object `package` extends RootModule with InstallModule {
os.write(vmOptionsFile, millOptionsContent)
val jvmArgs = otherArgs ++ List(s"-DMILL_OPTIONS_PATH=$vmOptionsFile")
val classpath = runClasspath().map(_.path.toString)
val classpathJar = Task.dest / "classpath.jar"
Jvm.createClasspathPassingJar(classpathJar, runClasspath().map(_.path))

launcherScript(
jvmArgs,
jvmArgs,
classpath,
Agg(pathingJar().path.toString) // TODO not working yet on Windows! see #791
)
}

def pathingJar = Task {
// see http://todayguesswhat.blogspot.com/2011/03/jar-manifestmf-class-path-referencing.html
// for more detailed explanation
val isWin = scala.util.Properties.isWin
val classpath = runClasspath().map { pathRef =>
val path =
if (isWin) "/" + pathRef.path.toString.replace("\\", "/")
else pathRef.path.toString
if (path.endsWith(".jar")) path
else path + "/"
}.mkString(" ")
val manifestEntries = Map[String, String](
java.util.jar.Attributes.Name.MANIFEST_VERSION.toString -> "1.0",
"Created-By" -> "Scala mill",
"Class-Path" -> classpath
Agg(classpathJar.toString()) // TODO not working yet on Windows! see #791
)
Jvm.createJar(Agg(), JarManifest(manifestEntries))
}

def run(args: Task[Args] = Task.Anon(Args())) = Task.Command(exclusive = true) {
Expand Down
20 changes: 12 additions & 8 deletions scalalib/src/mill/scalalib/JavaModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ import mill.scalalib.api.CompilationResult
import mill.scalalib.bsp.{BspBuildTarget, BspModule, BspUri, JvmBuildTarget}
import mill.scalalib.publish.Artifact
import mill.util.Jvm

import os.{Path, ProcessOutput}

import scala.annotation.nowarn
import mill.define.Target

/**
* Core configuration required to compile a single Java compilation target
Expand Down Expand Up @@ -1028,14 +1030,16 @@ trait JavaModule
* code, without the Mill process. Useful for deployment & other places where
* you do not want a build tool running
*/
def launcher = Task {
Result.Success(
Jvm.createLauncher(
finalMainClass(),
runClasspath().map(_.path),
forkArgs()
)
)
def launcher: Target[PathRef] = Task {
val launchClasspath =
if (!runUseArgsFile()) runClasspath().map(_.path)
else {
val classpathJar = Task.dest / "classpath.jar"
Jvm.createClasspathPassingJar(classpathJar, runClasspath().map(_.path))
Agg(classpathJar)
}

Jvm.createLauncher(finalMainClass(), launchClasspath, forkArgs())
}

/**
Expand Down
7 changes: 4 additions & 3 deletions testkit/src/mill/testkit/ExampleTester.scala
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,16 @@ class ExampleTester(
processCommand(expectedSnippets, commandHead.trim)
}
}
private val millExt = if (Util.windowsPlatform) ".bat" else ""

def processCommand(
expectedSnippets: Vector[String],
commandStr0: String,
check: Boolean = true
): Unit = {
val commandStr = commandStr0 match {
case s"mill $rest" => s"./mill --disable-ticker $rest"
case s"./mill $rest" => s"./mill --disable-ticker $rest"
case s"mill $rest" => s"./mill$millExt --disable-ticker $rest"
case s"./mill $rest" => s"./mill$millExt --disable-ticker $rest"
case s"curl $rest" => s"curl --retry 7 --retry-all-errors $rest"
case s => s
}
Expand Down Expand Up @@ -191,7 +192,7 @@ class ExampleTester(

try {
initWorkspace()
os.copy.over(millExecutable, workspacePath / "mill")
os.copy.over(millExecutable, workspacePath / s"mill$millExt")
for (commandBlock <- commandBlocks) processCommandBlock(commandBlock)
} finally {
if (clientServerMode) processCommand(Vector(), "./mill shutdown", check = false)
Expand Down

0 comments on commit 570a262

Please sign in to comment.