Skip to content

Commit 39e286c

Browse files
authored
Scala 3 crossbuild (#190)
1 parent cdd6c3d commit 39e286c

File tree

5 files changed

+54
-20
lines changed

5 files changed

+54
-20
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
strategy:
2424
matrix:
2525
os: [ubuntu-latest]
26-
scala: [2.12.13, 2.13.4]
26+
scala: [2.12.13, 2.13.4, 3.0.0-RC1]
2727
java: [adopt@1.8]
2828
runs-on: ${{ matrix.os }}
2929
steps:
@@ -71,7 +71,7 @@ jobs:
7171
strategy:
7272
matrix:
7373
os: [ubuntu-latest]
74-
scala: [2.12.12]
74+
scala: [2.13.4]
7575
java: [adopt@1.8]
7676
runs-on: ${{ matrix.os }}
7777
steps:
@@ -117,6 +117,16 @@ jobs:
117117
tar xf targets.tar
118118
rm targets.tar
119119
120+
- name: Download target directories (3.0.0-RC1)
121+
uses: actions/download-artifact@v2
122+
with:
123+
name: target-${{ matrix.os }}-3.0.0-RC1-${{ matrix.java }}
124+
125+
- name: Inflate target directories (3.0.0-RC1)
126+
run: |
127+
tar xf targets.tar
128+
rm targets.tar
129+
120130
- uses: olafurpg/setup-gpg@v3
121131

122132
- env:

build.sbt

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@ import sbtcrossproject.CrossPlugin.autoImport.crossProject
44

55
ThisBuild / githubWorkflowPublishTargetBranches := Seq()
66

7-
ThisBuild / crossScalaVersions := Seq("2.12.13", "2.13.4")
7+
ThisBuild / crossScalaVersions := Seq("2.12.13", "2.13.4", "3.0.0-RC1")
88

9-
lazy val commonSettings = Def.settings(
10-
scalaVersion := "2.13.1",
11-
crossScalaVersions := (ThisBuild / crossScalaVersions).value
12-
)
9+
ThisBuild / scalaVersion := "2.13.4"
1310

1411
lazy val root = project.in(file(".")).aggregate(js, jvm).
1512
settings(
1613
name := "mouse",
17-
commonSettings,
1814
publish / skip := true,
1915
sonatypeProfileName := "org.typelevel",
2016
releaseCrossBuild := true
@@ -24,13 +20,11 @@ lazy val cross = crossProject(JSPlatform, JVMPlatform).in(file(".")).
2420
settings(
2521
name := "mouse",
2622
organization := "org.typelevel",
27-
commonSettings,
2823
sonatypeProfileName := "org.typelevel",
2924
libraryDependencies ++= Seq(
3025
"org.typelevel" %%% "cats-core" % "2.4.2",
3126
"org.scalatest" %%% "scalatest" % "3.2.5" % Test,
32-
"org.scalatestplus" %%% "scalacheck-1-15" % "3.2.5.0" % Test,
33-
compilerPlugin("org.typelevel" %% "kind-projector" % "0.11.3" cross CrossVersion.full)
27+
"org.scalatestplus" %%% "scalacheck-1-15" % "3.2.5.0" % Test
3428
),
3529
licenses += ("MIT license", url("http://opensource.org/licenses/MIT")),
3630
homepage := Some(url("https://github.com/typelevel/mouse")),
@@ -39,11 +33,19 @@ lazy val cross = crossProject(JSPlatform, JVMPlatform).in(file(".")).
3933
scalacOptions ++= Seq("-feature", "-deprecation", "-language:implicitConversions", "-language:higherKinds"),
4034
scalacOptions ++= {
4135
scalaVersion.value match {
42-
case v if v.startsWith("2.13") => Nil
43-
case _ => Seq("-Ypartial-unification")
36+
case v if v.startsWith("2.12") => Seq("-Ypartial-unification")
37+
case v if v.startsWith("3") => Seq("-source", "3.0-migration")
38+
case _ => Nil
4439
}
4540
},
4641
Test / publishArtifact := false,
42+
Compile / doc / sources := {
43+
val old = (Compile / doc / sources).value
44+
if (isDotty.value)
45+
Seq()
46+
else
47+
old
48+
},
4749
pomIncludeRepository := { _ => false },
4850
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
4951
releaseProcess := Seq[ReleaseStep](
@@ -59,6 +61,10 @@ lazy val cross = crossProject(JSPlatform, JVMPlatform).in(file(".")).
5961
commitNextVersion,
6062
)
6163
)
64+
.jsSettings(
65+
crossScalaVersions := (ThisBuild / crossScalaVersions).value.filter(_.startsWith("2")),
66+
publishConfiguration := publishConfiguration.value.withOverwrite(true)
67+
)
6268

6369
ThisBuild / githubWorkflowTargetTags ++= Seq("v*")
6470
ThisBuild / githubWorkflowPublishTargetBranches :=

project/plugins.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.11")
55
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
66
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.10.1")
77
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.5")
8+
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.5.3")

shared/src/test/scala/mouse/AnyFSyntaxTest.scala

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,36 @@ import cats.{Id, ~>}
66

77
class AnyFSyntaxTest extends MouseSuite {
88

9-
val emptyK: List ~> List = λ[List ~> List](_ => Nil)
9+
val emptyK = new (List ~> List) {
10+
def apply[A](x: List[A]) = Nil
11+
}
1012

11-
val double: List ~> List = λ[List ~> List](list => list ::: list)
13+
val double = new (List ~> List) {
14+
def apply[A](x: List[A]) = x ::: x
15+
}
16+
17+
type E[B] = Either[String, B]
18+
val toRight = new (Option ~> E) {
19+
def apply[A](x: Option[A]) = x.toRight("foo")
20+
}
21+
22+
val headOption = new (List ~> Option) {
23+
def apply[A](x: List[A]) = x.headOption
24+
}
25+
26+
val optionGet = new (Option ~> Id) {
27+
def apply[A](x: Option[A]) = x.get
28+
}
1229

1330
List(1, 2, 3) thrushK emptyK shouldEqual Nil
1431

1532
List(5, 10) thrushK double shouldEqual List(5, 10, 5, 10)
1633

17-
"thing".some thrushK (λ[Option ~> Either[String, *]](_.toRight("foo"))) shouldEqual Right(
34+
"thing".some thrushK toRight shouldEqual Right(
1835
"thing"
1936
)
2037

2138
(List("This") ||> double
22-
||> λ[List ~> Option](_.headOption)
23-
||> λ[Option ~> Id](_.head)) shouldEqual "This"
39+
||> headOption
40+
||> optionGet) shouldEqual "This"
2441
}

shared/src/test/scala/mouse/MouseSuite.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ trait MouseSuite
1414
with ScalaCheckDrivenPropertyChecks
1515
with AllSharedSyntax
1616
with AllInstances {
17-
implicit val eq0 = new Eq[NumberFormatException] {
17+
implicit val eq0: Eq[NumberFormatException] = new Eq[NumberFormatException] {
1818
override def eqv(x: NumberFormatException, y: NumberFormatException): Boolean =
1919
x.getMessage == y.getMessage
2020
}
2121

22-
implicit val eq1 = new Eq[IllegalArgumentException] {
22+
implicit val eq1: Eq[IllegalArgumentException] = new Eq[IllegalArgumentException] {
2323
override def eqv(x: IllegalArgumentException, y: IllegalArgumentException): Boolean =
2424
x.getMessage == y.getMessage
2525
}

0 commit comments

Comments
 (0)