Skip to content

Commit 040127b

Browse files
committed
add Scala 3 support
1 parent 16bf953 commit 040127b

File tree

6 files changed

+46
-14
lines changed

6 files changed

+46
-14
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ jobs:
1111
matrix:
1212
scala:
1313
- 2.13.16
14+
- 3.3.6
1415

1516
steps:
1617
- uses: actions/checkout@v4
@@ -27,11 +28,15 @@ jobs:
2728
- name: setup SBT
2829
uses: sbt/setup-sbt@v1
2930

31+
- name: check code ${{ matrix.scala }}
32+
run: sbt ++${{ matrix.scala }} clean check
33+
3034
- name: build ${{ matrix.scala }}
31-
run: sbt ++${{ matrix.scala }} clean check coverage test
35+
run: sbt ++${{ matrix.scala }} clean coverage test
3236

3337
- name: test coverage
3438
if: success()
39+
run: sbt ++${{ matrix.scala }} coverageAggregate coveralls
3540
env:
36-
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
37-
run: sbt ++${{ matrix.scala }} coverageReport coverageAggregate coveralls
41+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
COVERALLS_FLAG_NAME: Scala ${{ matrix.scala }}

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ on:
77

88
jobs:
99
release:
10-
uses: evolution-gaming/scala-github-actions/.github/workflows/release.yml@v3
10+
uses: evolution-gaming/scala-github-actions/.github/workflows/release.yml@v4
1111
secrets: inherit

build.sbt

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,31 @@ organizationHomepage := Some(url("https://evolution.com"))
88
homepage := Some(url("https://github.com/evolution-gaming/sharding-strategy"))
99
startYear := Some(2018)
1010

11-
crossScalaVersions := Seq("2.13.16")
11+
crossScalaVersions := Seq("2.13.16", "3.3.6")
1212
scalaVersion := crossScalaVersions.value.head
1313
scalacOptions := Seq(
1414
"-release:17",
15-
"-Xsource:3",
15+
"-deprecation",
16+
)
17+
scalacOptions ++= crossSettings(
18+
scalaVersion = scalaVersion.value,
19+
// Good compiler options for Scala 2.13 are coming from com.evolution:sbt-scalac-opts-plugin:0.0.9,
20+
// but its support for Scala 3 is limited, especially what concerns linting options.
21+
if2 = Seq(
22+
"-Xsource:3",
23+
),
24+
// If Scala 3 is made the primary target, good linting scalac options for it should be added first.
25+
if3 = Seq(
26+
"-Ykind-projector:underscores",
27+
28+
// disable new brace-less syntax:
29+
// https://alexn.org/blog/2022/10/24/scala-3-optional-braces/
30+
"-no-indent",
31+
32+
// improve error messages:
33+
"-explain",
34+
"-explain-types",
35+
),
1636
)
1737
publishTo := Some(Resolver.evolutionReleases) // sbt-release
1838
versionPolicyIntention := Compatibility.BinaryCompatible // sbt-version-policy
@@ -31,7 +51,14 @@ libraryDependencies ++= Seq(
3151

3252
licenses := Seq(("MIT", url("https://opensource.org/licenses/MIT")))
3353

34-
//addCommandAlias("fmt", "scalafixAll; all scalafmtAll scalafmtSbt")
35-
//addCommandAlias("check", "scalafixEnable; scalafixAll --check; all versionPolicyCheck scalafmtCheckAll scalafmtSbtCheck")
36-
addCommandAlias("check", "versionPolicyCheck")
37-
addCommandAlias("build", "all compile test")
54+
//addCommandAlias("fmt", "all scalafmtAll scalafmtSbt")
55+
//addCommandAlias("check", "all versionPolicyCheck scalafmtCheckAll scalafmtSbtCheck")
56+
addCommandAlias("check", "+versionPolicyCheck")
57+
addCommandAlias("build", "+all compile test")
58+
59+
def crossSettings[T](scalaVersion: String, if3: T, if2: T): T = {
60+
scalaVersion match {
61+
case version if version.startsWith("3") => if3
62+
case _ => if2
63+
}
64+
}

project/Dependencies.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import sbt._
1+
import sbt.*
22

33
object Dependencies {
44

55
val scalatest = "org.scalatest" %% "scalatest" % "3.2.19"
66
val `cats-helper` = "com.evolutiongaming" %% "cats-helper" % "3.12.0"
7-
val `ddata-tools` = "com.evolutiongaming" %% "ddata-tools" % "4.0.0"
7+
val `ddata-tools` = "com.evolutiongaming" %% "ddata-tools" % "4.1.0"
88

99
object Cats {
1010
private val version = "2.13.0"

src/main/scala/com/evolutiongaming/cluster/sharding/LoggingAllocationStrategy.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ object LoggingAllocationStrategy {
2222
} mkString ", "
2323
}
2424

25-
def iterToStr(iter: Iterable[_]) = {
25+
def iterToStr(iter: Iterable[?]) = {
2626
iter.toSeq.map { _.toString }.sorted.mkString("[", ",", "]")
2727
}
2828

src/main/scala/com/evolutiongaming/cluster/sharding/ShardingStrategy.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ object ShardingStrategy {
226226
} mkString ", "
227227
}
228228

229-
def iterToStr(iter: Iterable[_]) = {
229+
def iterToStr(iter: Iterable[?]) = {
230230
iter.toSeq.map { _.toString }.sorted.mkString("[", ",", "]")
231231
}
232232

0 commit comments

Comments
 (0)