From 2e247001f7917423b001962124eccafb4508ae01 Mon Sep 17 00:00:00 2001 From: Christopher Batey Date: Tue, 12 Mar 2019 11:43:02 +0000 Subject: [PATCH] Validate compile in multi-jvm (#26400) * New validateCompile task for multi jvm to run in travis --- .travis.yml | 2 +- build.sbt | 2 +- project/MultiNode.scala | 12 ++++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 27a02a1c8d..440942664b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,7 @@ cache: script: - jabba use "adopt@~1.8.202-08" # need to override as the default is to test - - sbt -jvm-opts .jvmopts-travis ";++$TRAVIS_SCALA_VERSION update ;++$TRAVIS_SCALA_VERSION mimaReportBinaryIssues ;++$TRAVIS_SCALA_VERSION test:compile" + - sbt -jvm-opts .jvmopts-travis ";++$TRAVIS_SCALA_VERSION update ;++$TRAVIS_SCALA_VERSION mimaReportBinaryIssues ;++$TRAVIS_SCALA_VERSION test:compile ;++$TRAVIS_SCALA_VERSION validateCompile" # make 'git branch' work again - git branch -f "$TRAVIS_BRANCH" && git checkout "$TRAVIS_BRANCH" # check policies, if on master also upload diff --git a/build.sbt b/build.sbt index dfaa6e42db..280e53f1bf 100644 --- a/build.sbt +++ b/build.sbt @@ -534,7 +534,7 @@ def commandValue(p: Project, externalTest: Option[Project] = None) = { val test = externalTest.getOrElse(p) val optionalMima = if (p.id.endsWith("-typed")) "" else s";${p.id}/mimaReportBinaryIssues" val optionalExternalTestFormat = externalTest.map(t => s";${t.id}/scalafmtAll").getOrElse("") - s";${p.id}/scalafmtAll$optionalExternalTestFormat;${test.id}/test:compile$optionalMima;${docs.id}/paradox" + s";${p.id}/scalafmtAll$optionalExternalTestFormat;${test.id}/test:compile$optionalMima;${docs.id}/paradox;${test.id}:validateCompile" } addCommandAlias("allActor", commandValue(actor, Some(actorTests))) addCommandAlias("allRemote", commandValue(remote, Some(remoteTests))) diff --git a/project/MultiNode.scala b/project/MultiNode.scala index 723cef8ff5..0f6aaf393e 100644 --- a/project/MultiNode.scala +++ b/project/MultiNode.scala @@ -15,6 +15,11 @@ import org.scalafmt.sbt.ScalafmtPlugin.scalafmtConfigSettings object MultiNode extends AutoPlugin { + object autoImport { + val validateCompile = taskKey[Unit]("Validates compile for any project it is enabled") + } + import autoImport._ + // MultiJvm tests can be excluded from normal test target an validatePullRequest // with -Dakka.test.multi-in-test=false val multiNodeTestInTest: Boolean = @@ -55,6 +60,10 @@ object MultiNode extends AutoPlugin { "-Xmx256m" :: akkaProperties ::: CliOptions.sbtLogNoFormat.ifTrue("-Dakka.test.nocolor=true").toList } + private val anyConfigsInThisProject = ScopeFilter( + configurations = inAnyConfiguration + ) + private val multiJvmSettings = SbtMultiJvm.multiJvmSettings ++ inConfig(MultiJvm)(scalafmtConfigSettings) ++ @@ -99,8 +108,7 @@ object MultiNode extends AutoPlugin { (headerCreate in MultiJvm).value (compile in MultiJvm).value }) ++ headerSettings(MultiJvm) ++ Seq( - // only works if I put it here ¯\_(ツ)_/¯ - compile in MultiJvm := ((compile in MultiJvm).triggeredBy(compile in Test)).value + validateCompile := compile.?.all(anyConfigsInThisProject).value )