Skip to content

Commit

Permalink
Upgrade Scala 3, ZIO and scalafmt (#478)
Browse files Browse the repository at this point in the history
  • Loading branch information
mijicd authored Dec 21, 2021
1 parent e134424 commit 130d199
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 17 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Cache scala dependencies
uses: coursier/cache-action@v6
- name: Lint code
run: sbt check
run: ./sbt check

mdoc:
runs-on: ubuntu-20.04
Expand All @@ -41,7 +41,7 @@ jobs:
- name: Cache scala dependencies
uses: coursier/cache-action@v6
- name: Check Document Generation
run: sbt docs/docusaurusCreateSite
run: ./sbt docs/docusaurusCreateSite

test:
runs-on: ubuntu-20.04
Expand All @@ -50,7 +50,7 @@ jobs:
fail-fast: false
matrix:
java: ['[email protected]', '[email protected]']
scala: ['2.12.15', '2.13.7', '3.0.2']
scala: ['2.12.15', '2.13.7', '3.1.0']
steps:
- name: Checkout current branch
uses: actions/[email protected]
Expand All @@ -63,7 +63,7 @@ jobs:
- name: Cache scala dependencies
uses: coursier/cache-action@v6
- name: Run tests
run: sbt ++${{ matrix.scala }}! test
run: ./sbt ++${{ matrix.scala }}! test
- name: Compile examples
if: ${{ startsWith(matrix.scala, '2') }}
run: ./sbt ++${{ matrix.scala }}! compileExamples
Expand All @@ -90,7 +90,7 @@ jobs:
- name: Cache scala dependencies
uses: coursier/cache-action@v6
- name: Release artifacts
run: sbt ci-release
run: ./sbt ci-release
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
Expand Down
4 changes: 2 additions & 2 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "3.0.8"
version = "3.2.1"
maxColumn = 120
align.preset = most
continuationIndent.defnSite = 2
Expand All @@ -11,5 +11,5 @@ spaces {
inImportCurlyBraces = true
}
optIn.annotationNewlines = true

runner.dialect = scala213
rewrite.rules = [SortImports, RedundantBraces]
19 changes: 16 additions & 3 deletions project/BuildHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,26 @@ object BuildHelper {
val doc = new Load(LoadSettings.builder().build())
.loadFromReader(scala.io.Source.fromFile(".github/workflows/ci.yml").bufferedReader())
val yaml = doc.asInstanceOf[JMap[String, JMap[String, JMap[String, JMap[String, JMap[String, JList[String]]]]]]]
val list = yaml.get("jobs").get("test").get("strategy").get("matrix").get("scala").asScala
list.map(v => (v.split('.').take(2).mkString("."), v)).toMap

yaml
.get("jobs")
.get("test")
.get("strategy")
.get("matrix")
.get("scala")
.asScala
.map { v =>
val vs = v.split('.')
val init = vs.take(vs(0) match { case "2" => 2; case _ => 1 })

init.mkString(".") -> v
}
.toMap
}

private val Scala212: String = versions("2.12")
private val Scala213: String = versions("2.13")
private val Scala3: String = versions("3.0")
private val Scala3: String = versions("3")

private val stdOptions = Seq(
"-deprecation",
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ object Dependencies {
val opentelemetry = "1.9.1"
val opencensus = "0.30.0"
val zipkin = "2.16.3"
val zio = "1.0.12"
val zio = "1.0.13"
val zioHttp = "1.0.0.0-RC17"
val zioJson = "0.1.5"
val zioConfig = "1.0.6"
Expand Down
15 changes: 9 additions & 6 deletions sbt
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@

set -o pipefail

declare -r sbt_release_version="1.5.1"
declare -r sbt_unreleased_version="1.5.1"
declare -r sbt_release_version="1.5.7"
declare -r sbt_unreleased_version="1.6.0-M1"

declare -r latest_213="2.13.5"
declare -r latest_212="2.12.13"
declare -r latest_213="2.13.7"
declare -r latest_212="2.12.15"
declare -r latest_211="2.11.12"
declare -r latest_210="2.10.7"
declare -r latest_29="2.9.3"
Expand Down Expand Up @@ -216,7 +216,8 @@ getJavaVersion() {
# but on 9 and 10 it's 9.x.y and 10.x.y.
if [[ "$str" =~ ^1\.([0-9]+)(\..*)?$ ]]; then
echo "${BASH_REMATCH[1]}"
elif [[ "$str" =~ ^([0-9]+)(\..*)?$ ]]; then
# Fixes https://github.com/dwijnand/sbt-extras/issues/326
elif [[ "$str" =~ ^([0-9]+)(\..*)?(-ea)?$ ]]; then
echo "${BASH_REMATCH[1]}"
elif [[ -n "$str" ]]; then
echoerr "Can't parse java version from: $str"
Expand Down Expand Up @@ -252,7 +253,9 @@ is_apple_silicon() { [[ "$(uname -s)" == "Darwin" && "$(uname -m)" == "arm64" ]]
# MaxPermSize critical on pre-8 JVMs but incurs noisy warning on 8+
default_jvm_opts() {
local -r v="$(java_version)"
if [[ $v -ge 10 ]]; then
if [[ $v -ge 17 ]]; then
echo "$default_jvm_opts_common"
elif [[ $v -ge 10 ]]; then
if is_apple_silicon; then
# As of Dec 2020, JVM for Apple Silicon (M1) doesn't support JVMCI
echo "$default_jvm_opts_common"
Expand Down

0 comments on commit 130d199

Please sign in to comment.