Skip to content

Commit

Permalink
Merge pull request #617 from fd4s/scala-3-1.x
Browse files Browse the repository at this point in the history
Update 1.x to Scala 3 final
  • Loading branch information
bplommer authored May 22, 2021
2 parents ff6a84c + 1d2d6ee commit e05161b
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 14 deletions.
8 changes: 4 additions & 4 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.5, 3.0.0-RC3]
scala: [2.12.13, 2.13.6, 3.0.0]
java: [adopt@1.8]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:

- run: sbt ++${{ matrix.scala }} ci

- if: matrix.scala == '2.13.5'
- if: matrix.scala == '2.13.6'
run: sbt ++${{ matrix.scala }} docs/run

publish:
Expand All @@ -64,7 +64,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.5]
scala: [2.13.6]
java: [adopt@1.8]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -96,4 +96,4 @@ jobs:
GIT_DEPLOY_KEY: ${{ secrets.GIT_DEPLOY_KEY }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
run: sbt ++${{ matrix.scala }} ci-release docs/docusaurusPublishGhpages
run: sbt ++${{ matrix.scala }} ci-release docs/docusaurusPublishGhpages
19 changes: 9 additions & 10 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
val catsEffectVersion = "2.5.0"
val catsEffectVersion = "2.5.1"

val catsVersion = "2.6.0"
val catsVersion = "2.6.1"

val confluentVersion = "6.1.1"

val fs2Version = "2.5.5"
val fs2Version = "2.5.6"

val kafkaVersion = "2.8.0"

val testcontainersScalaVersion = "0.39.3"
val testcontainersScalaVersion = "0.39.4"

val vulcanVersion = "1.6.0"
val vulcanVersion = "1.7.0"

val scala212 = "2.12.13"

val scala213 = "2.13.5"
val scala213 = "2.13.6"

val scala3 = "3.0.0-RC3"
val scala3 = "3.0.0"

lazy val `fs2-kafka` = project
.in(file("."))
Expand Down Expand Up @@ -86,17 +86,16 @@ lazy val dependencySettings = Seq(
.cross(CrossVersion.for3Use2_13),
("com.dimafeng" %% "testcontainers-scala-kafka" % testcontainersScalaVersion)
.cross(CrossVersion.for3Use2_13),
"org.typelevel" %% "discipline-scalatest" % "2.1.4",
"org.typelevel" %% "discipline-scalatest" % "2.1.5",
"org.typelevel" %% "cats-effect-laws" % catsEffectVersion,
"org.typelevel" %% "cats-testkit-scalatest" % "2.1.4",
"ch.qos.logback" % "logback-classic" % "1.2.3"
).map(_ % Test),
libraryDependencies ++= {
if (scalaVersion.value.startsWith("3")) Nil
else
Seq(
compilerPlugin(
("org.typelevel" %% "kind-projector" % "0.11.3")
("org.typelevel" %% "kind-projector" % "0.13.0")
.cross(CrossVersion.full)
)
)
Expand Down
56 changes: 56 additions & 0 deletions modules/core/src/test/scala/cats/tests/CatsEquality.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copied verbatim from cats-testkit-scalatest (https://github.com/typelevel/cats-testkit-scalatest)
* which is licensed as follows:
*
* Copyright (c) 2019 Typelevel
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package cats
package tests

import org.scalactic._
import TripleEqualsSupport.AToBEquivalenceConstraint
import TripleEqualsSupport.BToAEquivalenceConstraint

// The code in this file was taken and only slightly modified from
// https://github.com/bvenners/equality-integration-demo
// Thanks for the great examples, Bill!

final class CatsEquivalence[T](T: Eq[T]) extends Equivalence[T] {
def areEquivalent(a: T, b: T): Boolean = T.eqv(a, b)
}

trait LowPriorityStrictCatsConstraints extends TripleEquals {
implicit def lowPriorityCatsCanEqual[A, B](implicit B: Eq[B], ev: A <:< B): CanEqual[A, B] =
new AToBEquivalenceConstraint[A, B](new CatsEquivalence(B), ev)
}

trait StrictCatsEquality extends LowPriorityStrictCatsConstraints {
override def convertToEqualizer[T](left: T): Equalizer[T] = super.convertToEqualizer[T](left)
implicit override def convertToCheckingEqualizer[T](left: T): CheckingEqualizer[T] =
new CheckingEqualizer(left)
override def unconstrainedEquality[A, B](implicit equalityOfA: Equality[A]): CanEqual[A, B] =
super.unconstrainedEquality[A, B]
implicit def catsCanEqual[A, B](implicit A: Eq[A], ev: B <:< A): CanEqual[A, B] =
new BToAEquivalenceConstraint[A, B](new CatsEquivalence(A), ev)
}

object StrictCatsEquality extends StrictCatsEquality
96 changes: 96 additions & 0 deletions modules/core/src/test/scala/cats/tests/CatsSuite.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* Copied verbatim from cats-testkit-scalatest (https://github.com/typelevel/cats-testkit-scalatest)
* which is licensed as follows:
*
* Copyright (c) 2019 Typelevel
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package cats
package tests

import cats.instances._
import cats.platform.Platform
import cats.syntax._
import org.scalactic.anyvals.{PosInt, PosZDouble, PosZInt}
import org.scalatest.funsuite.AnyFunSuiteLike
import org.scalatest.matchers.should.Matchers
import org.scalatest.prop.Configuration
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
import org.typelevel.discipline.scalatest.FunSuiteDiscipline

trait TestSettings extends Configuration with Matchers {

lazy val checkConfiguration: PropertyCheckConfiguration =
PropertyCheckConfiguration(
minSuccessful = if (Platform.isJvm) PosInt(50) else PosInt(5),
maxDiscardedFactor = if (Platform.isJvm) PosZDouble(5.0) else PosZDouble(50.0),
minSize = PosZInt(0),
sizeRange = if (Platform.isJvm) PosZInt(10) else PosZInt(5),
workers = if (Platform.isJvm) PosInt(2) else PosInt(1)
)

lazy val slowCheckConfiguration: PropertyCheckConfiguration =
if (Platform.isJvm) checkConfiguration
else PropertyCheckConfiguration(minSuccessful = 1, sizeRange = 1)
}

/**
* An opinionated stack of traits to improve consistency and reduce
* boilerplate in Cats tests.
*/
trait CatsSuite
extends AnyFunSuiteLike
with Matchers
with ScalaCheckDrivenPropertyChecks
with FunSuiteDiscipline
with TestSettings
with AllInstances
with AllInstancesBinCompat0
with AllInstancesBinCompat1
with AllInstancesBinCompat2
with AllInstancesBinCompat3
with AllInstancesBinCompat4
with AllInstancesBinCompat5
with AllSyntax
with AllSyntaxBinCompat0
with AllSyntaxBinCompat1
with AllSyntaxBinCompat2
with AllSyntaxBinCompat3
with AllSyntaxBinCompat4
with AllSyntaxBinCompat5
with StrictCatsEquality {

implicit override val generatorDrivenConfig: PropertyCheckConfiguration =
checkConfiguration

// disable Eq syntax (by making `catsSyntaxEq` not implicit), since it collides
// with scalactic's equality
override def catsSyntaxEq[A: Eq](a: A): EqOps[A] = new EqOps[A](a)

def even(i: Int): Boolean = i % 2 == 0

val evenPf: PartialFunction[Int, Int] = { case i if even(i) => i }
}

trait SlowCatsSuite extends CatsSuite {
implicit override val generatorDrivenConfig: PropertyCheckConfiguration =
slowCheckConfiguration
}

0 comments on commit e05161b

Please sign in to comment.