diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a8f9b8b3..44971d71 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,5 +33,8 @@ jobs: - name: "Run tests and compile documentation 🚀" run: nix develop -c sbt 'buildRedis4Cats' + - name: "Test for Binary Compatibility 📦" + run: nix develop -c sbt 'mimaReportBinaryIssuesIfRelevant' + - name: "Shutting down Redis 🐳" run: docker-compose down diff --git a/build.sbt b/build.sbt index 39d6bc1f..753668af 100644 --- a/build.sbt +++ b/build.sbt @@ -221,6 +221,6 @@ lazy val microsite = project // CI build addCommandAlias("buildDoc", ";++2.13.12;mdoc;doc") -addCommandAlias("buildRedis4Cats", ";mimaReportBinaryIssuesIfRelevant;+test;buildDoc") +addCommandAlias("buildRedis4Cats", ";+test;buildDoc") addCommandAlias("buildSite", ";doc;makeMicrosite") addCommandAlias("publishSite", ";doc;publishMicrosite") diff --git a/modules/effects/src/main/scala/dev/profunktor/redis4cats/algebra/hashes.scala b/modules/effects/src/main/scala/dev/profunktor/redis4cats/algebra/hashes.scala index da47e4b0..a41677f7 100644 --- a/modules/effects/src/main/scala/dev/profunktor/redis4cats/algebra/hashes.scala +++ b/modules/effects/src/main/scala/dev/profunktor/redis4cats/algebra/hashes.scala @@ -27,8 +27,8 @@ trait HashGetter[F[_], K, V] { def hmGet(key: K, field: K, fields: K*): F[Map[K, V]] def hKeys(key: K): F[List[K]] def hVals(key: K): F[List[V]] - def hStrLen(key: K, field: K): F[Option[Long]] - def hLen(key: K): F[Option[Long]] + def hStrLen(key: K, field: K): F[Long] + def hLen(key: K): F[Long] } trait HashSetter[F[_], K, V] { diff --git a/modules/effects/src/main/scala/dev/profunktor/redis4cats/algebra/lists.scala b/modules/effects/src/main/scala/dev/profunktor/redis4cats/algebra/lists.scala index fc2a056e..43aea578 100644 --- a/modules/effects/src/main/scala/dev/profunktor/redis4cats/algebra/lists.scala +++ b/modules/effects/src/main/scala/dev/profunktor/redis4cats/algebra/lists.scala @@ -34,7 +34,7 @@ trait ListBlocking[F[_], K, V] { trait ListGetter[F[_], K, V] { def lIndex(key: K, index: Long): F[Option[V]] - def lLen(key: K): F[Option[Long]] + def lLen(key: K): F[Long] def lRange(key: K, start: Long, stop: Long): F[List[V]] } diff --git a/modules/effects/src/main/scala/dev/profunktor/redis4cats/algebra/sortedsets.scala b/modules/effects/src/main/scala/dev/profunktor/redis4cats/algebra/sortedsets.scala index e9dcb895..f14cb279 100644 --- a/modules/effects/src/main/scala/dev/profunktor/redis4cats/algebra/sortedsets.scala +++ b/modules/effects/src/main/scala/dev/profunktor/redis4cats/algebra/sortedsets.scala @@ -25,9 +25,9 @@ import scala.concurrent.duration.Duration trait SortedSetCommands[F[_], K, V] extends SortedSetGetter[F, K, V] with SortedSetSetter[F, K, V] trait SortedSetGetter[F[_], K, V] { - def zCard(key: K): F[Option[Long]] - def zCount[T: Numeric](key: K, range: ZRange[T]): F[Option[Long]] - def zLexCount(key: K, range: ZRange[V]): F[Option[Long]] + def zCard(key: K): F[Long] + def zCount[T: Numeric](key: K, range: ZRange[T]): F[Long] + def zLexCount(key: K, range: ZRange[V]): F[Long] def zRange(key: K, start: Long, stop: Long): F[List[V]] def zRangeByLex(key: K, range: ZRange[V], limit: Option[RangeLimit]): F[List[V]] def zRangeByScore[T: Numeric](key: K, range: ZRange[T], limit: Option[RangeLimit]): F[List[V]] diff --git a/modules/effects/src/main/scala/dev/profunktor/redis4cats/algebra/strings.scala b/modules/effects/src/main/scala/dev/profunktor/redis4cats/algebra/strings.scala index 59be6e8d..2a7181dd 100644 --- a/modules/effects/src/main/scala/dev/profunktor/redis4cats/algebra/strings.scala +++ b/modules/effects/src/main/scala/dev/profunktor/redis4cats/algebra/strings.scala @@ -35,7 +35,7 @@ trait Getter[F[_], K, V] { def get(key: K): F[Option[V]] def getEx(key: K, getExArg: GetExArg): F[Option[V]] def getRange(key: K, start: Long, end: Long): F[Option[V]] - def strLen(key: K): F[Option[Long]] + def strLen(key: K): F[Long] } trait Setter[F[_], K, V] { diff --git a/modules/effects/src/main/scala/dev/profunktor/redis4cats/redis.scala b/modules/effects/src/main/scala/dev/profunktor/redis4cats/redis.scala index a969160e..7a74fb58 100644 --- a/modules/effects/src/main/scala/dev/profunktor/redis4cats/redis.scala +++ b/modules/effects/src/main/scala/dev/profunktor/redis4cats/redis.scala @@ -703,8 +703,8 @@ private[redis4cats] class BaseRedis[F[_]: FutureLift: MonadThrow: Log, K, V]( override def getRange(key: K, start: Long, end: Long): F[Option[V]] = async.flatMap(_.getrange(key, start, end).futureLift.map(Option.apply)) - override def strLen(key: K): F[Option[Long]] = - async.flatMap(_.strlen(key).futureLift.map(x => Option(Long.unbox(x)))) + override def strLen(key: K): F[Long] = + async.flatMap(_.strlen(key).futureLift.map(x => Long.unbox(x))) override def mGet(keys: Set[K]): F[Map[K, V]] = async @@ -741,11 +741,11 @@ private[redis4cats] class BaseRedis[F[_]: FutureLift: MonadThrow: Log, K, V]( override def hVals(key: K): F[List[V]] = async.flatMap(_.hvals(key).futureLift.map(_.asScala.toList)) - override def hStrLen(key: K, field: K): F[Option[Long]] = - async.flatMap(_.hstrlen(key, field).futureLift.map(x => Option(Long.unbox(x)))) + override def hStrLen(key: K, field: K): F[Long] = + async.flatMap(_.hstrlen(key, field).futureLift.map(x => Long.unbox(x))) - override def hLen(key: K): F[Option[Long]] = - async.flatMap(_.hlen(key).futureLift.map(x => Option(Long.unbox(x)))) + override def hLen(key: K): F[Long] = + async.flatMap(_.hlen(key).futureLift.map(x => Long.unbox(x))) override def hSet(key: K, field: K, value: V): F[Boolean] = async.flatMap(_.hset(key, field, value).futureLift.map(x => Boolean.box(x))) @@ -821,8 +821,8 @@ private[redis4cats] class BaseRedis[F[_]: FutureLift: MonadThrow: Log, K, V]( override def lIndex(key: K, index: Long): F[Option[V]] = async.flatMap(_.lindex(key, index).futureLift.map(Option.apply)) - override def lLen(key: K): F[Option[Long]] = - async.flatMap(_.llen(key).futureLift.map(x => Option(Long.unbox(x)))) + override def lLen(key: K): F[Long] = + async.flatMap(_.llen(key).futureLift.map(x => Long.unbox(x))) override def lRange(key: K, start: Long, stop: Long): F[List[V]] = async.flatMap(_.lrange(key, start, stop).futureLift.map(_.asScala.toList)) @@ -1074,14 +1074,14 @@ private[redis4cats] class BaseRedis[F[_]: FutureLift: MonadThrow: Log, K, V]( res.map(x => Long.box(x)) } - override def zCard(key: K): F[Option[Long]] = - async.flatMap(_.zcard(key).futureLift.map(x => Option(Long.unbox(x)))) + override def zCard(key: K): F[Long] = + async.flatMap(_.zcard(key).futureLift.map(x => Long.unbox(x))) - override def zCount[T: Numeric](key: K, range: ZRange[T]): F[Option[Long]] = - async.flatMap(_.zcount(key, range.asJavaRange).futureLift.map(x => Option(Long.unbox(x)))) + override def zCount[T: Numeric](key: K, range: ZRange[T]): F[Long] = + async.flatMap(_.zcount(key, range.asJavaRange).futureLift.map(x => Long.unbox(x))) - override def zLexCount(key: K, range: ZRange[V]): F[Option[Long]] = - async.flatMap(_.zlexcount(key, JRange.create[V](range.start, range.end)).futureLift.map(x => Option(Long.unbox(x)))) + override def zLexCount(key: K, range: ZRange[V]): F[Long] = + async.flatMap(_.zlexcount(key, JRange.create[V](range.start, range.end)).futureLift.map(x => Long.unbox(x))) override def zRange(key: K, start: Long, stop: Long): F[List[V]] = async.flatMap(_.zrange(key, start, stop).futureLift.map(_.asScala.toList)) diff --git a/modules/tests/src/test/scala/dev/profunktor/redis4cats/TestScenarios.scala b/modules/tests/src/test/scala/dev/profunktor/redis4cats/TestScenarios.scala index af24af86..fc6ffc57 100644 --- a/modules/tests/src/test/scala/dev/profunktor/redis4cats/TestScenarios.scala +++ b/modules/tests/src/test/scala/dev/profunktor/redis4cats/TestScenarios.scala @@ -107,7 +107,7 @@ trait TestScenarios { self: FunSuite => x <- redis.lRange(testKey, 0, 10) _ <- IO(assertEquals(x, List("one", "two", "three"))) y <- redis.lLen(testKey) - _ <- IO(assert(y.contains(3L))) + _ <- IO(assert(y == 3L)) a <- redis.lPop(testKey) _ <- IO(assert(a.contains("one"))) b <- redis.rPop(testKey) @@ -184,20 +184,20 @@ trait TestScenarios { self: FunSuite => _ <- IO(assertEquals(minPop2, List(scoreWithValue1))) maxPop2 <- redis.zPopMax(testKey, 1) _ <- IO(assertEquals(maxPop2, List(scoreWithValue2))) - _ <- redis.zCard(testKey).map(card => assert(card.contains(0L))) + _ <- redis.zCard(testKey).map(card => assert(card == 0L)) _ <- redis.zAdd(testKey, args = None, scoreWithValue1, scoreWithValue2) minBPop2 <- redis.bzPopMin(timeout, NonEmptyList.one(testKey)) _ <- IO(assert(minBPop2.contains((testKey, scoreWithValue1)))) maxBPop2 <- redis.bzPopMax(timeout, NonEmptyList.one(testKey)) _ <- IO(assert(maxBPop2.contains((testKey, scoreWithValue2)))) - _ <- redis.zCard(testKey).map(card => assert(card.contains(0L))) + _ <- redis.zCard(testKey).map(card => assert(card == 0L)) _ <- redis.zAdd(testKey, args = None, scoreWithValue1, scoreWithValue2) x <- redis.zRevRangeByScore(testKey, ZRange(0, 2), limit = None) _ <- IO(assertEquals(x, List(1L))) y <- redis.zCard(testKey) - _ <- IO(assert(y.contains(2L))) + _ <- IO(assert(y == 2L)) z <- redis.zCount(testKey, ZRange(0, 1)) - _ <- IO(assert(z.contains(1L))) + _ <- IO(assert(z == 1L)) _ <- redis.zAdd(otherTestKey, args = None, scoreWithValue1, scoreWithValue3) zUnion <- redis.zUnion(args = None, testKey, otherTestKey) _ <- IO(assertEquals(zUnion, List(1L, 2L, 3L))) diff --git a/project/MimaVersionPlugin.scala b/project/MimaVersionPlugin.scala index 26a456c5..a2246135 100644 --- a/project/MimaVersionPlugin.scala +++ b/project/MimaVersionPlugin.scala @@ -100,6 +100,7 @@ object MimaVersionPlugin extends AutoPlugin { val tags = scala.util .Try("git tag --list".!!.split("\n").map(_.trim)) .getOrElse(new Array[String](0)) + println(tags.mkString("\n")) // in semver, we allow breakage in minor releases if major is 0, otherwise not val Pattern =