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

Commit c33e1ad

Browse files
authored
Merge branch 'softwaremill:master' into master
2 parents 49076dd + 0050734 commit c33e1ad

File tree

5 files changed

+112
-24
lines changed

5 files changed

+112
-24
lines changed

.github/workflows/main.yaml

Lines changed: 59 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,92 @@ 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 }}
3352

53+
mima:
54+
# run on external PRs, but not on internal PRs since those will be run by push to branch
55+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
56+
runs-on: ubuntu-22.04
57+
steps:
58+
- name: Checkout
59+
uses: actions/checkout@v3
60+
with:
61+
fetch-depth: 0 # checkout tags so that dynver works properly (we need the version for MiMa)
62+
- name: Set up JDK 11
63+
uses: actions/setup-java@v3
64+
with:
65+
distribution: "temurin"
66+
java-version: 11
67+
cache: "sbt"
68+
- name: Check MiMa
69+
run: sbt $SBT_JAVA_OPTS -v mimaReportBinaryIssues
70+
3471
publish:
3572
name: Publish release
3673
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v'))
3774
needs: [build]
38-
runs-on: ubuntu-20.04
39-
env:
40-
JAVA_OPTS: -Xmx4G
75+
runs-on: ubuntu-22.04
4176
steps:
4277
- uses: actions/[email protected]
4378
with:
4479
fetch-depth: 0
4580
- uses: coursier/[email protected]
46-
- uses: olafurpg/setup-scala@v14
47-
- run: sbt ci-release
81+
- name: Set up JDK 11
82+
uses: actions/setup-java@v3
83+
with:
84+
distribution: "temurin"
85+
java-version: 11
86+
cache: "sbt"
87+
- name: Compile
88+
run: sbt $SBT_JAVA_OPTS compile
89+
- name: Publish artifacts
90+
run: sbt $SBT_JAVA_OPTS ci-release
4891
env:
4992
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
5093
PGP_SECRET: ${{ secrets.PGP_SECRET }}
@@ -66,5 +109,3 @@ jobs:
66109
version: "v${{ env.VERSION }}"
67110
env:
68111
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69-
70-

.sbtopts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-J-Xmx8G
2+
-J-Xss2M
3+
-Dsbt.task.timings=false

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![diffx](https://github.com/softwaremill/diffx/raw/master/banner.png)
22

3-
[![Build Status](https://img.shields.io/github/workflow/status/softwaremill/diffx/CI/master)](https://github.com/softwaremill/diffx/actions)
3+
[![Build Status](https://img.shields.io/github/actions/workflow/status/softwaremill/diffx/main.yaml?branch=master)](https://github.com/softwaremill/diffx/actions)
44
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.softwaremill.diffx/diffx-core_2.13/badge.svg)](https://search.maven.org/search?q=g:com.softwaremill.diffx)
55
[![diffx-core Scala version support](https://index.scala-lang.org/softwaremill/diffx/diffx-core/latest-by-scala-version.svg)](https://index.scala-lang.org/softwaremill/diffx/diffx-core)
66

build.sbt

Lines changed: 45 additions & 2 deletions
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,10 +15,19 @@ 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")),
2029
ideSkipProject := (scalaVersion.value != scalaIdeaVersion) || thisProjectRef.value.project.contains("JS"),
30+
mimaPreviousArtifacts := Set.empty, // we only use MiMa for `core` for now, using enableMimaSettings
2131
updateDocs := Def.taskDyn {
2232
val files1 = UpdateVersionInDocs(sLog.value, organization.value, version.value)
2333
Def.task {
@@ -32,6 +42,16 @@ compileDocs := {
3242
(docs.jvm(scala213) / mdoc).toTask(" --out target/diffx-docs").value
3343
}
3444

45+
val versioningSchemeSettings = Seq(versionScheme := Some("early-semver"))
46+
47+
val enableMimaSettings = Seq(
48+
mimaPreviousArtifacts := {
49+
val previous = previousStableVersion.value
50+
println(s"[info] Not a M or RC version, using previous version for MiMa check: $previous")
51+
previous.map(organization.value %% moduleName.value % _).toSet
52+
}
53+
)
54+
3555
val versionSpecificScalaSources = {
3656
Compile / unmanagedSourceDirectories := {
3757
val current = (Compile / unmanagedSourceDirectories).value
@@ -50,6 +70,7 @@ val versionSpecificScalaSources = {
5070

5171
lazy val core = (projectMatrix in file("core"))
5272
.settings(commonSettings)
73+
.settings(versioningSchemeSettings)
5374
.settings(
5475
name := "diffx-core",
5576
libraryDependencies ++= {
@@ -74,7 +95,8 @@ lazy val core = (projectMatrix in file("core"))
7495
versionSpecificScalaSources
7596
)
7697
.jvmPlatform(
77-
scalaVersions = List(scala212, scala213, scala3)
98+
scalaVersions = List(scala212, scala213, scala3),
99+
settings = enableMimaSettings
78100
)
79101
.jsPlatform(
80102
scalaVersions = List(scala212, scala213, scala3),
@@ -289,6 +311,19 @@ val allAggregates =
289311
def filterProject(p: String => Boolean) =
290312
ScopeFilter(inProjects(allAggregates.filter(pr => p(display(pr.project))): _*))
291313

314+
def filterByVersionAndPlatform(scalaVersionFilter: String, platformFilter: String) = filterProject { projectName =>
315+
val byPlatform =
316+
if (platformFilter == "JVM") !projectName.contains("JS") && !projectName.contains("Native")
317+
else projectName.contains(platformFilter)
318+
val byVersion = scalaVersionFilter match {
319+
case "2.13" => !projectName.contains("2_12") && !projectName.contains("3")
320+
case "2.12" => projectName.contains("2_12")
321+
case "3" => projectName.contains("3")
322+
}
323+
324+
byPlatform && byVersion && !projectName.contains("finatra")
325+
}
326+
292327
lazy val rootProject = project
293328
.in(file("."))
294329
.settings(commonSettings)
@@ -297,6 +332,14 @@ lazy val rootProject = project
297332
name := "diffx",
298333
scalaVersion := scalaIdeaVersion,
299334
testJVM := (Test / test).all(filterProject(p => !p.contains("JS") && !p.contains("Native"))).value,
300-
testJS := (Test / test).all(filterProject(_.contains("JS"))).value
335+
testJS := (Test / test).all(filterProject(_.contains("JS"))).value,
336+
compileScoped := Def.inputTaskDyn {
337+
val args = spaceDelimited("<arg>").parsed
338+
Def.taskDyn((Compile / compile).all(filterByVersionAndPlatform(args.head, args(1))))
339+
}.evaluated,
340+
testScoped := Def.inputTaskDyn {
341+
val args = spaceDelimited("<arg>").parsed
342+
Def.taskDyn((Test / test).all(filterByVersionAndPlatform(args.head, args(1))))
343+
}.evaluated
301344
)
302345
.aggregate(allAggregates: _*)

project/plugins.sbt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ 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")
10+
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.3")

0 commit comments

Comments
 (0)