Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scala 3 crossbuild #190

Merged
merged 1 commit into from
Mar 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12.13, 2.13.4]
scala: [2.12.13, 2.13.4, 3.0.0-RC1]
java: [[email protected]]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12.12]
scala: [2.13.4]
java: [[email protected]]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -117,6 +117,16 @@ jobs:
tar xf targets.tar
rm targets.tar

- name: Download target directories (3.0.0-RC1)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-3.0.0-RC1-${{ matrix.java }}

- name: Inflate target directories (3.0.0-RC1)
run: |
tar xf targets.tar
rm targets.tar

- uses: olafurpg/setup-gpg@v3

- env:
Expand Down
28 changes: 17 additions & 11 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@ import sbtcrossproject.CrossPlugin.autoImport.crossProject

ThisBuild / githubWorkflowPublishTargetBranches := Seq()

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

lazy val commonSettings = Def.settings(
scalaVersion := "2.13.1",
crossScalaVersions := (ThisBuild / crossScalaVersions).value
)
ThisBuild / scalaVersion := "2.13.4"

lazy val root = project.in(file(".")).aggregate(js, jvm).
settings(
name := "mouse",
commonSettings,
publish / skip := true,
sonatypeProfileName := "org.typelevel",
releaseCrossBuild := true
Expand All @@ -24,13 +20,11 @@ lazy val cross = crossProject(JSPlatform, JVMPlatform).in(file(".")).
settings(
name := "mouse",
organization := "org.typelevel",
commonSettings,
sonatypeProfileName := "org.typelevel",
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-core" % "2.4.2",
"org.scalatest" %%% "scalatest" % "3.2.5" % Test,
"org.scalatestplus" %%% "scalacheck-1-15" % "3.2.5.0" % Test,
compilerPlugin("org.typelevel" %% "kind-projector" % "0.11.3" cross CrossVersion.full)
"org.scalatestplus" %%% "scalacheck-1-15" % "3.2.5.0" % Test
),
licenses += ("MIT license", url("http://opensource.org/licenses/MIT")),
homepage := Some(url("https://github.com/typelevel/mouse")),
Expand All @@ -39,11 +33,19 @@ lazy val cross = crossProject(JSPlatform, JVMPlatform).in(file(".")).
scalacOptions ++= Seq("-feature", "-deprecation", "-language:implicitConversions", "-language:higherKinds"),
scalacOptions ++= {
scalaVersion.value match {
case v if v.startsWith("2.13") => Nil
case _ => Seq("-Ypartial-unification")
case v if v.startsWith("2.12") => Seq("-Ypartial-unification")
case v if v.startsWith("3") => Seq("-source", "3.0-migration")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to make Dotty shut up about missing parens in lambdas. I didn't fix them to keep the PR as small as possible.

case _ => Nil
}
},
Test / publishArtifact := false,
Compile / doc / sources := {
val old = (Compile / doc / sources).value
if (isDotty.value)
Seq()
else
old
},
pomIncludeRepository := { _ => false },
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
releaseProcess := Seq[ReleaseStep](
Expand All @@ -59,6 +61,10 @@ lazy val cross = crossProject(JSPlatform, JVMPlatform).in(file(".")).
commitNextVersion,
)
)
.jsSettings(
crossScalaVersions := (ThisBuild / crossScalaVersions).value.filter(_.startsWith("2")),
publishConfiguration := publishConfiguration.value.withOverwrite(true)
Comment on lines +65 to +66
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required because Scalatest does not publish DottyJS artifacts.

)

ThisBuild / githubWorkflowTargetTags ++= Seq("v*")
ThisBuild / githubWorkflowPublishTargetBranches :=
Expand Down
1 change: 1 addition & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.11")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.10.1")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.5")
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.5.3")
27 changes: 22 additions & 5 deletions shared/src/test/scala/mouse/AnyFSyntaxTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,36 @@ import cats.{Id, ~>}

class AnyFSyntaxTest extends MouseSuite {

val emptyK: List ~> List = λ[List ~> List](_ => Nil)
val emptyK = new (List ~> List) {
def apply[A](x: List[A]) = Nil
}
Comment on lines -9 to +11
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This syntax is not supported in Dotty, so I opted to write it like this. It's only in tests, so it seemed fair to me.


val double: List ~> List = λ[List ~> List](list => list ::: list)
val double = new (List ~> List) {
def apply[A](x: List[A]) = x ::: x
}

type E[B] = Either[String, B]
val toRight = new (Option ~> E) {
def apply[A](x: Option[A]) = x.toRight("foo")
}

val headOption = new (List ~> Option) {
def apply[A](x: List[A]) = x.headOption
}

val optionGet = new (Option ~> Id) {
def apply[A](x: Option[A]) = x.get
}

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

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

"thing".some thrushK (λ[Option ~> Either[String, *]](_.toRight("foo"))) shouldEqual Right(
"thing".some thrushK toRight shouldEqual Right(
"thing"
)

(List("This") ||> double
||> λ[List ~> Option](_.headOption)
||> λ[Option ~> Id](_.head)) shouldEqual "This"
||> headOption
||> optionGet) shouldEqual "This"
}
4 changes: 2 additions & 2 deletions shared/src/test/scala/mouse/MouseSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ trait MouseSuite
with ScalaCheckDrivenPropertyChecks
with AllSharedSyntax
with AllInstances {
implicit val eq0 = new Eq[NumberFormatException] {
implicit val eq0: Eq[NumberFormatException] = new Eq[NumberFormatException] {
override def eqv(x: NumberFormatException, y: NumberFormatException): Boolean =
x.getMessage == y.getMessage
}

implicit val eq1 = new Eq[IllegalArgumentException] {
implicit val eq1: Eq[IllegalArgumentException] = new Eq[IllegalArgumentException] {
override def eqv(x: IllegalArgumentException, y: IllegalArgumentException): Boolean =
x.getMessage == y.getMessage
}
Expand Down