Skip to content

Commit f44bc13

Browse files
committed
build cleanup, github actions
1 parent 86a5dee commit f44bc13

File tree

8 files changed

+173
-99
lines changed

8 files changed

+173
-99
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-92
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,35 @@
1-
import sbtcrossproject.CrossPlugin.autoImport.crossProject
2-
3-
val scala213Version = "2.13.4"
4-
val scala212Version = "2.12.12"
5-
val scala211Version = "2.11.12"
6-
val scala3Version = "3.0.0-RC1-bin-20210113-8345078-NIGHTLY"
7-
8-
inThisBuild(Seq(
9-
name := "Scala DOM Types",
10-
normalizedName := "domtypes",
11-
organization := "com.raquo",
12-
scalaVersion := scala3Version, //scala213Version,
13-
crossScalaVersions := Seq(scala3Version, scala213Version, scala212Version, scala211Version)
14-
))
15-
16-
// @TODO[WTF] Why can't this be inside releaseSettings?
17-
releaseCrossBuild := true
18-
19-
// @TODO[SBT] How to extract these shared settings into a separate release.sbt file?
20-
lazy val releaseSettings = Seq(
21-
homepage := Some(url("https://github.com/raquo/scala-dom-types")),
22-
licenses += ("MIT", url("https://github.com/raquo/scala-dom-types/blob/master/LICENSE.md")),
23-
scmInfo := Some(
24-
ScmInfo(
25-
url("https://github.com/raquo/scala-dom-types"),
26-
"scm:git@github.com/raquo/scala-dom-types.git"
27-
)
28-
),
29-
developers := List(
30-
Developer(
31-
id = "raquo",
32-
name = "Nikita Gazarov",
33-
email = "nikita@raquo.com",
34-
url = url("http://raquo.com")
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) ++= Seq(
13+
"-no-link-warnings" // Suppress scaladoc "Could not find any member to link for" warnings
14+
)
3515
)
36-
),
37-
sonatypeProfileName := "com.raquo",
38-
publishMavenStyle := true,
39-
publishArtifact in Test := false,
40-
publishTo := sonatypePublishTo.value,
41-
releaseCrossBuild := true,
42-
pomIncludeRepository := { _ => false },
43-
useGpg := false,
44-
releasePublishArtifactsAction := PgpKeys.publishSigned.value
45-
)
46-
47-
lazy val adjustScalacOptions = { options: Seq[String] =>
48-
options.filterNot(
49-
Set(
50-
"-Wdead-code",
51-
"-Wunused:implicits",
52-
"-Wunused:explicits",
53-
"-Wunused:imports",
54-
"-Wunused:params"
16+
.jsSettings(
17+
scalaJSLinkerConfig ~= { _.withSourceMap(false) },
18+
libraryDependencies ++= Seq(
19+
("org.scala-js" %%% "scalajs-dom" % "1.1.0").withDottyCompat(scalaVersion.value)
20+
)
5521
)
56-
)
57-
}
58-
5922

60-
lazy val scalacSettings = Seq(
61-
scalacOptions ~= adjustScalacOptions,
62-
// scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
63-
// case Some((3, _)) =>
64-
// Seq.empty
65-
// case _ =>
66-
// Seq(
67-
// "-Ymacro-annotations"
68-
// )
69-
// }),
23+
lazy val noPublish = Seq(
24+
publishLocal / skip := true,
25+
publish / skip := true,
26+
publishTo := Some(Resolver.file("Unused transient repository", file("target/unusedrepo")))
7027
)
7128

72-
lazy val commonSettings = releaseSettings ++ scalacSettings
73-
74-
lazy val root = project.in(file("."))
75-
.aggregate(domtypesJS, domtypesJVM)
76-
.settings(commonSettings)
77-
.settings(
78-
name := "Scala DOM Types",
79-
skip in publish := true
80-
)
81-
82-
lazy val domtypes = crossProject(JSPlatform, JVMPlatform).in(file("."))
83-
.settings(commonSettings)
84-
.jsConfigure(_.enablePlugins(ScalaJSBundlerPlugin))
85-
.jsSettings(
86-
scalaJSLinkerConfig ~= { _.withSourceMap(false) },
87-
requireJsDomEnv in Test := true,
88-
useYarn := true,
89-
libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match {
90-
case Some((3, _)) => Seq("org.scala-js" %%% "scalajs-dom" % "1.2.0.3M3-SNAPSHOT")
91-
case Some((2, _)) => Seq("org.scala-js" %%% "scalajs-dom" % "1.1.0")
92-
case _ => Seq.empty
93-
})
94-
)
95-
96-
lazy val domtypesJS = domtypes.js
97-
lazy val domtypesJVM = domtypes.jvm
29+
lazy val root =
30+
project.in(file("."))
31+
.aggregate(domtypes.js, domtypes.jvm)
32+
.settings(noPublish)
33+
.settings(
34+
name := "Scala DOM Types"
35+
)

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/plugins.sbt

+7-6
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.5.1")
44

55
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.2.0")
66

7-
// @TODO I don't think we need this plugin in this project
8-
addSbtPlugin("ch.epfl.scala" % s"sbt-scalajs-bundler" % "0.18.0")
9-
107
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
118

12-
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.1")
9+
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.2")
10+
11+
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.10")
12+
13+
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.16")
1314

14-
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.8")
15+
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.5")
1516

16-
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.3")
17+
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.10.0")

release.sbt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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 := sonatypePublishTo.value
9+
ThisBuild / releaseCrossBuild := true
10+
ThisBuild / releasePublishArtifactsAction := PgpKeys.publishSigned.value

version.sbt

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

0 commit comments

Comments
 (0)