From ef81f36b6362ec9b0952f97db642cd7188868757 Mon Sep 17 00:00:00 2001 From: Mikhail Sokolov Date: Tue, 1 Apr 2025 16:15:55 +0300 Subject: [PATCH] Add Scala 3 cross-compilation, update build, update deps - CI build JDK version updated from 11 to 17 - updated dependencies, sbt and plugins - switched to sbt-dynver plugin like in other evo OSS projects - added sbt-version-policy for bincompat checks - updated CI and release github actions --- .github/workflows/ci.yml | 21 ++++++++---- .github/workflows/release.yml | 10 +++--- build.sbt | 33 ++++++++++++++----- project/build.properties | 2 +- project/plugins.sbt | 13 +++----- .../evolutiongaming/hostname/HostName.scala | 4 +-- version.sbt | 1 - 7 files changed, 52 insertions(+), 32 deletions(-) delete mode 100644 version.sbt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 86ef9d6..171959f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,18 +10,27 @@ jobs: strategy: matrix: scala: - - 2.13.6 - - 2.12.14 + - 2.13.16 + - 2.12.20 + - 3.3.5 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: coursier/cache-action@v6 - - name: scala - uses: olafurpg/setup-scala@v11 + - name: setup Java 17 + uses: actions/setup-java@v4 with: - java-version: openjdk@1.11 + java-version: '17' + distribution: 'oracle' + cache: 'sbt' + + - name: setup SBT + uses: sbt/setup-sbt@v1 + + - name: check code + run: sbt clean check - name: build ${{ matrix.scala }} run: sbt ++${{ matrix.scala }} clean coverage test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a8a2f2b..9bf3d4d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,11 +1,11 @@ -name: Publish new Release +name: Publish Release on: - release: - types: [published] - branches: [master] + push: + tags: + - 'v*' jobs: release: - uses: evolution-gaming/scala-github-actions/.github/workflows/release.yml@v1 + uses: evolution-gaming/scala-github-actions/.github/workflows/release.yml@v3 secrets: inherit diff --git a/build.sbt b/build.sbt index e4be175..bb1a9d9 100644 --- a/build.sbt +++ b/build.sbt @@ -2,31 +2,46 @@ name := "hostname" organization := "com.evolutiongaming" -homepage := Some(new URL("http://github.com/evolution-gaming/hostname")) +homepage := Some(new URL("https://github.com/evolution-gaming/hostname")) startYear := Some(2018) organizationName := "Evolution" -organizationHomepage := Some(url("http://evolution.com")) +organizationHomepage := Some(url("https://evolution.com")) publishTo := Some(Resolver.evolutionReleases) +versionPolicyIntention := Compatibility.BinaryCompatible + scalaVersion := crossScalaVersions.value.head -crossScalaVersions := Seq("2.13.6", "2.12.14") +crossScalaVersions := Seq("2.13.16", "2.12.20", "3.3.5") + +scalacOptions ++= crossSettings( + scalaVersion.value, + if3 = Seq(), + if2 = Seq( + "-Xsource:3", + ) +) Compile / doc / scalacOptions ++= Seq("-groups", "-implicits", "-no-link-warnings") libraryDependencies ++= Seq( - "org.scalatest" %% "scalatest" % "3.2.9" % Test, - "org.scalatest" %% "scalatest-funsuite" % "3.2.9" % Test + "org.scalatest" %% "scalatest" % "3.2.19" % Test, + "org.scalatest" %% "scalatest-funsuite" % "3.2.19" % Test ) licenses := Seq(("MIT", url("https://opensource.org/licenses/MIT"))) -releaseCrossBuild := true - -//addCommandAlias("check", "all versionPolicyCheck Compile/doc") -addCommandAlias("check", "show version") +addCommandAlias("check", "versionPolicyCheck; +Compile/doc") addCommandAlias("build", "+all compile test") + +def crossSettings[T](scalaVersion: String, if3: Seq[T], if2: Seq[T]): Seq[T] = { + CrossVersion.partialVersion(scalaVersion) match { + case Some((3, _)) => if3 + case Some((2, 12 | 13)) => if2 + case _ => Nil + } +} diff --git a/project/build.properties b/project/build.properties index bb5389d..af06c85 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.5 \ No newline at end of file +sbt.version=1.10.11 \ No newline at end of file diff --git a/project/plugins.sbt b/project/plugins.sbt index 9d90788..3f758da 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,9 +1,6 @@ -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.8.2") - -addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.3.1") - -addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0") - +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.3.1") +addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.3.15") addSbtPlugin("com.evolution" % "sbt-scalac-opts-plugin" % "0.0.9") - -addSbtPlugin("com.evolution" % "sbt-artifactory-plugin" % "0.0.2") \ No newline at end of file +addSbtPlugin("com.evolution" % "sbt-artifactory-plugin" % "0.0.2") +addSbtPlugin("ch.epfl.scala" % "sbt-version-policy" % "3.2.1") +addSbtPlugin("com.github.sbt" % "sbt-dynver" % "5.1.0") diff --git a/src/main/scala/com/evolutiongaming/hostname/HostName.scala b/src/main/scala/com/evolutiongaming/hostname/HostName.scala index b34bfae..fa1f802 100644 --- a/src/main/scala/com/evolutiongaming/hostname/HostName.scala +++ b/src/main/scala/com/evolutiongaming/hostname/HostName.scala @@ -3,9 +3,9 @@ package com.evolutiongaming.hostname import java.net.InetAddress import java.util.concurrent.Executors -import scala.concurrent.duration._ +import scala.concurrent.duration.* import scala.concurrent.{Await, ExecutionContext, Future} -import scala.sys.process._ +import scala.sys.process.* import scala.util.Properties import scala.util.control.NonFatal diff --git a/version.sbt b/version.sbt deleted file mode 100644 index 0dd0d5f..0000000 --- a/version.sbt +++ /dev/null @@ -1 +0,0 @@ -ThisBuild / version := "0.2.1-SNAPSHOT"