Skip to content

Commit

Permalink
Upgrade scala 2.13 and circe (#1041)
Browse files Browse the repository at this point in the history
* Upgrade scala 2.13

* ci generated

* Ignore binary incompatibilities in examples

* fmt sbt
  • Loading branch information
Odomontois authored Nov 30, 2022
1 parent ea92e6a commit 9a0933e
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 20 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.8, 2.12.16]
scala: [2.13.10, 2.12.16]
java: [temurin@8, temurin@17]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.8]
scala: [2.13.10]
java: [temurin@8]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -123,12 +123,12 @@ jobs:
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

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

- name: Inflate target directories (2.13.8)
- name: Inflate target directories (2.13.10)
run: |
tar xf targets.tar
rm targets.tar
Expand Down
11 changes: 8 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ lazy val examplesZIO2 =
.settings(
defaultSettings,
name := "tofu-examples-zio2",
noPublishSettings
exampleSettings
)
.dependsOn(zio2Logging, loggingDer, loggingLayout)

Expand Down Expand Up @@ -351,7 +351,7 @@ lazy val examples = project
libraryDependencies ++= http4s,
defaultSettings,
name := "tofu-examples",
noPublishSettings,
exampleSettings,
)
.dependsOn(mainModuleDeps: _*)

Expand All @@ -361,7 +361,7 @@ lazy val examplesCE3 = project
libraryDependencies ++= List(doobieCoreCE3, doobieH2CE3, derevo, groovy),
defaultSettings,
name := "tofu-examples-ce3",
noPublishSettings,
exampleSettings,
)
.dependsOn(ce3MainModuleDeps: _*)

Expand Down Expand Up @@ -465,6 +465,8 @@ lazy val scalacWarningConfig = scalacOptions += {
s"-Wconf:$contextDeprecationInfo,$verboseWarnings"
}

ThisBuild / libraryDependencySchemes += "io.circe" %% "circe-core" % "early-semver"

lazy val macros = Seq(
scalacOptions ++= { if (minorVersion.value == 13) Seq("-Ymacro-annotations") else Seq() },
libraryDependencies ++= { if (minorVersion.value == 12) Seq(compilerPlugin(macroParadise)) else Seq() }
Expand All @@ -473,6 +475,9 @@ lazy val macros = Seq(
lazy val noPublishSettings =
defaultSettings ++ Seq(publish := {}, publishArtifact := false, publishTo := None, publish / skip := true)

lazy val exampleSettings =
noPublishSettings ++ Set(evictionErrorLevel := Level.Info)

addCommandAlias("fmt", "all tofu/scalafmtSbt tofu/scalafmtAll")
addCommandAlias("checkfmt", "all tofu/scalafmtSbtCheck tofu/scalafmtCheckAll")

Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/test/scala/tofu/ScopedSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import scala.annotation.nowarn
import scala.concurrent.Future

class ScopedSuite {
@nowarn("msg=parameter value")
@nowarn("cat=unused-params")
def doSomething[F[_]: ContextShift: Async, A](fa: F[A], ea: => A)(calcEc: ExecutionContext)(implicit
ec: ExecutionContext,
block: Blocker
Expand Down
2 changes: 2 additions & 0 deletions modules/core/src/test/scala/tofu/syntax/FEitherSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import tofu.Raise
import tofu.syntax.feither._

import java.util.concurrent.atomic.AtomicInteger
import scala.annotation.nowarn

@nowarn("cat=lint-infer-any")
class FEitherSuite extends AnyWordSpec with Matchers {

// --Helpers------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions modules/core3/src/test/scala/tofu/syntax/FEitherSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import tofu.Raise
import tofu.syntax.feither._

import java.util.concurrent.atomic.AtomicInteger
import scala.annotation.nowarn

@nowarn("cat=lint-infer-any")
class FEitherSuite extends AnyWordSpec with Matchers {

// --Helpers------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tofu.control

import cats.{Applicative, FlatMap}
import tofu.compat.unused
import tofu.instances.bind._

class CatsInstancesFromBindSuite {
Expand All @@ -10,7 +9,7 @@ class CatsInstancesFromBindSuite {
requireFlatMap[F[Nothing, *]]
}

def requireApplicative[F[_]](implicit @unused applicative: Applicative[F]): Unit = ()
def requireApplicative[F[_]](implicit applicative: Applicative[F]): Unit = ()

def requireFlatMap[F[_]](implicit @unused flatMap: FlatMap[F]): Unit = ()
def requireFlatMap[F[_]](implicit flatMap: FlatMap[F]): Unit = ()
}
3 changes: 1 addition & 2 deletions modules/kernel/src/main/scala/tofu/internal/NonTofu.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package tofu.internal
import tofu.compat.unused

/** workaround for scala 2.12.10 derivation */
sealed abstract class IsTofu[+F[_]]
Expand All @@ -12,7 +11,7 @@ sealed abstract class NonTofu[+F[_]]
object NonTofu extends NonTofu[Nothing] {

/** This results in ambigous implicits if there is implicit evidence of `IsTofo[F]` */
implicit def ambiguousIfPresent[F[_]](implicit @unused _ev: IsTofu[F]): NonTofu[F] = this
implicit def ambiguousIfPresent[F[_]](implicit _ev: IsTofu[F]): NonTofu[F] = this

/** This always declares an instance of `Refute`
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import cats.kernel.Monoid
import tofu.logging.LogRenderer.LogRendererUnit
import tethys.commons.RawJson
import tethys.writers.tokens.TokenWriter
import tofu.compat.unused

class TethysBuilder(prefix: String = "", postfix: String = "") extends LogBuilder[String] {
type Top = TokenWriter
Expand All @@ -17,7 +16,7 @@ class TethysBuilder(prefix: String = "", postfix: String = "") extends LogBuilde
type Output = Unit

/** override to add predefined fields */
def predefined(@unused tokenWriter: TokenWriter): Unit = {}
def predefined(tokenWriter: TokenWriter): Unit = {}

def writeValue(value: LogParamValue, writer: TokenWriter): Unit = value match {
case StrValue(v) => writer.writeString(v)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ package impl
import cats.Applicative
import cats.syntax.applicative._
import org.slf4j.{Logger, Marker}
import scala.annotation.nowarn

@nowarn("cat=lint-infer-any")
class ContextLoggingImpl[F[_]: Applicative, C: Loggable, Service](context: F WithContext C, logger: Logger)
extends LoggingImpl[F](logger) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ package impl
import org.slf4j.{Logger, Marker}
import tofu.syntax.monadic._
import cats.Monad
import scala.annotation.nowarn

@nowarn("cat=lint-infer-any")
class ContextSyncLoggingImpl[F[_]: Monad, C: Loggable](context: F WithContext C, logger: Logger)(implicit F: Delay[F])
extends LoggingImpl[F](logger) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import org.slf4j.{Logger, Marker}
import tofu.syntax.monadic._
import cats.Monad
import tofu.Delay
import scala.annotation.nowarn

@nowarn("cat=lint-infer-any")
class SyncLogging[F[_]: Monad](logger: Logger)(implicit F: Delay[F]) extends LoggingImpl[F](logger) {
override def trace(message: String, values: LoggedValue*): F[Unit] =
F.delay(logger.trace(message, values: _*)).whenA(traceEnabled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import cats.FlatMap
import org.slf4j.{Logger, LoggerFactory, Marker}
import tofu.logging.Logging.{Debug, Error, Info, Trace, Warn}
import tofu.{Delay, WithContext}
import scala.annotation.nowarn

@nowarn("cat=lint-infer-any")
object UniversalLogging {
private[impl] final def enabled(level: Logging.Level, logger: Logger): Boolean = level match {
case Trace => logger.isTraceEnabled()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import tofu.logging.Loggable
import scala.annotation.tailrec
import scala.collection.mutable
import scala.reflect.macros.blackbox
import scala.annotation.nowarn

case class Location(file: String, line: Int, applicationPoint: String)

Expand All @@ -16,6 +17,7 @@ object Location {
implicit def location: Location = macro LocationMacro.getEnclosingPosition
}

@nowarn("cat=lint-infer-any")
object LocationMacro {

/** Based on Izumi Logstage CodePosition */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import zio.console.Console
import zio._

import scala.jdk.CollectionConverters._
import scala.annotation.nowarn

class ZLogsSuite extends AnyFlatSpec with Matchers {

Expand Down Expand Up @@ -54,7 +53,6 @@ class ZLogsSuite extends AnyFlatSpec with Matchers {
val logLayer: URLayer[Has[CtxService], Has[ZLogging.Make]] =
ZLogging.Make.layerPlainWithContext(_.get)

@nowarn("cat=unused-locals")
val program = for {
logs <- ZIO.service[ZLogging.Make]
implicit0(logger: ULogging) = logs.byName(Name)
Expand Down
4 changes: 2 additions & 2 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ object Dependencies {
object Version {
val scala212 = "2.12.16"

val scala213 = "2.13.8"
val scala213 = "2.13.10"

val circe = "0.14.2"
val circe = "0.14.3"

val tethys = "0.26.0"

Expand Down

0 comments on commit 9a0933e

Please sign in to comment.