Skip to content

Commit

Permalink
Merge branch 'main' into android/android-studio-experiments
Browse files Browse the repository at this point in the history
  • Loading branch information
vaslabs authored Jan 21, 2025
2 parents 51469bd + b616252 commit 7cd9cc8
Show file tree
Hide file tree
Showing 8 changed files with 297 additions and 29 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/publish-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ jobs:

- run: "echo temurin:11 > .mill-jvm-version"

- run: "echo 0.12.5-150-31d41c > .mill-version"

- run: ./mill -i mill.scalalib.PublishModule/ --publishArtifacts dist.native.publishArtifacts

release-github:
Expand Down
30 changes: 22 additions & 8 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@ jobs:
# Run these with Mill native launcher as a smoketest
include:
- os: ubuntu-24.04-arm
millargs: example.javalib.__.local.server.test
millargs: "'example.thirdparty[fansi].native.server.test'"
java-version: 17

- os: macos-latest
millargs: example.scalalib.__.native.server.test
millargs: "'example.thirdparty[acyclic].native.server.test'"
java-version: 11

- os: macos-13
millargs: example.kotlinlib.__.native.server.test
millargs: "'example.thirdparty[jimfs].native.server.test'"
java-version: 11
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -137,6 +139,18 @@ jobs:
millargs: "contrib.__.test"
install-android-sdk: false

- java-version: 17
millargs: "example.javalib.__.local.server.test"
install-android-sdk: false

- java-version: 17
millargs: "example.kotlinlib.__.native.server.test"
install-android-sdk: false

- java-version: 17
millargs: "example.scalalib.__.native.server.test"
install-android-sdk: false

- java-version: 17
millargs: "'example.android.__.local.server.test'"
install-android-sdk: true
Expand All @@ -146,11 +160,11 @@ jobs:
install-android-sdk: false

- java-version: 11
millargs: "'example.thirdparty[{mockito,acyclic,commons-io}].local.server.test'"
millargs: "'example.thirdparty[{mockito,commons-io}].local.server.test'"
install-android-sdk: false

- java-version: 17
millargs: "'example.thirdparty[{fansi,jimfs,netty,gatling}].local.server.test'"
millargs: "'example.thirdparty[{netty,gatling}].local.server.test'"
install-android-sdk: false

- java-version: '17'
Expand All @@ -160,11 +174,11 @@ jobs:
- java-version: 11
millargs: "'example.{cli,fundamentals,depth,extending}.__.local.server.test'"
install-android-sdk: false
# Most of these integration tests should not depend on which mode they
# are run in, so just run them in `local`
- java-version: '17'

- java-version: 11
millargs: "'integration.{failure,feature,ide}.__.packaged.server.test'"
install-android-sdk: false

# These invalidation tests need to be exercised in both execution modes
# to make sure they work with and without -i/--no-server being passed
- java-version: 17
Expand Down
23 changes: 18 additions & 5 deletions contrib/docker/src/mill/contrib/docker/DockerModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ trait DockerModule { outer: JavaModule =>
*/
def envVars: T[Map[String, String]] = Map.empty[String, String]

/**
* Environment to pass to the docker commands.
* Example: DOCKER_DEFAULT_PLATFORM=linux/amd64
*
* See also the Docker docs on
* [[https://docs.docker.com/engine/reference/commandline/cli/#environment-variables Environment variables]]
* for more information.
*/
def dockerEnv: T[Map[String, String]] = T.env

/**
* Commands to add as RUN instructions.
*
Expand Down Expand Up @@ -138,19 +148,21 @@ trait DockerModule { outer: JavaModule =>
}

private def pullAndHash = Task.Input {
val env = dockerEnv()
def imageHash() =
os.proc(executable(), "images", "--no-trunc", "--quiet", baseImage())
.call(stderr = os.Inherit).out.text().trim
.call(stderr = os.Inherit, env = env).out.text().trim

if (pullBaseImage() || imageHash().isEmpty)
os.proc(executable(), "image", "pull", baseImage())
.call(stdout = os.Inherit, stderr = os.Inherit)
.call(stdout = os.Inherit, stderr = os.Inherit, env = env)

(pullBaseImage(), imageHash())
}

final def build = Task {
val dest = T.dest
val env = dockerEnv()

val asmPath = outer.assembly().path
os.copy(asmPath, dest / asmPath.last)
Expand All @@ -168,7 +180,7 @@ trait DockerModule { outer: JavaModule =>
if (platform().nonEmpty)
log.info("Platform parameter is ignored when using non-docker executable")
os.proc(executable(), "build", tagArgs, pullLatestBase, dest)
.call(stdout = os.Inherit, stderr = os.Inherit)
.call(stdout = os.Inherit, stderr = os.Inherit, env = env)
} else {
os.proc(
executable(),
Expand All @@ -180,7 +192,7 @@ trait DockerModule { outer: JavaModule =>
platform(),
dest
)
.call(stdout = os.Inherit, stderr = os.Inherit)
.call(stdout = os.Inherit, stderr = os.Inherit, env = env)
}
log.info(s"Docker build completed ${if (result.exitCode == 0) "successfully"
else "unsuccessfully"} with ${result.exitCode}")
Expand All @@ -189,8 +201,9 @@ trait DockerModule { outer: JavaModule =>

final def push() = Task.Command {
val tags = build()
val env = dockerEnv()
tags.foreach(t =>
os.proc(executable(), "push", t).call(stdout = os.Inherit, stderr = os.Inherit)
os.proc(executable(), "push", t).call(stdout = os.Inherit, stderr = os.Inherit, env = env)
)
}
}
Expand Down
15 changes: 15 additions & 0 deletions contrib/docker/test/src/mill/contrib/docker/DockerModuleTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package mill
package contrib.docker

import mill.scalalib.JavaModule
import mill.api.Result
import mill.util.TestUtil
import mill.testkit.UnitTester
import mill.testkit.TestBaseModule
import os.Path
Expand Down Expand Up @@ -41,6 +43,10 @@ object DockerModuleTest extends TestSuite {
override def executable = testExecutable
override def jvmOptions = Seq("-Xmx1024M")
}

object dockerEnv extends DockerConfig {
override def dockerEnv = Map("DOCKER_HOST" -> "wrong_host")
}
}

val testArtifactName = "mill-docker-contrib-test"
Expand Down Expand Up @@ -86,6 +92,15 @@ object DockerModuleTest extends TestSuite {
val Right(result) = eval(Docker.dockerAll.build)
assert(result.value == List(testArtifactName))
}

"dockerEnv" - workspaceTest(Docker) { eval =>
// since stdout and stderr are inherited we can only test
// that docker fails with wrong DOCKER_HOST
val Left(Result.Exception(error: os.SubprocessException, _)) =
eval(Docker.dockerEnv.build)
val message = error.getMessage
assert(message == "Result of docker…: 1\n")
}
}

test("dockerfile contents") {
Expand Down
1 change: 0 additions & 1 deletion example/kotlinlib/basic/1-simple/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package build
import mill._, kotlinlib._

object foo extends KotlinModule {

def kotlinVersion = "1.9.24"

def mainClass = Some("foo.FooKt")
Expand Down
11 changes: 11 additions & 0 deletions scalalib/src/mill/scalalib/JavaModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ trait JavaModule
}
}

override def bomIvyDeps = Task.Anon[Agg[Dep]] {
// FIXME Add that back when we can break bin-compat
// super.bomIvyDeps() ++
outer.bomIvyDeps()
}
override def depManagement = Task.Anon[Agg[Dep]] {
// FIXME Add that back when we can break bin-compat
// super.depManagement() ++
outer.depManagement()
}

/**
* JavaModule and its derivatives define inner test modules.
* To avoid unexpected misbehavior due to the use of the wrong inner test trait
Expand Down
19 changes: 11 additions & 8 deletions scalalib/src/mill/scalalib/PublishModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -327,22 +327,25 @@ trait PublishModule extends JavaModule { outer =>
* If not set, falls back to `maven.repo.local` system property or `~/.m2/repository`
* @return [[PathRef]]s to published files.
*/
def publishM2Local(m2RepoPath: String = getM2LocalRepoPath.toString()): Command[Seq[PathRef]] =
Task.Command {
publishM2LocalTask(Task.Anon {
os.Path(m2RepoPath, T.workspace)
})()
}
def publishM2Local(m2RepoPath: String = null): Command[Seq[PathRef]] = m2RepoPath match {
case null => Task.Command { publishM2LocalTask(Task.Anon { publishM2LocalRepoPath() })() }
case p => Task.Command { publishM2LocalTask(Task.Anon { os.Path(p, T.workspace) })() }
}

/**
* Publish artifacts to the local Maven repository.
* @return [[PathRef]]s to published files.
*/
def publishM2LocalCached: T[Seq[PathRef]] = Task {
publishM2LocalTask(getM2LocalRepoPath)()
publishM2LocalTask(publishM2LocalRepoPath)()
}

def getM2LocalRepoPath: Task[os.Path] = Task.Input {
/**
* The default path that [[publishM2Local]] should publish its artifacts to.
* Defaults to `~/.m2/repository`, but can be configured by setting the
* `maven.repo.local` JVM property
*/
def publishM2LocalRepoPath: Task[os.Path] = Task.Input {
sys.props.get("maven.repo.local").map(os.Path(_))
.getOrElse(os.Path(os.home / ".m2", T.workspace)) / "repository"
}
Expand Down
Loading

0 comments on commit 7cd9cc8

Please sign in to comment.