From a5f17fec5b5e6f58558917d9cbbdc0163a937635 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Tue, 6 Nov 2018 00:14:06 +0800 Subject: bump ammonite integration test version, remove 2.11.8 build since it blows up mysteriously --- build.sc | 2 +- integration/test/resources/ammonite/build.sc | 229 ++++++++++++++++++--- .../test/src/mill/integration/AmmoniteTests.scala | 1 - .../test/src/mill/integration/forked/Tests.scala | 1 - 4 files changed, 196 insertions(+), 37 deletions(-) diff --git a/build.sc b/build.sc index 8e4b1b13..261c933b 100755 --- a/build.sc +++ b/build.sc @@ -301,7 +301,7 @@ def testRepos = T{ "MILL_BETTERFILES_REPO" -> shared.downloadTestRepo("pathikrit/better-files", "ba74ae9ef784dcf37f1b22c3990037a4fcc6b5f8", T.ctx().dest/"better-files"), "MILL_AMMONITE_REPO" -> - shared.downloadTestRepo("lihaoyi/ammonite", "96ea548d5e3b72ab6ad4d9765e205bf6cc1c82ac", T.ctx().dest/"ammonite"), + shared.downloadTestRepo("lihaoyi/ammonite", "26b7ebcace16b4b5b4b68f9344ea6f6f48d9b53e", T.ctx().dest/"ammonite"), "MILL_UPICKLE_REPO" -> shared.downloadTestRepo("lihaoyi/upickle", "7f33085c890db7550a226c349832eabc3cd18769", T.ctx().dest/"upickle"), "MILL_PLAY_JSON_REPO" -> diff --git a/integration/test/resources/ammonite/build.sc b/integration/test/resources/ammonite/build.sc index 34f80825..8dff405a 100644 --- a/integration/test/resources/ammonite/build.sc +++ b/integration/test/resources/ammonite/build.sc @@ -1,28 +1,89 @@ -import mill._, scalalib._ -val binCrossScalaVersions = Seq("2.11.11", "2.12.4") +import mill._, scalalib._, publish._ +import ammonite.ops._, ImplicitWd._ + +val isMasterCommit = + sys.env.get("TRAVIS_PULL_REQUEST") == Some("false") && + (sys.env.get("TRAVIS_BRANCH") == Some("master") || sys.env("TRAVIS_TAG") != "") + +val latestTaggedVersion = %%('git, 'describe, "--abbrev=0", "--tags").out.trim + +val commitsSinceTaggedVersion = { + %%('git, "rev-list", 'master, "--not", latestTaggedVersion, "--count").out.trim.toInt +} + + +val binCrossScalaVersions = Seq("2.11.12", "2.12.7") val fullCrossScalaVersions = Seq( - "2.11.3", "2.11.4", "2.11.5", "2.11.6", "2.11.7", "2.11.8", "2.11.9", "2.11.11", - "2.12.0", "2.12.1", "2.12.2", "2.12.3", "2.12.4" + "2.11.3", "2.11.4", "2.11.5", "2.11.6", "2.11.7", "2.11.8", "2.11.9", "2.11.11", "2.11.12", + "2.12.0", "2.12.1", "2.12.2", "2.12.3", "2.12.4", "2.12.6", "2.12.7" ) -trait AmmModule extends mill.scalalib.CrossSbtModule{ - def testFrameworks = Seq("utest.runner.Framework") + +val latestAssemblies = binCrossScalaVersions.map(amm(_).assembly) + +val (buildVersion, unstable) = sys.env.get("TRAVIS_TAG") match{ + case Some(v) if v != "" => (v, false) + case _ => + val gitHash = %%("git", "rev-parse", "--short", "HEAD").out.trim + (s"$latestTaggedVersion-$commitsSinceTaggedVersion-${gitHash}", true) +} + +trait AmmInternalModule extends mill.scalalib.CrossSbtModule{ + def artifactName = "ammonite-" + millOuterCtx.segments.parts.last + def testFramework = "utest.runner.Framework" def scalacOptions = Seq("-P:acyclic:force", "-target:jvm-1.7") def compileIvyDeps = Agg(ivy"com.lihaoyi::acyclic:0.1.7") def scalacPluginIvyDeps = Agg(ivy"com.lihaoyi::acyclic:0.1.7") trait Tests extends super.Tests{ def ivyDeps = Agg(ivy"com.lihaoyi::utest:0.6.0") def testFrameworks = Seq("utest.runner.Framework") + def forkArgs = Seq("-XX:MaxPermSize=2g", "-Xmx4g", "-Dfile.encoding=UTF8") } def allIvyDeps = T{transitiveIvyDeps() ++ scalaLibraryIvyDeps()} def externalSources = T{ resolveDeps(allIvyDeps, sources = true)() } } +trait AmmModule extends AmmInternalModule with PublishModule{ + def publishVersion = buildVersion + def pomSettings = PomSettings( + description = artifactName(), + organization = "com.lihaoyi", + url = "https://github.com/lihaoyi/Ammonite", + licenses = Seq(License.MIT), + versionControl = VersionControl.github("lihaoyi", "ammonite"), + developers = Seq( + Developer("lihaoyi", "Li Haoyi","https://github.com/lihaoyi") + ) + ) + + +} +trait AmmDependenciesResourceFileModule extends JavaModule{ + def crossScalaVersion: String + def dependencyResourceFileName: String + def resources = T.sources { + + val deps0 = T.task{compileIvyDeps() ++ transitiveIvyDeps()}() + val (_, res) = mill.modules.Jvm.resolveDependenciesMetadata( + repositories, + deps0.map(resolveCoursierDependency().apply(_)), + deps0.filter(_.force).map(resolveCoursierDependency().apply(_)), + mapDependencies = Some(mapDependencies()) + ) + + super.resources() ++ + Seq(PathRef(generateDependenciesFile( + crossScalaVersion, + dependencyResourceFileName, + res.minDependencies.toSeq + ))) + } +} object ops extends Cross[OpsModule](binCrossScalaVersions:_*) class OpsModule(val crossScalaVersion: String) extends AmmModule{ - def ivyDeps = Agg(ivy"com.lihaoyi::geny:0.1.2") - + def ivyDeps = Agg(ivy"com.lihaoyi::os-lib:0.2.0") + def scalacOptions = super.scalacOptions().filter(!_.contains("acyclic")) object test extends Tests } @@ -33,7 +94,7 @@ class TerminalModule(val crossScalaVersion: String) extends AmmModule{ ivy"com.lihaoyi::fansi:0.2.4" ) def compileIvyDeps = Agg( - ivy"${scalaOrganization()}:scala-reflect:$crossScalaVersion" + ivy"org.scala-lang:scala-reflect:$crossScalaVersion" ) object test extends Tests @@ -44,12 +105,12 @@ object amm extends Cross[MainModule](fullCrossScalaVersions:_*){ class UtilModule(val crossScalaVersion: String) extends AmmModule{ def moduleDeps = Seq(ops()) def ivyDeps = Agg( - ivy"com.lihaoyi::upickle:0.5.1", + ivy"com.lihaoyi::upickle:0.6.7", ivy"com.lihaoyi::pprint:0.5.2", ivy"com.lihaoyi::fansi:0.2.4" ) def compileIvyDeps = Agg( - ivy"${scalaOrganization()}:scala-reflect:$crossScalaVersion" + ivy"org.scala-lang:scala-reflect:$crossScalaVersion" ) } @@ -59,52 +120,64 @@ object amm extends Cross[MainModule](fullCrossScalaVersions:_*){ class RuntimeModule(val crossScalaVersion: String) extends AmmModule{ def moduleDeps = Seq(ops(), amm.util()) def ivyDeps = Agg( - ivy"io.get-coursier::coursier:1.0.0", - ivy"io.get-coursier::coursier-cache:1.0.0", - ivy"org.scalaj::scalaj-http:2.3.0" + ivy"io.get-coursier::coursier:1.1.0-M7", + ivy"io.get-coursier::coursier-cache:1.1.0-M7", + ivy"org.scalaj::scalaj-http:2.4.0" ) def generatedSources = T{ - - os.copy(build.millSourcePath/'project/"Constants.scala", T.ctx().dest/"Constants.scala") - Seq(PathRef(T.ctx().dest)) + Seq(PathRef(generateConstantsFile(buildVersion))) } } object interp extends Cross[InterpModule](fullCrossScalaVersions:_*) class InterpModule(val crossScalaVersion: String) extends AmmModule{ def moduleDeps = Seq(ops(), amm.util(), amm.runtime()) + def crossFullScalaVersion = true def ivyDeps = Agg( - ivy"${scalaOrganization()}:scala-compiler:$crossScalaVersion", - ivy"${scalaOrganization()}:scala-reflect:$crossScalaVersion", - ivy"com.lihaoyi::scalaparse:1.0.0", + ivy"org.scala-lang:scala-compiler:$crossScalaVersion", + ivy"org.scala-lang:scala-reflect:$crossScalaVersion", + ivy"com.lihaoyi::scalaparse:2.0.5", ivy"org.javassist:javassist:3.21.0-GA" ) } object repl extends Cross[ReplModule](fullCrossScalaVersions:_*) class ReplModule(val crossScalaVersion: String) extends AmmModule{ + def crossFullScalaVersion = true def moduleDeps = Seq( ops(), amm.util(), amm.runtime(), amm.interp(), terminal() ) def ivyDeps = Agg( - ivy"jline:jline:2.14.3", + ivy"org.jline:jline-terminal:3.6.2", + ivy"org.jline:jline-terminal-jna:3.6.2", + ivy"org.jline:jline-reader:3.6.2", ivy"com.github.javaparser:javaparser-core:3.2.5", ivy"com.github.scopt::scopt:3.5.0" ) - object test extends Tests{ + object test extends Tests with AmmDependenciesResourceFileModule{ + def crossScalaVersion = ReplModule.this.crossScalaVersion + def dependencyResourceFileName = "amm-test-dependencies.txt" def resources = T.sources { - super.resources() ++ - ReplModule.this.sources() ++ - ReplModule.this.externalSources() + (super.resources() ++ + ReplModule.this.sources() ++ + ReplModule.this.externalSources() ++ + resolveDeps(ivyDeps, sources = true)()).distinct } + def ivyDeps = super.ivyDeps() ++ Agg( + ivy"org.scalaz::scalaz-core:7.2.24" + ) } } } -class MainModule(val crossScalaVersion: String) extends AmmModule{ +class MainModule(val crossScalaVersion: String) extends AmmModule with AmmDependenciesResourceFileModule{ + + def artifactName = "ammonite" + + def crossFullScalaVersion = true def mainClass = Some("ammonite.Main") @@ -130,37 +203,57 @@ class MainModule(val crossScalaVersion: String) extends AmmModule{ - def prependShellScript = - "#!/usr/bin/env sh\n" + - """exec java -jar -Xmx500m -XX:+UseG1GC $JAVA_OPTS "$0" "$@"""" + def prependShellScript = T{ + mill.modules.Jvm.launcherUniversalScript( + mainClass().get, + Agg("$0"), + Agg("%~dpnx0"), + // G1 Garbage Collector is awesome https://github.com/lihaoyi/Ammonite/issues/216 + Seq("-Xmx500m", "-XX:+UseG1GC") + ) + } + def dependencyResourceFileName = "amm-dependencies.txt" object test extends Tests{ def moduleDeps = super.moduleDeps ++ Seq(amm.repl().test) def ivyDeps = super.ivyDeps() ++ Agg( ivy"com.chuusai::shapeless:2.3.2" ) + // Need to duplicate this from MainModule due to Mill not properly propagating it through + def runClasspath = + super.runClasspath() ++ + ops().sources() ++ + terminal().sources() ++ + amm.util().sources() ++ + amm.runtime().sources() ++ + amm.interp().sources() ++ + amm.repl().sources() ++ + sources() ++ + externalSources() + } } object shell extends Cross[ShellModule](fullCrossScalaVersions:_*) class ShellModule(val crossScalaVersion: String) extends AmmModule{ def moduleDeps = Seq(ops(), amm()) + def crossFullScalaVersion = true object test extends Tests{ def moduleDeps = super.moduleDeps ++ Seq(amm.repl().test) def forkEnv = super.forkEnv() ++ Seq( - "AMMONITE_TEST_SHELL" -> shell().jar().path.toString, - "AMMONITE_TEST_ASSEMBLY" -> amm().assembly().path.toString + "AMMONITE_SHELL" -> shell().jar().path.toString, + "AMMONITE_ASSEMBLY" -> amm().assembly().path.toString ) } } object integration extends Cross[IntegrationModule](fullCrossScalaVersions:_*) -class IntegrationModule(val crossScalaVersion: String) extends AmmModule{ +class IntegrationModule(val crossScalaVersion: String) extends AmmInternalModule{ def moduleDeps = Seq(ops(), amm()) object test extends Tests { def forkEnv = super.forkEnv() ++ Seq( - "AMMONITE_TEST_SHELL" -> shell().jar().path.toString, - "AMMONITE_TEST_ASSEMBLY" -> amm().assembly().path.toString + "AMMONITE_SHELL" -> shell().jar().path.toString, + "AMMONITE_ASSEMBLY" -> amm().assembly().path.toString ) } } @@ -168,6 +261,7 @@ class IntegrationModule(val crossScalaVersion: String) extends AmmModule{ object sshd extends Cross[SshdModule](fullCrossScalaVersions:_*) class SshdModule(val crossScalaVersion: String) extends AmmModule{ def moduleDeps = Seq(ops(), amm()) + def crossFullScalaVersion = true def ivyDeps = Agg( // sshd-core 1.3.0 requires java8 ivy"org.apache.sshd:sshd-core:1.2.0", @@ -182,3 +276,70 @@ class SshdModule(val crossScalaVersion: String) extends AmmModule{ ) } } + +def unitTest(scalaVersion: String = sys.env("TRAVIS_SCALA_VERSION")) = T.command{ + ops(scalaVersion).test.test()() + terminal(scalaVersion).test.test()() + amm.repl(scalaVersion).test.test()() + amm(scalaVersion).test.test()() + shell(scalaVersion).test.test()() + sshd(scalaVersion).test.test()() +} + +def integrationTest(scalaVersion: String = sys.env("TRAVIS_SCALA_VERSION")) = T.command{ + integration(scalaVersion).test.test()() +} + +def generateConstantsFile(version: String = buildVersion, + unstableVersion: String = "", + curlUrl: String = "", + unstableCurlUrl: String = "", + oldCurlUrls: Seq[(String, String)] = Nil, + oldUnstableCurlUrls: Seq[(String, String)] = Nil) + (implicit ctx: mill.util.Ctx.Dest)= { + val versionTxt = s""" + package ammonite + object Constants{ + val version = "$version" + val unstableVersion = "$unstableVersion" + val curlUrl = "$curlUrl" + val unstableCurlUrl = "$unstableCurlUrl" + val oldCurlUrls = Seq[(String, String)]( + ${oldCurlUrls.map{case (name, value) => s""" "$name" -> "$value" """}.mkString(",\n")} + ) + val oldUnstableCurlUrls = Seq[(String, String)]( + ${oldUnstableCurlUrls.map{case (name, value) => s""" "$name" -> "$value" """}.mkString(",\n")} + ) + } + """ + println("Writing Constants.scala") + + write(ctx.dest/"Constants.scala", versionTxt) + ctx.dest/"Constants.scala" +} + +def generateDependenciesFile(scalaVersion: String, + fileName: String, + deps: Seq[coursier.Dependency]) + (implicit ctx: mill.util.Ctx.Dest) = { + + val dir = ctx.dest / "extra-resources" + val dest = dir / fileName + + val content = deps + .map { dep => + (dep.module.organization, dep.module.name, dep.version) + } + .sorted + .map { + case (org, name, ver) => + s"$org:$name:$ver" + } + .mkString("\n") + + println(s"Writing $dest") + write(dest, content.getBytes("UTF-8")) + + dir +} + diff --git a/integration/test/src/mill/integration/AmmoniteTests.scala b/integration/test/src/mill/integration/AmmoniteTests.scala index 2f2c648d..5851a393 100644 --- a/integration/test/src/mill/integration/AmmoniteTests.scala +++ b/integration/test/src/mill/integration/AmmoniteTests.scala @@ -29,7 +29,6 @@ class AmmoniteTests(fork: Boolean) ) } - 'scala2118 - check("2.11.8") 'scala2124 - check("2.12.4") } diff --git a/integration/test/src/mill/integration/forked/Tests.scala b/integration/test/src/mill/integration/forked/Tests.scala index 41844b58..bc2d0d6d 100644 --- a/integration/test/src/mill/integration/forked/Tests.scala +++ b/integration/test/src/mill/integration/forked/Tests.scala @@ -1,7 +1,6 @@ package mill.integration.forked object AcyclicTests extends mill.integration.AcyclicTests(fork = true) -object AmmoniteTests extends mill.integration.AmmoniteTests(fork = true) object BetterFilesTests extends mill.integration.BetterFilesTests(fork = true) object JawnTests extends mill.integration.JawnTests(fork = true) object UpickleTests extends mill.integration.UpickleTests(fork = true) -- cgit v1.2.3