Skip to content

Commit 0d8e4af

Browse files
[CI] Fix tests and detect snapshot verison on workflow_dispatch (#46)
* Update Scala versions * Detect Native snapshot to use from dispatch event payload * Fix Scala download links * Update Scala and LLVM versions * Replace sonatypeOssRepos with sonatypeCentralSnapshots * Fix integration/standalone test
1 parent d467f23 commit 0d8e4af

File tree

10 files changed

+41
-33
lines changed

10 files changed

+41
-33
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
matrix:
99
OS: [ubuntu-22.04, windows-2022]
1010
# Test using the same Scala 3 as used to publish ScalaNative artifacts
11-
scala: [2.12.18, 2.13.12, 3.1.3]
11+
scala: [2.12.20, 2.13.17, 3.1.3]
1212
steps:
1313
- uses: actions/checkout@v3
1414
- uses: coursier/cache-action@v6
@@ -30,7 +30,7 @@ jobs:
3030
3131
function InstallLLVM {
3232
Write-Host "Attempting to install LLVM (try $($retryCount + 1 - $global:retryAttempt) of $($retryCount + 1))..."
33-
choco install llvm --version=17.0.6 --allow-downgrade --force
33+
choco install llvm --version=21.1.0 --allow-downgrade --force
3434
}
3535
3636
# Attempt to install LLVM with retries

.github/workflows/publish.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ jobs:
1212
name: Publish
1313
runs-on: ubuntu-22.04
1414
if: github.repository == 'scala-native/scala-native-cli'
15+
env:
16+
# Present only for repository_dispatch; empty for tag push / manual runs
17+
CI_NATIVE_VERSION: ${{ github.event.client_payload.version || '' }}
1518
steps:
1619
- uses: actions/checkout@v3
1720
- uses: coursier/cache-action@v6
1821
- uses: coursier/setup-action@v1
1922
with:
2023
jvm: adopt:8
24+
apps: sbt
2125

2226
- name: Setup PGP Key
2327
run: |

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ bin/
2727

2828
# vim
2929
*.swp
30+
**/*.DS_Store

build.sbt

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
val ScalaNativeVersion = "0.5.9-SNAPSHOT"
1+
import scala.util.Properties.envOrNone
2+
import scala.scalanative.nir.Proxy.nativeBinaryVersion
3+
4+
val ScalaNativeVersion = envOrNone("CI_NATIVE_VERSION")
5+
.filterNot(_.isEmpty)
6+
.getOrElse("0.5.8")
27

38
val crossScalaVersions212 = (14 to 20).map("2.12." + _)
4-
val crossScalaVersions213 = (8 to 16).map("2.13." + _)
9+
val crossScalaVersions213 = (8 to 17).map("2.13." + _)
510
val crossScalaVersions3 =
611
(2 to 3).map("3.1." + _) ++
712
(0 to 2).map("3.2." + _) ++
8-
(0 to 6).map("3.3." + _) ++
13+
(0 to 7).map("3.3." + _) ++
914
(0 to 3).map("3.4." + _) ++
1015
(0 to 2).map("3.5." + _) ++
1116
(2 to 4).map("3.6." + _) ++
12-
(0 to 1).map("3.7." + _) ++
17+
(0 to 3).map("3.7." + _) ++
1318
Nil
1419

1520
val scala2_12 = crossScalaVersions212.last
@@ -100,9 +105,6 @@ inThisBuild(
100105
Some("scm:git:git@github.com:scala-native/scala-native-cli.git")
101106
)
102107
),
103-
// Used during the releases
104-
resolvers += "Sonatype Central Deployments" at "https://central.sonatype.com/api/v1/publisher/deployments/download/",
105-
resolvers ++= Resolver.sonatypeOssRepos("snapshots"),
106108
resolvers += Resolver.sonatypeCentralSnapshots,
107109
resolvers += Resolver.mavenCentral,
108110
resolvers += Resolver.defaultLocal
@@ -120,11 +122,10 @@ lazy val cli = project
120122
crossScalaVersions := publishScalaVersions,
121123
Compile / run / mainClass :=
122124
Some("scala.scalanative.cli.ScalaNativeLd"),
123-
scalacOptions += "-Ywarn-unused:imports",
124-
scalacOptions ++= CrossVersion.partialVersion(scalaVersion.value).collect {
125-
case (2, _) => "-target:jvm-1.8"
126-
case (3, _) => "-Xtarget:8"
127-
},
125+
scalacOptions ++= Seq(
126+
"-release:8",
127+
"-Ywarn-unused:imports"
128+
),
128129
libraryDependencies ++= Seq(
129130
"org.scala-native" %% "tools" % scalaNativeVersion.value,
130131
"com.github.scopt" %% "scopt" % "4.0.1",
@@ -170,13 +171,6 @@ lazy val cliScriptedTests = project
170171
}
171172
)
172173

173-
def nativeBinaryVersion(version: String): String = {
174-
val VersionPattern = raw"(\d+)\.(\d+)\.(\d+)(\-.*)?".r
175-
val VersionPattern(major, minor, patch, milestone) = version
176-
if (patch != null && milestone != null) version
177-
else s"$major.$minor"
178-
}
179-
180174
val nativeSourceExtensions = Set(".c", ".cpp", ".cxx", ".h", ".hpp", ".S")
181175
val DeduplicateOrRename = new sbtassembly.MergeStrategy {
182176
def name: String = "deduplicate-or-rename"
@@ -230,7 +224,7 @@ lazy val cliPackSettings = Def.settings(
230224
val lm = {
231225
import sbt.librarymanagement.ivy._
232226
val ivyConfig = InlineIvyConfiguration()
233-
.withResolvers(resolvers.value.toVector)
227+
.withResolvers((ThisBuild / resolvers).value.toVector)
234228
.withLog(log)
235229
IvyDependencyResolution(ivyConfig)
236230
}
@@ -312,9 +306,7 @@ lazy val sonatypePublishSettings = Def.settings(
312306
publishMavenStyle := true,
313307
pomIncludeRepository := (_ => false),
314308
publishTo := {
315-
val centralSnapshots =
316-
"https://central.sonatype.com/repository/maven-snapshots/"
317-
if (isSnapshot.value) Some("central-snapshots" at centralSnapshots)
309+
if (isSnapshot.value) Some(Resolver.sonatypeCentralSnapshots)
318310
else localStaging.value
319311
},
320312
credentials ++= {

cli/src/sbt-test/integration/cli/build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
resolvers ++= Resolver.sonatypeOssRepos("snapshots")
1+
resolvers += Resolver.sonatypeCentralSnapshots
22
enablePlugins(ScalaNativePlugin)
33

44
import sbt._

cli/src/sbt-test/integration/cli/project/build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
resolvers ++= Resolver.sonatypeOssRepos("snapshots")
1+
resolvers += Resolver.sonatypeCentralSnapshots
22

33
val pluginVersion = System.getProperty("plugin.version")
44
if (pluginVersion == null)

cli/src/sbt-test/integration/standalone/build.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ runScript := {
4747
if (!scalaBinDir.exists) {
4848
val downloadUrl =
4949
if (ver.startsWith("3."))
50-
s"https://github.com/lampepfl/dotty/releases/download/$ver/$scalaDir.zip"
50+
s"https://github.com/scala/scala3/releases/download/$ver/$scalaDir.zip"
5151
else
52-
s"https://downloads.lightbend.com/scala/${ver}/$scalaDir.zip"
52+
s"https://github.com/scala/scala/releases/download/v${ver}/${scalaDir}.zip"
5353
IO.unzipURL(url(downloadUrl), cacheDir)
5454
}
5555
// Make sure we can execute scala/scalac from downloaded distro

cli/src/sbt-test/integration/standalone/test

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ $ exists Foo$.nir
1616
-> runScript scala-native-p --from-path notExisting.nir
1717

1818
# Move nir file to directory outside classpath
19-
$ mkdir ../scala-native-test/
20-
$ copy-file Foo.nir ../scala-native-test//Foo2.nir
21-
$ exists ../scala-native-test/Foo2.nir
22-
> runScript scala-native-p --from-path ../scala-native-test/Foo2.nir
19+
$ mkdir scala-native-test/
20+
$ copy-file Foo.nir scala-native-test/Foo2.nir
21+
$ exists scala-native-test/Foo2.nir
22+
> runScript scala-native-p --from-path scala-native-test/Foo2.nir
2323

2424
> runExec jar cf inside.jar Foo.class Foo.nir Foo$.class Foo$.nir
2525
> runScript scala-native-p --cp inside.jar --from-path Foo.nir Foo$.nir

project/Internals.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package scala.scalanative
2+
3+
// Proxy to package private methods
4+
package nir {
5+
object Proxy {
6+
def nativeBinaryVersion(version: String) = Versions.binaryVersion(version)
7+
}
8+
}

project/plugins.sbt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.0.0")
22
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
33
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.0")
4+
5+
// Used only to access cross-version utilities
6+
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.5.8")

0 commit comments

Comments
 (0)