Skip to content

Commit 4d93f23

Browse files
authored
Merge pull request #14301 from dotty-staging/fix-windows-ci-for-forward-compat
Fix windows CI; conditionally enable forward compat community build in PRs
2 parents 30a2333 + 2de9cb2 commit 4d93f23

File tree

3 files changed

+30
-30
lines changed

3 files changed

+30
-30
lines changed

.github/workflows/ci.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,12 @@ jobs:
327327
- ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache
328328
- ${{ github.workspace }}/../../cache/general:/root/.cache
329329
if: "github.event_name == 'schedule' && github.repository == 'lampepfl/dotty'
330+
|| (
331+
github.event_name == 'pull_request'
332+
&& !contains(github.event.pull_request.body, '[skip ci]')
333+
&& !contains(github.event.pull_request.body, '[skip community_build]')
334+
&& contains(github.event.pull_request.body, '[test_forward_compat]')
335+
)
330336
|| (
331337
github.event_name == 'workflow_dispatch'
332338
&& github.repository == 'lampepfl/dotty'

compiler/test/dotty/tools/vulpix/ParallelTesting.scala

+22-29
Original file line numberDiff line numberDiff line change
@@ -545,25 +545,36 @@ trait ParallelTesting extends RunnerOrchestration { self =>
545545
diagnostics.reverse
546546

547547
protected def compileWithOtherCompiler(compiler: String, files: Array[JFile], flags: TestFlags, targetDir: JFile): TestReporter =
548-
val compilerDir = getCompiler(compiler).toString
548+
def artifactClasspath(organizationName: String, moduleName: String) =
549+
import coursier._
550+
val dep = Dependency(
551+
Module(
552+
Organization(organizationName),
553+
ModuleName(moduleName),
554+
attributes = Map.empty
555+
),
556+
version = compiler
557+
)
558+
Fetch()
559+
.addDependencies(dep)
560+
.run()
561+
.mkString(JFile.pathSeparator)
549562

550-
def substituteClasspath(old: String): String =
551-
old.split(JFile.pathSeparator).map { o =>
552-
if JFile(o) == JFile(Properties.dottyLibrary) then s"$compilerDir/lib/scala3-library_3-$compiler.jar"
553-
else o
554-
}.mkString(JFile.pathSeparator)
563+
val stdlibClasspath = artifactClasspath("org.scala-lang", "scala3-library_3")
564+
val scalacClasspath = artifactClasspath("org.scala-lang", "scala3-compiler_3")
555565

556566
val pageWidth = TestConfiguration.pageWidth - 20
557-
val flags1 = flags.copy(defaultClassPath = substituteClasspath(flags.defaultClassPath))
567+
val flags1 = flags.copy(defaultClassPath = stdlibClasspath)
558568
.withClasspath(targetDir.getPath)
559569
.and("-d", targetDir.getPath)
560570
.and("-pagewidth", pageWidth.toString)
561571

562-
val reporter = TestReporter.reporter(realStdout, logLevel =
563-
if (suppressErrors || suppressAllOutput) ERROR + 1 else ERROR)
564-
565-
val command = Array(compilerDir + "/bin/scalac") ++ flags1.all ++ files.map(_.getPath)
572+
val scalacCommand = Array("java", "-cp", scalacClasspath, "dotty.tools.dotc.Main")
573+
val command = scalacCommand ++ flags1.all ++ files.map(_.getAbsolutePath)
566574
val process = Runtime.getRuntime.exec(command)
575+
576+
val reporter = TestReporter.reporter(realStdout, logLevel =
577+
if (suppressErrors || suppressAllOutput) ERROR + 1 else ERROR)
567578
val errorsText = Source.fromInputStream(process.getErrorStream).mkString
568579
if process.waitFor() != 0 then
569580
val diagnostics = parseErrors(errorsText, compiler, pageWidth)
@@ -1445,22 +1456,4 @@ object ParallelTesting {
14451456
def isTastyFile(f: JFile): Boolean =
14461457
f.getName.endsWith(".tasty")
14471458

1448-
def getCompiler(version: String): JFile =
1449-
val dir = cache.resolve(s"scala3-${version}").toFile
1450-
synchronized {
1451-
if dir.exists then
1452-
dir
1453-
else
1454-
import scala.sys.process._
1455-
val archivePath = cache.resolve(s"scala3-$version.tar.gz")
1456-
val compilerDownloadUrl = s"https://github.com/lampepfl/dotty/releases/download/$version/scala3-$version.tar.gz"
1457-
(URL(compilerDownloadUrl) #>> archivePath.toFile #&& s"tar -xf $archivePath -C $cache").!!
1458-
archivePath.toFile.delete()
1459-
dir
1460-
}
1461-
1462-
private lazy val cache =
1463-
val dir = Properties.testCache.resolve("compilers")
1464-
dir.toFile.mkdirs()
1465-
dir
14661459
}

project/Build.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,8 @@ object Build {
516516
Dependencies.oldCompilerInterface, // we stick to the old version to avoid deprecation warnings
517517
"org.jline" % "jline-reader" % "3.19.0", // used by the REPL
518518
"org.jline" % "jline-terminal" % "3.19.0",
519-
"org.jline" % "jline-terminal-jna" % "3.19.0" // needed for Windows
519+
"org.jline" % "jline-terminal-jna" % "3.19.0", // needed for Windows
520+
("io.get-coursier" %% "coursier" % "2.0.16" % Test).cross(CrossVersion.for3Use2_13),
520521
),
521522

522523
// For convenience, change the baseDirectory when running the compiler

0 commit comments

Comments
 (0)