-
-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve overriden target detection to let it handle stackable-traits-…
…style overrides (#1600) Fixes #554 This PR swaps out our detection of overriden targets and commands: - Previously, we tried to count how many overriden methods there are upstream of a particular target, statically at its definition site. Any target that has the max number of overriden methods is considered the "final" one, while others are considered overriden. This fails for stackable traits, e.g. the example in the test suite below, as multiple traits can have the same number of static definiton-site overrides but when stacked together on a module one of them ends up winning - Now, we simply do a reverse walk of the targets list after they have been topo sorted. Since the directionality of overrides is exactly opposite that of the topo sort, we can assume that the first time we see a target of a particular label in the reverse walk it's the "final" one, while any subsequent targets we see with the same label must be the overriden versions The new mechanism is simpler, and possibly more correct. Hopefully CI would catch any issues... Added a test case that fails on master and passes on this PR. Also verified manually that the issue reported above can be reproduced on master, and does not reproduce (i.e. it behaves correctly) on this PR.
- Loading branch information
Showing
10 changed files
with
201 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
diff --git a/build.sc b/build.sc | ||
index cf9b2036..335e5ec0 100755 | ||
--- a/build.sc | ||
+++ b/build.sc | ||
@@ -1,16 +1,16 @@ | ||
import $file.ci.shared | ||
import $file.ci.upload | ||
import $ivy.`org.scalaj::scalaj-http:2.4.2` | ||
-import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.1.2-4-dcde72` | ||
-import $ivy.`com.github.lolgab::mill-mima::0.0.6` | ||
+//import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.1.2-4-dcde72` | ||
+//import $ivy.`com.github.lolgab::mill-mima::0.0.6` | ||
import $ivy.`net.sourceforge.htmlcleaner:htmlcleaner:2.24` | ||
import java.nio.file.attribute.PosixFilePermission | ||
|
||
-import com.github.lolgab.mill.mima | ||
-import com.github.lolgab.mill.mima.ProblemFilter | ||
-import com.typesafe.tools.mima.core.{DirectMissingMethodProblem, IncompatibleSignatureProblem} | ||
+//import com.github.lolgab.mill.mima | ||
+//import com.github.lolgab.mill.mima.ProblemFilter | ||
+//import com.typesafe.tools.mima.core.{DirectMissingMethodProblem, IncompatibleSignatureProblem} | ||
import coursier.maven.MavenRepository | ||
-import de.tobiasroeser.mill.vcs.version.VcsVersion | ||
+//import de.tobiasroeser.mill.vcs.version.VcsVersion | ||
import mill._ | ||
import mill.define.{Command, Source, Sources, Target, Task} | ||
import mill.eval.Evaluator | ||
@@ -127,12 +127,8 @@ object Deps { | ||
val jarjarabrams = ivy"com.eed3si9n.jarjarabrams::jarjar-abrams-core:1.8.0" | ||
} | ||
|
||
-def millVersion: T[String] = T { VcsVersion.vcsState().format() } | ||
-def millLastTag: T[String] = T { | ||
- VcsVersion.vcsState().lastTag.getOrElse( | ||
- sys.error("No (last) git tag found. Your git history seems incomplete!") | ||
- ) | ||
-} | ||
+def millVersion: T[String] = T { "0.0.0.test" } | ||
+def millLastTag: T[String] = T { "0.0.0.test" } | ||
def millBinPlatform: T[String] = T { | ||
val tag = millLastTag() | ||
if (tag.contains("-M")) tag | ||
@@ -170,44 +166,44 @@ trait MillCoursierModule extends CoursierModule { | ||
} | ||
} | ||
|
||
-trait MillMimaConfig extends mima.Mima { | ||
- override def mimaPreviousVersions: T[Seq[String]] = Settings.mimaBaseVersions | ||
- override def mimaPreviousArtifacts = | ||
- if (Settings.mimaBaseVersions.isEmpty) T { Agg[Dep]() } | ||
- else super.mimaPreviousArtifacts | ||
- override def mimaExcludeAnnotations: T[Seq[String]] = Seq( | ||
- "mill.api.internal", | ||
- "mill.api.experimental" | ||
- ) | ||
- override def mimaBinaryIssueFilters: Target[Seq[ProblemFilter]] = T { | ||
- issueFilterByModule.getOrElse(this, Seq()) | ||
- } | ||
- lazy val issueFilterByModule: Map[MillMimaConfig, Seq[ProblemFilter]] = Map( | ||
- main.api -> Seq( | ||
- ProblemFilter.exclude[IncompatibleSignatureProblem]("mill.api.Ctx.args"), | ||
- ProblemFilter.exclude[IncompatibleSignatureProblem]("mill.api.Ctx.this"), | ||
- ProblemFilter.exclude[IncompatibleSignatureProblem]("mill.api.Ctx#Args.args") | ||
- ), | ||
- main.core -> Seq( | ||
- ProblemFilter.exclude[IncompatibleSignatureProblem]("mill.define.Target.makeT"), | ||
- ProblemFilter.exclude[IncompatibleSignatureProblem]("mill.define.Target.args"), | ||
- ProblemFilter.exclude[IncompatibleSignatureProblem]("mill.define.ParseArgs.standaloneIdent"), | ||
- ProblemFilter.exclude[IncompatibleSignatureProblem]( | ||
- "mill.define.ParseArgs#BraceExpansionParser.plainChars" | ||
- ), | ||
- ProblemFilter.exclude[IncompatibleSignatureProblem]( | ||
- "mill.define.ParseArgs#BraceExpansionParser.braceParser" | ||
- ), | ||
- ProblemFilter.exclude[IncompatibleSignatureProblem]( | ||
- "mill.define.ParseArgs#BraceExpansionParser.parser" | ||
- ), | ||
- ProblemFilter.exclude[IncompatibleSignatureProblem]( | ||
- "mill.define.ParseArgs#BraceExpansionParser.toExpand" | ||
- ), | ||
- ProblemFilter.exclude[IncompatibleSignatureProblem]("mill.eval.EvaluatorPaths.*"), | ||
- ProblemFilter.exclude[DirectMissingMethodProblem]("mill.eval.EvaluatorPaths.*") | ||
- ) | ||
- ) | ||
+trait MillMimaConfig { | ||
+// override def mimaPreviousVersions: T[Seq[String]] = Settings.mimaBaseVersions | ||
+// override def mimaPreviousArtifacts = | ||
+// if (Settings.mimaBaseVersions.isEmpty) T { Agg[Dep]() } | ||
+// else super.mimaPreviousArtifacts | ||
+// override def mimaExcludeAnnotations: T[Seq[String]] = Seq( | ||
+// "mill.api.internal", | ||
+// "mill.api.experimental" | ||
+// ) | ||
+// def mimaBinaryIssueFilters: Target[Seq[ProblemFilter]] = T { | ||
+// issueFilterByModule.getOrElse(this, Seq()) | ||
+// } | ||
+// lazy val issueFilterByModule: Map[MillMimaConfig, Seq[ProblemFilter]] = Map( | ||
+// main.api -> Seq( | ||
+// ProblemFilter.exclude[IncompatibleSignatureProblem]("mill.api.Ctx.args"), | ||
+// ProblemFilter.exclude[IncompatibleSignatureProblem]("mill.api.Ctx.this"), | ||
+// ProblemFilter.exclude[IncompatibleSignatureProblem]("mill.api.Ctx#Args.args") | ||
+// ), | ||
+// main.core -> Seq( | ||
+// ProblemFilter.exclude[IncompatibleSignatureProblem]("mill.define.Target.makeT"), | ||
+// ProblemFilter.exclude[IncompatibleSignatureProblem]("mill.define.Target.args"), | ||
+// ProblemFilter.exclude[IncompatibleSignatureProblem]("mill.define.ParseArgs.standaloneIdent"), | ||
+// ProblemFilter.exclude[IncompatibleSignatureProblem]( | ||
+// "mill.define.ParseArgs#BraceExpansionParser.plainChars" | ||
+// ), | ||
+// ProblemFilter.exclude[IncompatibleSignatureProblem]( | ||
+// "mill.define.ParseArgs#BraceExpansionParser.braceParser" | ||
+// ), | ||
+// ProblemFilter.exclude[IncompatibleSignatureProblem]( | ||
+// "mill.define.ParseArgs#BraceExpansionParser.parser" | ||
+// ), | ||
+// ProblemFilter.exclude[IncompatibleSignatureProblem]( | ||
+// "mill.define.ParseArgs#BraceExpansionParser.toExpand" | ||
+// ), | ||
+// ProblemFilter.exclude[IncompatibleSignatureProblem]("mill.eval.EvaluatorPaths.*"), | ||
+// ProblemFilter.exclude[DirectMissingMethodProblem]("mill.eval.EvaluatorPaths.*") | ||
+// ) | ||
+// ) | ||
} | ||
|
||
trait MillApiModule | ||
@@ -1255,12 +1251,11 @@ def launcher = T { | ||
} | ||
|
||
def uploadToGithub(authKey: String) = T.command { | ||
- val vcsState = VcsVersion.vcsState() | ||
- val label = vcsState.format() | ||
+// val vcsState = VcsVersion.vcsState() | ||
+// val label = vcsState.format() | ||
+ val label = millVersion() | ||
if (label != millVersion()) sys.error("Modified mill version detected, aborting upload") | ||
- val releaseTag = vcsState.lastTag.getOrElse(sys.error( | ||
- "Incomplete git history. No tag found.\nIf on CI, make sure your git checkout job includes enough history." | ||
- )) | ||
+ val releaseTag = millLastTag() | ||
|
||
if (releaseTag == label) { | ||
scalaj.http.Http( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters