Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit 4bcb54b

Browse files
Update scala-js and other sbt plugins (#447)
--------- Co-authored-by: ghostbuster91 <[email protected]>
1 parent 428a522 commit 4bcb54b

File tree

4 files changed

+78
-22
lines changed

4 files changed

+78
-22
lines changed

.github/workflows/main.yaml

+41-18
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,50 @@ name: CI
22

33
on:
44
push:
5-
branches: [ "**" ]
6-
tags: [ v* ]
5+
branches: ["**"]
6+
tags: [v*]
77
pull_request:
8-
branches: [ "**" ]
9-
8+
branches: ["**"]
9+
env:
10+
# .sbtopts specifies 8g, which is needed to import into IntelliJ, but on GH that exceeds the maximum available memory
11+
SBT_JAVA_OPTS: -J-Xms4g -J-Xmx4g
1012
jobs:
1113
build:
12-
runs-on: ubuntu-20.04
13-
env:
14-
JAVA_OPTS: -Xmx4G
14+
# run on external PRs, but not on internal PRs since those will be run by push to branch
15+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
16+
runs-on: ubuntu-22.04
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
scala-version: ["2.12", "2.13", "3"]
21+
target-platform: ["JVM", "JS"]
1522
steps:
1623
- uses: actions/[email protected]
1724
- uses: coursier/[email protected]
18-
- uses: coursier/[email protected]
25+
- name: Set up JDK 11
26+
uses: actions/setup-java@v3
1927
with:
20-
jvm: zulu:17
21-
- name: Run tests with sbt
22-
run: sbt test
28+
distribution: "temurin"
29+
cache: "sbt"
30+
java-version: 11
31+
- uses: coursier/[email protected]
32+
- name: Compile
33+
run: sbt $SBT_JAVA_OPTS -v "compileScoped ${{ matrix.scala-version }} ${{ matrix.target-platform }}"
2334
- name: Compile docs
35+
if: matrix.target-platform == 'JVM'
2436
run: sbt compileDocs
37+
- name: Test
38+
run: sbt $SBT_JAVA_OPTS -v "testScoped ${{ matrix.scala-version }} ${{ matrix.target-platform }}"
2539
- name: Generate LSIF
40+
if: matrix.target-platform == 'JVM' && matrix.scala-version == 2.13
2641
run: cs launch com.sourcegraph:scip-java_2.13:0.8.2 -- index
2742
- name: Install sourcegraph/src
43+
if: matrix.target-platform == 'JVM' && matrix.scala-version == 2.13
44+
2845
run: yarn global add @sourcegraph/src
2946
- name: Upload LSIF data
47+
if: matrix.target-platform == 'JVM' && matrix.scala-version == 2.13
48+
3049
run: src code-intel upload -trace=3 -root . -file index.scip -github-token $GITHUB_TOKEN
3150
env:
3251
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -35,16 +54,22 @@ jobs:
3554
name: Publish release
3655
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v'))
3756
needs: [build]
38-
runs-on: ubuntu-20.04
39-
env:
40-
JAVA_OPTS: -Xmx4G
57+
runs-on: ubuntu-22.04
4158
steps:
4259
- uses: actions/[email protected]
4360
with:
4461
fetch-depth: 0
4562
- uses: coursier/[email protected]
46-
- uses: olafurpg/setup-scala@v14
47-
- run: sbt ci-release
63+
- name: Set up JDK 11
64+
uses: actions/setup-java@v3
65+
with:
66+
distribution: "temurin"
67+
java-version: 11
68+
cache: "sbt"
69+
- name: Compile
70+
run: sbt $SBT_JAVA_OPTS compile
71+
- name: Publish artifacts
72+
run: sbt $SBT_JAVA_OPTS ci-release
4873
env:
4974
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
5075
PGP_SECRET: ${{ secrets.PGP_SECRET }}
@@ -66,5 +91,3 @@ jobs:
6691
version: "v${{ env.VERSION }}"
6792
env:
6893
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69-
70-

.sbtopts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-J-Xmx8G
2+
-J-Xss2M
3+
-Dsbt.task.timings=false

build.sbt

+31-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import sbt.Def
33
import sbt.Reference.display
44
import com.softwaremill.SbtSoftwareMillCommon.commonSmlBuildSettings
55
import com.softwaremill.Publish.{ossPublishSettings, updateDocs}
6+
import complete.DefaultParsers._
67

78
val scala212 = "2.12.16"
89
val scala213 = "2.13.8"
@@ -14,6 +15,14 @@ val scalatestVersion = "3.2.12"
1415
val specs2Version = "4.16.1"
1516
val smlTaggingVersion = "2.3.3"
1617

18+
val scopesDescription = "Scala version can be: 2.12, 2.13, 3; platform: JVM, JS, Native"
19+
val compileScoped =
20+
inputKey[Unit](
21+
s"Compiles sources in the given scope. Usage: compileScoped [scala version] [platform]. $scopesDescription"
22+
)
23+
val testScoped =
24+
inputKey[Unit](s"Run tests in the given scope. Usage: testScoped [scala version] [platform]. $scopesDescription")
25+
1726
lazy val commonSettings: Seq[Def.Setting[_]] = commonSmlBuildSettings ++ ossPublishSettings ++ Seq(
1827
organization := "com.softwaremill.diffx",
1928
scmInfo := Some(ScmInfo(url("https://github.com/softwaremill/diffx"), "[email protected]:softwaremill/diffx.git")),
@@ -272,6 +281,19 @@ val allAggregates =
272281
def filterProject(p: String => Boolean) =
273282
ScopeFilter(inProjects(allAggregates.filter(pr => p(display(pr.project))): _*))
274283

284+
def filterByVersionAndPlatform(scalaVersionFilter: String, platformFilter: String) = filterProject { projectName =>
285+
val byPlatform =
286+
if (platformFilter == "JVM") !projectName.contains("JS") && !projectName.contains("Native")
287+
else projectName.contains(platformFilter)
288+
val byVersion = scalaVersionFilter match {
289+
case "2.13" => !projectName.contains("2_12") && !projectName.contains("3")
290+
case "2.12" => projectName.contains("2_12")
291+
case "3" => projectName.contains("3")
292+
}
293+
294+
byPlatform && byVersion && !projectName.contains("finatra")
295+
}
296+
275297
lazy val rootProject = project
276298
.in(file("."))
277299
.settings(commonSettings)
@@ -280,6 +302,14 @@ lazy val rootProject = project
280302
name := "diffx",
281303
scalaVersion := scalaIdeaVersion,
282304
testJVM := (Test / test).all(filterProject(p => !p.contains("JS") && !p.contains("Native"))).value,
283-
testJS := (Test / test).all(filterProject(_.contains("JS"))).value
305+
testJS := (Test / test).all(filterProject(_.contains("JS"))).value,
306+
compileScoped := Def.inputTaskDyn {
307+
val args = spaceDelimited("<arg>").parsed
308+
Def.taskDyn((Compile / compile).all(filterByVersionAndPlatform(args.head, args(1))))
309+
}.evaluated,
310+
testScoped := Def.inputTaskDyn {
311+
val args = spaceDelimited("<arg>").parsed
312+
Def.taskDyn((Test / test).all(filterByVersionAndPlatform(args.head, args(1))))
313+
}.evaluated
284314
)
285315
.aggregate(allAggregates: _*)

project/plugins.sbt

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ addSbtPlugin("com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-common" % "
22
addSbtPlugin("com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-publish" % "2.0.9")
33
addSbtPlugin("com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-extra" % "2.0.9")
44

5-
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.1")
6-
addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.9.0")
7-
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.2")
5+
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.13.2")
6+
addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.9.1")
7+
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.7")
88

99
addSbtPlugin("org.jetbrains.scala" % "sbt-ide-settings" % "1.1.1")

0 commit comments

Comments
 (0)