Skip to content

Commit 65ad441

Browse files
yuriquescalavision
andauthored
Build: Initial attempt to upgrade to scala3 rc1 (#64)
Co-authored-by: Scalavision <scalavision@gmail.com>
1 parent 75b1d3e commit 65ad441

File tree

9 files changed

+172
-98
lines changed

9 files changed

+172
-98
lines changed

.github/workflows/ci.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# This file was automatically generated by sbt-github-actions using the
2+
# githubWorkflowGenerate task. You should add and commit this file to
3+
# your git repository. It goes without saying that you shouldn't edit
4+
# this file by hand! Instead, if you wish to make changes, you should
5+
# change your sbt build configuration to revise the workflow description
6+
# to meet your needs, then regenerate this file.
7+
8+
name: Continuous Integration
9+
10+
on:
11+
pull_request:
12+
branches: ['*']
13+
push:
14+
branches: ['*']
15+
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
19+
jobs:
20+
build:
21+
name: Build and Test
22+
strategy:
23+
matrix:
24+
os: [ubuntu-latest]
25+
scala:
26+
- 3.0.0-RC1-bin-20210113-8345078-NIGHTLY
27+
- 2.13.4
28+
- 2.12.12
29+
- 2.11.12
30+
java: [adopt@1.8]
31+
runs-on: ${{ matrix.os }}
32+
steps:
33+
- name: Checkout current branch (full)
34+
uses: actions/checkout@v2
35+
with:
36+
fetch-depth: 0
37+
38+
- name: Setup Java and Scala
39+
uses: olafurpg/setup-scala@v10
40+
with:
41+
java-version: ${{ matrix.java }}
42+
43+
- name: Cache sbt
44+
uses: actions/cache@v2
45+
with:
46+
path: |
47+
~/.sbt
48+
~/.ivy2/cache
49+
~/.coursier/cache/v1
50+
~/.cache/coursier/v1
51+
~/AppData/Local/Coursier/Cache/v1
52+
~/Library/Caches/Coursier/v1
53+
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
54+
55+
- name: Check that workflows are up to date
56+
run: sbt ++${{ matrix.scala }} githubWorkflowCheck
57+
58+
- name: Build project
59+
run: sbt ++${{ matrix.scala }} test

.github/workflows/clean.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# This file was automatically generated by sbt-github-actions using the
2+
# githubWorkflowGenerate task. You should add and commit this file to
3+
# your git repository. It goes without saying that you shouldn't edit
4+
# this file by hand! Instead, if you wish to make changes, you should
5+
# change your sbt build configuration to revise the workflow description
6+
# to meet your needs, then regenerate this file.
7+
8+
name: Clean
9+
10+
on: push
11+
12+
jobs:
13+
delete-artifacts:
14+
name: Delete Artifacts
15+
runs-on: ubuntu-latest
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
steps:
19+
- name: Delete artifacts
20+
run: |
21+
# Customize those three lines with your repository and credentials:
22+
REPO=${GITHUB_API_URL}/repos/${{ github.repository }}
23+
24+
# A shortcut to call GitHub API.
25+
ghapi() { curl --silent --location --user _:$GITHUB_TOKEN "$@"; }
26+
27+
# A temporary file which receives HTTP response headers.
28+
TMPFILE=/tmp/tmp.$$
29+
30+
# An associative array, key: artifact name, value: number of artifacts of that name.
31+
declare -A ARTCOUNT
32+
33+
# Process all artifacts on this repository, loop on returned "pages".
34+
URL=$REPO/actions/artifacts
35+
while [[ -n "$URL" ]]; do
36+
37+
# Get current page, get response headers in a temporary file.
38+
JSON=$(ghapi --dump-header $TMPFILE "$URL")
39+
40+
# Get URL of next page. Will be empty if we are at the last page.
41+
URL=$(grep '^Link:' "$TMPFILE" | tr ',' '\n' | grep 'rel="next"' | head -1 | sed -e 's/.*<//' -e 's/>.*//')
42+
rm -f $TMPFILE
43+
44+
# Number of artifacts on this page:
45+
COUNT=$(( $(jq <<<$JSON -r '.artifacts | length') ))
46+
47+
# Loop on all artifacts on this page.
48+
for ((i=0; $i < $COUNT; i++)); do
49+
50+
# Get name of artifact and count instances of this name.
51+
name=$(jq <<<$JSON -r ".artifacts[$i].name?")
52+
ARTCOUNT[$name]=$(( $(( ${ARTCOUNT[$name]} )) + 1))
53+
54+
id=$(jq <<<$JSON -r ".artifacts[$i].id?")
55+
size=$(( $(jq <<<$JSON -r ".artifacts[$i].size_in_bytes?") ))
56+
printf "Deleting '%s' #%d, %'d bytes\n" $name ${ARTCOUNT[$name]} $size
57+
ghapi -X DELETE $REPO/actions/artifacts/$id
58+
done
59+
done

build.sbt

+30-90
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,36 @@
1-
import sbtcrossproject.CrossPlugin.autoImport.crossProject
2-
3-
inThisBuild(Seq(
4-
name := "Scala DOM Types",
5-
normalizedName := "domtypes",
6-
organization := "com.raquo",
7-
scalaVersion := "2.12.12",
8-
crossScalaVersions := Seq("2.11.12", "2.12.12", "2.13.4")
9-
))
10-
11-
// @TODO[WTF] Why can't this be inside releaseSettings?
12-
releaseCrossBuild := true
13-
14-
// @TODO[SBT] How to extract these shared settings into a separate release.sbt file?
15-
lazy val releaseSettings = Seq(
16-
homepage := Some(url("https://github.com/raquo/scala-dom-types")),
17-
licenses += ("MIT", url("https://github.com/raquo/scala-dom-types/blob/master/LICENSE.md")),
18-
scmInfo := Some(
19-
ScmInfo(
20-
url("https://github.com/raquo/scala-dom-types"),
21-
"scm:git@github.com/raquo/scala-dom-types.git"
1+
ThisBuild / scalaVersion := ScalaVersions.v213
2+
ThisBuild / crossScalaVersions := Seq(ScalaVersions.v3RC1, ScalaVersions.v213, ScalaVersions.v212, ScalaVersions.v211)
3+
4+
lazy val domtypes =
5+
crossProject(JSPlatform, JVMPlatform).in(file("."))
6+
.settings(
7+
scalacOptions ~= (_.filterNot(Set(
8+
"-Wunused:params",
9+
"-Ywarn-unused:params",
10+
"-Wunused:explicits"
11+
))),
12+
scalacOptions in (Compile, doc) ~= (_.filter(_.startsWith("-Xplugin"))),
13+
scalacOptions in (Compile, doc) ++= Seq(
14+
"-no-link-warnings" // Suppress scaladoc "Could not find any member to link for" warnings
15+
)
2216
)
23-
),
24-
developers := List(
25-
Developer(
26-
id = "raquo",
27-
name = "Nikita Gazarov",
28-
email = "nikita@raquo.com",
29-
url = url("http://raquo.com")
17+
.jsSettings(
18+
scalaJSLinkerConfig ~= { _.withSourceMap(false) },
19+
libraryDependencies ++= Seq(
20+
("org.scala-js" %%% "scalajs-dom" % "1.1.0").withDottyCompat(scalaVersion.value)
21+
)
3022
)
31-
),
32-
sonatypeProfileName := "com.raquo",
33-
publishMavenStyle := true,
34-
publishArtifact in Test := false,
35-
publishTo := sonatypePublishTo.value,
36-
releaseCrossBuild := true,
37-
pomIncludeRepository := { _ => false },
38-
useGpg := false,
39-
releasePublishArtifactsAction := PgpKeys.publishSigned.value
40-
)
41-
4223

43-
val baseScalacSettings =
44-
"-encoding" :: "UTF-8" ::
45-
"-unchecked" ::
46-
"-deprecation" ::
47-
"-explaintypes" ::
48-
"-feature" ::
49-
"-language:_" ::
50-
"-Xfuture" ::
51-
"-Xlint" ::
52-
"-Yno-adapted-args" ::
53-
"-Ywarn-value-discard" ::
54-
"-Ywarn-unused" ::
55-
Nil
56-
57-
lazy val scalacSettings = Seq(
58-
scalacOptions ++= {
59-
CrossVersion.partialVersion(scalaVersion.value) match {
60-
case Some((2, 13)) =>
61-
baseScalacSettings.diff(
62-
"-Xfuture" ::
63-
"-Yno-adapted-args" ::
64-
"-Ywarn-infer-any" ::
65-
"-Ywarn-nullary-override" ::
66-
"-Ywarn-nullary-unit" ::
67-
Nil
68-
)
69-
case _ => baseScalacSettings
70-
}
71-
}
24+
lazy val noPublish = Seq(
25+
publishLocal / skip := true,
26+
publish / skip := true,
27+
publishTo := Some(Resolver.file("Unused transient repository", file("target/unusedrepo")))
7228
)
7329

74-
lazy val commonSettings = releaseSettings ++ scalacSettings
75-
76-
lazy val root = project.in(file("."))
77-
.aggregate(domtypesJS, domtypesJVM)
78-
.settings(commonSettings)
79-
.settings(
80-
skip in publish := true
81-
)
82-
83-
lazy val domtypes = crossProject(JSPlatform, JVMPlatform).in(file("."))
84-
.settings(commonSettings)
85-
.jsConfigure(_.enablePlugins(ScalaJSBundlerPlugin))
86-
.jsSettings(
87-
scalaJSLinkerConfig ~= { _.withSourceMap(false) },
88-
requireJsDomEnv in Test := true,
89-
useYarn := true,
90-
libraryDependencies ++= Seq(
91-
"org.scala-js" %%% "scalajs-dom" % "1.0.0"
30+
lazy val root =
31+
project.in(file("."))
32+
.aggregate(domtypes.js, domtypes.jvm)
33+
.settings(noPublish)
34+
.settings(
35+
name := "Scala DOM Types"
9236
)
93-
)
94-
95-
lazy val domtypesJS = domtypes.js
96-
lazy val domtypesJVM = domtypes.jvm

github.sbt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ThisBuild / githubWorkflowPublishTargetBranches := Seq()

project/ScalaVersions.scala

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object ScalaVersions {
2+
val v211 = "2.11.12"
3+
val v213 = "2.13.4"
4+
val v212 = "2.12.12"
5+
val v3RC1 = "3.0.0-RC1-bin-20210113-8345078-NIGHTLY"
6+
}

project/build.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version = 1.4.5
1+
sbt.version = 1.4.6

project/plugins.sbt

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
logLevel := Level.Warn
22

3-
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.0.1")
3+
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.5.1")
44

5-
// @TODO I don't think we need this plugin in this project
6-
addSbtPlugin("ch.epfl.scala" % s"sbt-scalajs-bundler" % "0.17.0")
5+
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.3.1")
76

87
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
98

10-
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.1")
9+
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.2")
1110

12-
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.8")
11+
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.16")
1312

14-
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.3")
13+
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.5")
14+
15+
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.10.0")

release.sbt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ThisBuild / organization := "com.raquo"
2+
ThisBuild / homepage := Some(url("https://github.com/raquo/scala-dom-types"))
3+
ThisBuild / licenses += "MIT" -> url("https://github.com/raquo/scala-dom-types/blob/master/LICENSE.md")
4+
ThisBuild / scmInfo := Some(ScmInfo(url("https://github.com/raquo/scala-dom-types"), "scm:git@github.com/raquo/scala-dom-types.git"))
5+
ThisBuild / developers += Developer("raquo", "Nikita Gazarov", "nikita@raquo.com", url("http://raquo.com"))
6+
ThisBuild / sonatypeProfileName := "com.raquo"
7+
ThisBuild / publishArtifact in Test := false
8+
ThisBuild / publishTo := sonatypePublishToBundle.value

version.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version in ThisBuild := "0.11.1-SNAPSHOT"
1+
version in ThisBuild := "0.12.0-SNAPSHOT"

0 commit comments

Comments
 (0)