Skip to content

Commit dba1efe

Browse files
committed
Fix windows CI; use coursier as tests dependency; conditionally enable forward compat community build in PRs
1 parent 0e4e5d5 commit dba1efe

File tree

3 files changed

+42
-33
lines changed

3 files changed

+42
-33
lines changed

.github/workflows/ci.yaml

Lines changed: 6 additions & 0 deletions
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

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -520,30 +520,50 @@ trait ParallelTesting extends RunnerOrchestration { self =>
520520
}
521521

522522
protected def compileWithOtherCompiler(compiler: String, files: Array[JFile], flags: TestFlags, targetDir: JFile): TestReporter =
523-
val compilerDir = getCompiler(compiler).toString
523+
def artifactClasspath(organizationName: String, moduleName: String) =
524+
import coursier._
525+
val dep = Dependency(
526+
Module(
527+
Organization(organizationName),
528+
ModuleName(moduleName),
529+
attributes = Map.empty
530+
),
531+
version = compiler
532+
)
533+
Fetch()
534+
.addDependencies(dep)
535+
.run()
536+
.mkString(JFile.pathSeparator)
524537

525-
def substituteClasspath(old: String): String =
526-
old.split(JFile.pathSeparator).map { o =>
527-
if JFile(o) == JFile(Properties.dottyLibrary) then s"$compilerDir/lib/scala3-library_3-$compiler.jar"
528-
else o
529-
}.mkString(JFile.pathSeparator)
538+
val stdlibClasspath = artifactClasspath("org.scala-lang", "scala3-library_3")
539+
val scalacClasspath = artifactClasspath("org.scala-lang", "scala3-compiler_3")
530540

531-
val flags1 = flags.copy(defaultClassPath = substituteClasspath(flags.defaultClassPath))
541+
val flags1 = flags.copy(defaultClassPath = stdlibClasspath)
532542
.withClasspath(targetDir.getPath)
533543
.and("-d", targetDir.getPath)
534544

545+
val scalacCommand = Array("java", "-cp", scalacClasspath, "dotty.tools.dotc.Main")
546+
val command = scalacCommand ++ flags1.all ++ files.map(_.getAbsolutePath)
547+
val process = Runtime.getRuntime.exec(command)
548+
535549
val dummyStream = new PrintStream(new ByteArrayOutputStream())
536550
val reporter = TestReporter.reporter(dummyStream, ERROR)
537-
538-
val command = Array(compilerDir + "/bin/scalac") ++ flags1.all ++ files.map(_.getPath)
539-
val process = Runtime.getRuntime.exec(command)
540551
val errorsText = Source.fromInputStream(process.getErrorStream).mkString
541552
if process.waitFor() != 0 then
542553
val diagnostics = parseErrors(errorsText, compiler)
543-
diagnostics.foreach { diag =>
544-
val context = (new ContextBase).initialCtx
545-
reporter.report(diag)(using context)
546-
}
554+
if diagnostics.nonEmpty then
555+
diagnostics.foreach { diag =>
556+
val context = (new ContextBase).initialCtx
557+
reporter.report(diag)(using context)
558+
}
559+
else
560+
System.err.println(s"The attempt to compile files: ${files.mkString(", ")} failed unexpectedly.")
561+
System.err.println("Invoked command:")
562+
System.err.println(command.mkString(" "))
563+
System.err.println()
564+
System.err.println("Error log:")
565+
System.err.println(errorsText)
566+
System.err.println()
547567

548568
reporter
549569

@@ -1418,22 +1438,4 @@ object ParallelTesting {
14181438
def isTastyFile(f: JFile): Boolean =
14191439
f.getName.endsWith(".tasty")
14201440

1421-
def getCompiler(version: String): JFile =
1422-
val dir = cache.resolve(s"scala3-${version}").toFile
1423-
synchronized {
1424-
if dir.exists then
1425-
dir
1426-
else
1427-
import scala.sys.process._
1428-
val archivePath = cache.resolve(s"scala3-$version.tar.gz")
1429-
val compilerDownloadUrl = s"https://github.com/lampepfl/dotty/releases/download/$version/scala3-$version.tar.gz"
1430-
(URL(compilerDownloadUrl) #>> archivePath.toFile #&& s"tar -xf $archivePath -C $cache").!!
1431-
archivePath.toFile.delete()
1432-
dir
1433-
}
1434-
1435-
private lazy val cache =
1436-
val dir = Properties.testCache.resolve("compilers")
1437-
dir.toFile.mkdirs()
1438-
dir
14391441
}

project/Build.scala

Lines changed: 2 additions & 1 deletion
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)