From b752e5e331b84c11ab335de704b7196884765a30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Poniedzia=C5=82ek?= Date: Tue, 8 Feb 2022 16:40:28 +0100 Subject: [PATCH 01/21] Replacement for scalacache-guava (close #34) --- README.md | 6 ++-- build.sbt | 3 +- project/Dependencies.scala | 3 +- .../CreateLruMap.scala | 36 +++++++------------ 4 files changed, 18 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index ff03eb4..976f87a 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![codecov](https://codecov.io/gh/snowplow-incubator/scala-lru-map/branch/master/graph/badge.svg)](https://codecov.io/gh/snowplow-incubator/scala-lru-map) [![Join the chat at https://gitter.im/snowplow-incubator/scala-lru-map](https://badges.gitter.im/snowplow-incubator/scala-lru-map.svg)](https://gitter.im/snowplow-incubator/scala-lru-map?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -A pure least recently used hash map based on [`java.util.LinkedHashMap`][linkedhashmap]. +A pure least recently used map based on [`Scaffeine`][scaffeine]. ## API @@ -82,7 +82,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -[linkedhashmap]: https://docs.oracle.com/javase/7/docs/api/java/util/LinkedHashMap.html -[cats-sync]: https://typelevel.org/cats-effect/typeclasses/sync.html +[scaffeine]: https://github.com/blemale/scaffeine +[cats-sync]: https://typelevel.org/cats-effect/docs/typeclasses/sync [license]: http://www.apache.org/licenses/LICENSE-2.0 diff --git a/build.sbt b/build.sbt index 83b4ee1..f63abca 100644 --- a/build.sbt +++ b/build.sbt @@ -23,8 +23,7 @@ lazy val root = project libraryDependencies ++= Seq( Dependencies.cats, Dependencies.catsEffect, - Dependencies.scache, - Dependencies.scacheCats, + Dependencies.scaffeine, Dependencies.scalaCheck, Dependencies.specs2 ) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index e3d97a4..a4e4602 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -13,10 +13,9 @@ import sbt._ object Dependencies { - val scache = "com.github.cb372" %% "scalacache-guava" % "0.28.0" - val scacheCats = "com.github.cb372" %% "scalacache-cats-effect" % "0.28.0" val catsEffect = "org.typelevel" %% "cats-effect" % "2.1.3" val cats = "org.typelevel" %% "cats-core" % "2.1.1" + val scaffeine = "com.github.blemale" %% "scaffeine" % "5.1.2" val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.14.0" % Test val specs2 = "org.specs2" %% "specs2-core" % "4.8.3" % Test } diff --git a/src/main/scala/com.snowplowanalytics.lrumap/CreateLruMap.scala b/src/main/scala/com.snowplowanalytics.lrumap/CreateLruMap.scala index de24985..4a7ef8b 100644 --- a/src/main/scala/com.snowplowanalytics.lrumap/CreateLruMap.scala +++ b/src/main/scala/com.snowplowanalytics.lrumap/CreateLruMap.scala @@ -13,16 +13,9 @@ package com.snowplowanalytics.lrumap import cats.Id -import cats.syntax.functor._ import cats.effect.Async - -import com.google.common.cache.CacheBuilder - -import scalacache._ -import scalacache.guava._ -import scalacache.modes.sync -import scalacache.CatsEffect - +import cats.syntax.functor._ +import com.github.blemale.scaffeine.Scaffeine /** `CreateLruMap` provides an ability to initialize the cache, * which effect will `F` @@ -50,34 +43,31 @@ object CreateLruMap { /** Eager instance */ implicit def idInitCache[K, V]: CreateLruMap[Id, K, V] = new CreateLruMap[Id, K, V] { def create(size: Int): Id[LruMap[Id, K, V]] = new LruMap[Id, K, V] { - private implicit val scacheMode: Mode[Id] = sync.mode + private val underlying = makeUnderlying[K, V](size) - def get(key: K): Id[Option[V]] = underlying.get(key) - def put(key: K, value: V): Id[Unit] = { - val _ = underlying.put[Id](key)(value, None) - () - } + + def get(key: K): Id[Option[V]] = underlying.getIfPresent(key) + def put(key: K, value: V): Id[Unit] = underlying.put(key, value) } } /** Pure instance */ implicit def asyncInitCache[F[_], K, V](implicit F: Async[F]): CreateLruMap[F, K, V] = new CreateLruMap[F, K, V] { - private implicit val scacheMode: Mode[F] = CatsEffect.modes.async[F] def create(size: Int): F[LruMap[F, K, V]] = F.delay(makeUnderlying[K, V](size)).map { underlying => new LruMap[F, K, V] { - def get(key: K): F[Option[V]] = - underlying.get[F](key) + def get(key: K): F[Option[V]] = F.delay(underlying.getIfPresent(key)) - def put(key: K, value: V): F[Unit] = - underlying.put[F](key)(value, None).void + def put(key: K, value: V): F[Unit] = F.delay(underlying.put(key, value)) } } } - // initial capacity and load factor are the normal defaults for LinkedHashMap - private def makeUnderlying[K, V](maxSize: Int): GuavaCache[V] = - GuavaCache(CacheBuilder.newBuilder().maximumSize(maxSize.toLong).build[String, Entry[V]]) + private def makeUnderlying[K, V](maxSize: Int) = { + Scaffeine() + .maximumSize(maxSize.toLong) + .build[K, V]() + } } From 161dcb1328d48df65fc138e80f217a5d4f3f4f60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Poniedzia=C5=82ek?= Date: Tue, 8 Feb 2022 16:48:51 +0100 Subject: [PATCH 02/21] Bump scala to 2.13.8, 2.12.15 (close #46) --- build.sbt | 4 ++-- project/BuildSettings.scala | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/build.sbt b/build.sbt index f63abca..efbce66 100644 --- a/build.sbt +++ b/build.sbt @@ -17,8 +17,8 @@ lazy val root = project name := "scala-lru-map", version := "0.5.0", description := "Simple LRU Map for caching", - scalaVersion := "2.13.2", - crossScalaVersions := Seq("2.12.10", "2.13.1"), + scalaVersion := "2.13.8", + crossScalaVersions := Seq("2.12.15", "2.13.8"), javacOptions := BuildSettings.javaCompilerOptions, libraryDependencies ++= Seq( Dependencies.cats, diff --git a/project/BuildSettings.scala b/project/BuildSettings.scala index 5d8943c..3dc008a 100644 --- a/project/BuildSettings.scala +++ b/project/BuildSettings.scala @@ -57,10 +57,7 @@ object BuildSettings { siteSubdirName := "" ) - lazy val javaCompilerOptions = Seq( - "-source", "1.8", - "-target", "1.8" - ) + lazy val javaCompilerOptions = Seq("-source", "11", "-target", "11") lazy val coverageSettings = Seq( coverageMinimum := 90 From f387c49f4611dfabe77098daf00ecd116aec8860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Poniedzia=C5=82ek?= Date: Tue, 8 Feb 2022 16:50:15 +0100 Subject: [PATCH 03/21] Bump sbt to 1.6.2 (close #40) --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index c0bab04..c8fcab5 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.2.8 +sbt.version=1.6.2 From b96e1c6749b7fbb3a838367133b4d42494331330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Poniedzia=C5=82ek?= Date: Tue, 8 Feb 2022 16:52:33 +0100 Subject: [PATCH 04/21] Bump cats-effect to 3.3.5 (close #37) --- project/Dependencies.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index a4e4602..f150c4d 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -13,7 +13,7 @@ import sbt._ object Dependencies { - val catsEffect = "org.typelevel" %% "cats-effect" % "2.1.3" + val catsEffect = "org.typelevel" %% "cats-effect" % "3.3.5" val cats = "org.typelevel" %% "cats-core" % "2.1.1" val scaffeine = "com.github.blemale" %% "scaffeine" % "5.1.2" val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.14.0" % Test From d950a538cae9613ea4390d9e1d5f9fde8284190d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Poniedzia=C5=82ek?= Date: Tue, 8 Feb 2022 16:54:11 +0100 Subject: [PATCH 05/21] Bump cats-core to 2.7.0 (close #36) --- project/Dependencies.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index f150c4d..99dde00 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -13,8 +13,8 @@ import sbt._ object Dependencies { + val cats = "org.typelevel" %% "cats-core" % "2.7.0" val catsEffect = "org.typelevel" %% "cats-effect" % "3.3.5" - val cats = "org.typelevel" %% "cats-core" % "2.1.1" val scaffeine = "com.github.blemale" %% "scaffeine" % "5.1.2" val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.14.0" % Test val specs2 = "org.specs2" %% "specs2-core" % "4.8.3" % Test From b620f2d161879a5a976c41019253a7332f30afa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Poniedzia=C5=82ek?= Date: Tue, 8 Feb 2022 16:54:40 +0100 Subject: [PATCH 06/21] Bump scalacheck to 1.15.4 (close #38) --- project/Dependencies.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 99dde00..e93986d 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -16,6 +16,6 @@ object Dependencies { val cats = "org.typelevel" %% "cats-core" % "2.7.0" val catsEffect = "org.typelevel" %% "cats-effect" % "3.3.5" val scaffeine = "com.github.blemale" %% "scaffeine" % "5.1.2" - val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.14.0" % Test + val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.15.4" % Test val specs2 = "org.specs2" %% "specs2-core" % "4.8.3" % Test } From 9c8896eb34605a136aaf4a934632322e806df813 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Poniedzia=C5=82ek?= Date: Tue, 8 Feb 2022 16:55:53 +0100 Subject: [PATCH 07/21] Remove specs2-core dependency (close #39) --- build.sbt | 3 +-- project/Dependencies.scala | 9 ++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/build.sbt b/build.sbt index efbce66..59d3f59 100644 --- a/build.sbt +++ b/build.sbt @@ -24,8 +24,7 @@ lazy val root = project Dependencies.cats, Dependencies.catsEffect, Dependencies.scaffeine, - Dependencies.scalaCheck, - Dependencies.specs2 + Dependencies.scalaCheck ) ) .settings(BuildSettings.publishSettings) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index e93986d..8dadd92 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -13,9 +13,8 @@ import sbt._ object Dependencies { - val cats = "org.typelevel" %% "cats-core" % "2.7.0" - val catsEffect = "org.typelevel" %% "cats-effect" % "3.3.5" - val scaffeine = "com.github.blemale" %% "scaffeine" % "5.1.2" - val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.15.4" % Test - val specs2 = "org.specs2" %% "specs2-core" % "4.8.3" % Test + val cats = "org.typelevel" %% "cats-core" % "2.7.0" + val catsEffect = "org.typelevel" %% "cats-effect" % "3.3.5" + val scaffeine = "com.github.blemale" %% "scaffeine" % "5.1.2" + val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.15.4" % Test } From ffded324262bdedd5d6913ae3868e3fc3045dab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Poniedzia=C5=82ek?= Date: Wed, 9 Feb 2022 09:22:46 +0100 Subject: [PATCH 08/21] Bump sbt-scalafmt to 2.4.6 (close #41) --- .scalafmt.conf | 4 +- build.sbt | 12 ++--- project/BuildSettings.scala | 23 +++++---- project/plugins.sbt | 14 +++--- .../CreateLruMap.scala | 48 ++++++++++--------- .../com.snowplowanalytics.lrumap/LruMap.scala | 9 ++-- .../LruMapTest.scala | 30 +++++++----- 7 files changed, 77 insertions(+), 63 deletions(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index bb98e6d..596ebbf 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,7 +1,9 @@ +version = 3.4.2 +runner.dialect = scala213 style = defaultWithAlign maxColumn = 100 -docstrings = JavaDoc +docstrings.style = Asterisk optIn.breakChainOnFirstMethodDot = true spaces.afterKeywordBeforeParen = true continuationIndent.defnSite = 2 diff --git a/build.sbt b/build.sbt index 59d3f59..487ed47 100644 --- a/build.sbt +++ b/build.sbt @@ -13,13 +13,13 @@ lazy val root = project .in(file(".")) .settings( - organization := "com.snowplowanalytics", - name := "scala-lru-map", - version := "0.5.0", - description := "Simple LRU Map for caching", - scalaVersion := "2.13.8", + organization := "com.snowplowanalytics", + name := "scala-lru-map", + version := "0.5.0", + description := "Simple LRU Map for caching", + scalaVersion := "2.13.8", crossScalaVersions := Seq("2.12.15", "2.13.8"), - javacOptions := BuildSettings.javaCompilerOptions, + javacOptions := BuildSettings.javaCompilerOptions, libraryDependencies ++= Seq( Dependencies.cats, Dependencies.catsEffect, diff --git a/project/BuildSettings.scala b/project/BuildSettings.scala index 3dc008a..0eb9d6e 100644 --- a/project/BuildSettings.scala +++ b/project/BuildSettings.scala @@ -31,18 +31,21 @@ import scoverage.ScoverageKeys._ object BuildSettings { lazy val publishSettings = bintraySettings ++ Seq( - publishMavenStyle := true, - publishArtifact := true, + publishMavenStyle := true, + publishArtifact := true, publishArtifact in Test := false, licenses += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0.html")), - bintrayOrganization := Some("snowplow"), - bintrayRepository := "snowplow-maven", + bintrayOrganization := Some("snowplow"), + bintrayRepository := "snowplow-maven", pomIncludeRepository := { _ => false }, - homepage := Some(url("https://github.com/snowplow-incubator/scala-lru-map")), - scmInfo := Some(ScmInfo(url("https://github.com/snowplow-incubator/scala-lru-map"), - "scm:git@github.com:snowplow-incubator/scala-lru-map.git")), - pomExtra := ( - + homepage := Some(url("https://github.com/snowplow-incubator/scala-lru-map")), + scmInfo := Some( + ScmInfo( + url("https://github.com/snowplow-incubator/scala-lru-map"), + "scm:git@github.com:snowplow-incubator/scala-lru-map.git" + ) + ), + pomExtra := ( Snowplow Analytics Ltd support@snowplowanalytics.com @@ -53,7 +56,7 @@ object BuildSettings { ) lazy val docSettings = Seq( - gitRemoteRepo := "https://github.com/snowplow-incubator/scala-lru-map.git", + gitRemoteRepo := "https://github.com/snowplow-incubator/scala-lru-map.git", siteSubdirName := "" ) diff --git a/project/plugins.sbt b/project/plugins.sbt index 52a192c..6d8ab65 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,7 +1,7 @@ -addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.3") -addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.15") -addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.1") -addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.3.2") -addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.2") -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1") -addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.12") +addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.3") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") +addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.1") +addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.3.2") +addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.2") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1") +addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.12") diff --git a/src/main/scala/com.snowplowanalytics.lrumap/CreateLruMap.scala b/src/main/scala/com.snowplowanalytics.lrumap/CreateLruMap.scala index 4a7ef8b..c4e284e 100644 --- a/src/main/scala/com.snowplowanalytics.lrumap/CreateLruMap.scala +++ b/src/main/scala/com.snowplowanalytics.lrumap/CreateLruMap.scala @@ -17,21 +17,23 @@ import cats.effect.Async import cats.syntax.functor._ import com.github.blemale.scaffeine.Scaffeine -/** `CreateLruMap` provides an ability to initialize the cache, - * which effect will `F` - * - * *WARNING*: Due to support of non-`Sync`/eager algebras, - * users should be super-careful about creating *values* of `F[_]`, - * as they won't have RT/lazy semantics and will be memoized - * - * This is NOT a type class, as it does not have the coherence - * requirement, but can be passed implicitly - */ +/** + * `CreateLruMap` provides an ability to initialize the cache, which effect will `F` + * + * *WARNING*: Due to support of non-`Sync`/eager algebras, users should be super-careful about + * creating *values* of `F[_]`, as they won't have RT/lazy semantics and will be memoized + * + * This is NOT a type class, as it does not have the coherence requirement, but can be passed + * implicitly + */ trait CreateLruMap[F[_], K, V] extends Serializable { - /** Create an LruMap within `F` effect - * - * @param size Max size before evicting - */ + + /** + * Create an LruMap within `F` effect + * + * @param size + * Max size before evicting + */ def create(size: Int): F[LruMap[F, K, V]] } @@ -47,22 +49,24 @@ object CreateLruMap { private val underlying = makeUnderlying[K, V](size) def get(key: K): Id[Option[V]] = underlying.getIfPresent(key) + def put(key: K, value: V): Id[Unit] = underlying.put(key, value) } } /** Pure instance */ - implicit def asyncInitCache[F[_], K, V](implicit F: Async[F]): CreateLruMap[F, K, V] = new CreateLruMap[F, K, V] { + implicit def asyncInitCache[F[_], K, V](implicit F: Async[F]): CreateLruMap[F, K, V] = + new CreateLruMap[F, K, V] { - def create(size: Int): F[LruMap[F, K, V]] = - F.delay(makeUnderlying[K, V](size)).map { underlying => - new LruMap[F, K, V] { - def get(key: K): F[Option[V]] = F.delay(underlying.getIfPresent(key)) + def create(size: Int): F[LruMap[F, K, V]] = + F.delay(makeUnderlying[K, V](size)).map { underlying => + new LruMap[F, K, V] { + def get(key: K): F[Option[V]] = F.delay(underlying.getIfPresent(key)) - def put(key: K, value: V): F[Unit] = F.delay(underlying.put(key, value)) + def put(key: K, value: V): F[Unit] = F.delay(underlying.put(key, value)) + } } - } - } + } private def makeUnderlying[K, V](maxSize: Int) = { Scaffeine() diff --git a/src/main/scala/com.snowplowanalytics.lrumap/LruMap.scala b/src/main/scala/com.snowplowanalytics.lrumap/LruMap.scala index e7d3f3d..4380b2a 100644 --- a/src/main/scala/com.snowplowanalytics.lrumap/LruMap.scala +++ b/src/main/scala/com.snowplowanalytics.lrumap/LruMap.scala @@ -14,13 +14,14 @@ package com.snowplowanalytics.lrumap /** Pure cache interface with `F` effect produced by interactions with cache */ trait LruMap[F[_], K, V] { + /** - * Associates the key with the specified value - */ + * Associates the key with the specified value + */ def put(key: K, value: V): F[Unit] /** - * Returns the value associated with the key, unless the key has been evicted - */ + * Returns the value associated with the key, unless the key has been evicted + */ def get(key: K): F[Option[V]] } diff --git a/src/test/scala/com.snowplowanalytics.lrumap/LruMapTest.scala b/src/test/scala/com.snowplowanalytics.lrumap/LruMapTest.scala index 3cc2663..6e074a3 100644 --- a/src/test/scala/com.snowplowanalytics.lrumap/LruMapTest.scala +++ b/src/test/scala/com.snowplowanalytics.lrumap/LruMapTest.scala @@ -12,7 +12,7 @@ */ package com.snowplowanalytics.lrumap -import org.scalacheck.{Properties, Prop, Gen} +import org.scalacheck.{Gen, Prop, Properties} import cats.Id import cats.implicits._ @@ -31,23 +31,27 @@ class LruMapSpecification extends Properties("LruMap") { property("Fill lru") = Prop.forAll(Gen.choose(1, 10000)) { size => val map: Id[LruMap[Id, Int, Int]] = CreateLruMap[Id, Int, Int].create(size) - val result = map.flatMap[Option[Int]](m => (1 to size).toList.traverse(n => m.put(n, n)).productR(m.get(0))) + val result = map.flatMap[Option[Int]](m => + (1 to size).toList.traverse(n => m.put(n, n)).productR(m.get(0)) + ) result.isEmpty } - property("Last put") = Prop.forAll(Gen.listOf(Gen.identifier).suchThat(list => list.distinct == list)) { list => - val map: Id[LruMap[Id, String, String]] = CreateLruMap[Id, String, String].create(list.length * 4) - val result = map - .flatMap[List[Option[String]]] { m => - list.traverse[Id, Unit] { w => m.put(w, w) }.productR { - list.traverse[Id, Option[String]] { w => m.get(w) } + property("Last put") = + Prop.forAll(Gen.listOf(Gen.identifier).suchThat(list => list.distinct == list)) { list => + val map: Id[LruMap[Id, String, String]] = + CreateLruMap[Id, String, String].create(list.length * 4) + val result = map + .flatMap[List[Option[String]]] { m => + list.traverse[Id, Unit](w => m.put(w, w)).productR { + list.traverse[Id, Option[String]](w => m.get(w)) + } } - } - val res = result == list.map(x => Some(x)) - if (!res) { println(s"list $list and result $result and len ${list.length}") } - res - } + val res = result == list.map(x => Some(x)) + if (!res) { println(s"list $list and result $result and len ${list.length}") } + res + } property("Evict lru") = Prop.forAll(Gen.choose(1, 1000)) { size => val map: Id[LruMap[Id, Int, Int]] = CreateLruMap[Id, Int, Int].create(size) From 750c1270a3956699bdf83223faadbc3cf250a54a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Poniedzia=C5=82ek?= Date: Wed, 9 Feb 2022 09:31:44 +0100 Subject: [PATCH 09/21] Bump sbt-site to 1.4.1 (close #42) --- project/BuildSettings.scala | 1 - project/plugins.sbt | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/project/BuildSettings.scala b/project/BuildSettings.scala index 0eb9d6e..a48d76d 100644 --- a/project/BuildSettings.scala +++ b/project/BuildSettings.scala @@ -21,7 +21,6 @@ import bintray.BintrayPlugin._ import bintray.BintrayKeys._ // Scaladocs -import sbtunidoc.ScalaUnidocPlugin.autoImport._ import com.typesafe.sbt.site.SitePlugin.autoImport._ import com.typesafe.sbt.SbtGit.GitKeys._ diff --git a/project/plugins.sbt b/project/plugins.sbt index 6d8ab65..cc8234b 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,7 +1,6 @@ addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.3") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") -addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.1") -addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.3.2") +addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.2") addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1") addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.12") From a59491247c0c4f0d15bfeb89812f237fe3487c61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Poniedzia=C5=82ek?= Date: Wed, 9 Feb 2022 09:33:21 +0100 Subject: [PATCH 10/21] Bump sbt-ghpages to 0.6.3 (close #43) --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index cc8234b..cfdbf19 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,6 +1,6 @@ addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.3") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") -addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.2") +addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1") addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.12") From 6a570fab022a48ea71a2fa48c94e647e868e7fae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Poniedzia=C5=82ek?= Date: Wed, 9 Feb 2022 10:18:38 +0100 Subject: [PATCH 11/21] Bump sbt-scoverage to 1.9.3 (close #44) --- project/BuildSettings.scala | 9 +++++---- project/plugins.sbt | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/project/BuildSettings.scala b/project/BuildSettings.scala index a48d76d..433d6bf 100644 --- a/project/BuildSettings.scala +++ b/project/BuildSettings.scala @@ -24,9 +24,6 @@ import bintray.BintrayKeys._ import com.typesafe.sbt.site.SitePlugin.autoImport._ import com.typesafe.sbt.SbtGit.GitKeys._ -// Scoverage -import scoverage.ScoverageKeys._ - object BuildSettings { lazy val publishSettings = bintraySettings ++ Seq( @@ -62,6 +59,10 @@ object BuildSettings { lazy val javaCompilerOptions = Seq("-source", "11", "-target", "11") lazy val coverageSettings = Seq( - coverageMinimum := 90 + coverageMinimumStmtTotal := 90, + coverageFailOnMinimum := false, + (Test / test) := { + (coverageReport dependsOn (Test / test)).value + } ) } diff --git a/project/plugins.sbt b/project/plugins.sbt index cfdbf19..c28a179 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,5 +2,5 @@ addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.3") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3") addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.12") From 647125cbd12bdbdca894ec7fec8ef8847a624809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Poniedzia=C5=82ek?= Date: Wed, 9 Feb 2022 10:19:19 +0100 Subject: [PATCH 12/21] Bump sbt-tpolecat to 0.1.20 (close #45) --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index c28a179..dcfbd43 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -3,4 +3,4 @@ addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3") -addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.12") +addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20") From 88047b8ab7a996b154212622b625c1cc33c50ee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Poniedzia=C5=82ek?= Date: Wed, 9 Feb 2022 10:24:36 +0100 Subject: [PATCH 13/21] Migrate from travis to github actions (close #35) --- .github/workflows/ci.yml | 31 +++++++++++++++++++++++++ .github/workflows/release.yml | 21 +++++++++++++++++ .github/workflows/snyk.yml | 20 ++++++++++++++++ .travis.yml | 23 ------------------- .travis/deploy.sh | 23 ------------------- README.md | 15 +++++++++--- build.sbt | 1 - project/BuildSettings.scala | 43 ++++++++++++++--------------------- project/plugins.sbt | 12 +++++----- 9 files changed, 107 insertions(+), 82 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/snyk.yml delete mode 100644 .travis.yml delete mode 100755 .travis/deploy.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..a34af0a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: CI + +on: + push: + branches: + - master + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: coursier/cache-action@v6 + + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + + - name: Run tests + run: sbt coverage +test coverageReport + + - name: Check Scala formatting + run: sbt scalafmtCheckAll + + - name: Check binary compatibility + run: sbt +mimaReportBinaryIssues + + - name: Check assets can be published + run: sbt +publishLocal diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a532a9c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,21 @@ +name: RELEASE + +on: + push: + tags: + - '*' + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: coursier/cache-action@v6 + + - name: Deploy scala-lru-map to Maven Central + run: sbt ci-release + env: + PGP_PASSPHRASE: ${{ secrets.SONA_PGP_PASSPHRASE }} + PGP_SECRET: ${{ secrets.SONA_PGP_SECRET }} + SONATYPE_USERNAME: ${{ secrets.SONA_USER }} + SONATYPE_PASSWORD: ${{ secrets.SONA_PASS }} diff --git a/.github/workflows/snyk.yml b/.github/workflows/snyk.yml new file mode 100644 index 0000000..6f8beac --- /dev/null +++ b/.github/workflows/snyk.yml @@ -0,0 +1,20 @@ +name: Snyk + +on: + push: + branches: [ master ] + +jobs: + security: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Run Snyk to check for vulnerabilities + uses: snyk/actions/scala@master + with: + command: monitor + args: --project-name=scala-lru-map + env: + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ec53d6e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: scala -scala: -- 2.12.6 -- 2.13.2 -jdk: -- openjdk8 -script: -- sbt coverage test coverageReport -deploy: - skip_cleanup: true - provider: script - script: "./.travis/deploy.sh $TRAVIS_TAG" - on: - condition: '"${TRAVIS_SCALA_VERSION}" == "2.12.6"' - tags: true -after_success: -- bash <(curl -s https://codecov.io/bash) -env: - global: - - SONA_USER=snowplow - - secure: 7M48lkBfeKFectdFiDLIbRr0wwez7gxOnvqiAnsmHQ5U1HuJd0nPnwXMkycMZs9/UK3ce7dPfrr2tDjF/PbBGOumq4Tsmoog8wwV1E0gwNJEOLQiUCkY5oq1V33tBfqyWf+kDP9JHoyUZoF0jT2EiO72EO0XBxHza51ch2vBC0LRIPihErzBXODo+rVa9/FFtWpbraPHVdRCuyh40+rId1XPI14bJN2zI2VJ+BqUD9a6KCnjPK43R7smvjXQyz7HBFjRcO7493LDMtZcnT9yomRKtNdF9tE8WWfQ7XVVSIsD8gnCzsIUwIyMy5TbrgLISm255EXtd38KgD3SrTLs+vJEkvRI4eQ5QFmsY8j75t0Z9CNhJNjl+UKaj+poheDYnWaudHtJsBqTmil2d5z2TTLlZvPa0IUmt+Yl5mQgEZFMxb6zGGnkixCPoHs13cDyHViYAEQ1QL0GYr3HjHlk+JqxdSyUMilbQCLnIgEK/pdCTl5pWYQn90qvO+op8rE8pSO27GXvCVjTM323BcL6h0Ge/+zGrrSpzREV8t9xCs1UoiDlGViQkUuqH90fpaQjK6AIklqQfZtDogmj8nRoPxwqzNBAB5cp3D0U5ekvGPK4byLx4tdenfacceJ4fj00TIgALrL/YOEJRaUF0Af03CtAxjF8KsEtMke0L368Na0= - - secure: OXRSiJG88IbU3hEpEdF990isGzaZZIqi9l9NxSScnAMXQnRi/mUVrGb6XYzoA1Z8e+4XtK/0aiWxqCpXsDT6haQZSGwqUkjR/dHM3T7KtDrhvvoC6V8MoWHMT3WJplscrRkcNExqdt9k3xioYgsx7f0/LVS13I5a2vXjJ171ltTCFcmlDW5B2oUo268GJKwzsolobAWuJGFoj9Qwq/B3mCqwn7illLTPzDmprWsymFXiBYRm9/hzE5ITs6djLU+g6IsfFmN6hdSovRk4lfmGQThhvEV+PrY38PlU2iXoLzkF5fjitxA2Lx8UH0M6kwA8Hvbuf6mDECCQ4WQWjdY/1htF8gMWwh7N0z9DaWmCU0upqnIAKUSKwswVLcA6CmEHCTY5emFwtHYIom5aEQZYa6FYUyg4s1et7wv7xwpK99afCNy2eKrVAq0AhN+T7bd9UQchbYgKXDzZrC8Ua4sfIT9FOwZCCyTcF1kQGgDKzJ/vtD8gwlH5Mb1jV0sHJSlucL9vCrbUO/q2GZCw0GDcBBLYj0Dl9entnBdNAuJlp2xVyOHe4ZNC7+xQPAXnpTkJicv5zscXX8vxkHI9peMIrlFtdk1O6ej+5nZwSWLPY0qBy/X92iPV5KHONgJOO7k+SaQbKDQs5sWL4f1e+eYcgUpEXCWNiHiER+ajXWnD5iM= - - secure: 4tU4OD5MJoZEsloOjPz5TuwehVvMUBRnklpuavn35dj2Ghh49jydQtMa9yRsGw7kgeEbgHqtRfRI9MKTKVc3L38d8u3hkJS0f5ohjMnrR79EyCOvWRiTapCLJg1Tu2So1Pl0DVA08VD3SBGBQEW/caOWPw//BL48Xwac9h4baIyGMgA1uNg0uCDZS4j62gWZTUfffEU4x+4aHDSpC29pvZ3JqQNl0wp1aCIu2ksSl3vWFUq3gs/stQ0x43ib5qKAm2MPfv2GXMweCz5co9v657b0JfBBMVTrZ7tawwcIGkbmkQjtnVAT8PPJbcsaHa+p+JSbTTokrS/UXLY/4sQ3foJ4I0we1w7qo+qN8XuzwZRj2/Ljb8WVGTesjVEZwzcsMbTLjmPemfqI0QBlR54mKaMdkX6+HJn5nvsTK66ucoilkGb8U1+E+tMRQRyHf2Dewo/7/CaIs7HpAPRCHFtic1MrH4m5IJIprZB84l9u8dLSqkFR+dV27Klzc+1eAW07ZEsc5IklHV63Qt0y+K2dbT0F4UzA+dVYRzShFeAh/AMQeZTdAhWGaYBOmgc3oV+pmML8NSIfokaV31ZJbCJHd4UCzKu0BH8vCE+XJ2jk5f0YKRcxo4YcWpq3WRCEu13rW18wXI972BlatfcvskJ08oHvMchToGUVbsHVfG6GmOk= diff --git a/.travis/deploy.sh b/.travis/deploy.sh deleted file mode 100755 index aec5a0b..0000000 --- a/.travis/deploy.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -tag_version=$1 - -mkdir ~/.bintray/ -file=$HOME/.bintray/.credentials -cat <$file -realm = Bintray API Realm -host = api.bintray.com -user = $BINTRAY_SNOWPLOW_MAVEN_USER -password = $BINTRAY_SNOWPLOW_MAVEN_API_KEY -EOF - -cd $TRAVIS_BUILD_DIR - -project_version=$(sbt version -Dsbt.log.noformat=true | perl -ne 'print "$1\n" if /(\d+\.\d+\.\d+[^\r\n]*)/' | head -n 1 | tr -d '\n') -if [ "${project_version}" == "${tag_version}" ]; then - sbt +publish - sbt +bintraySyncMavenCentral -else - echo "Tag version '${tag_version}' doesn't match version in scala project ('${project_version}'). Aborting!" - exit 1 -fi diff --git a/README.md b/README.md index 976f87a..1eb36c5 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # Scala LruMap -[![Build Status](https://api.travis-ci.org/snowplow-incubator/scala-lru-map.svg)](https://travis-ci.org/snowplow-incubator/scala-lru-map) -[![Maven Central](https://img.shields.io/maven-central/v/com.snowplowanalytics/scala-lru-map_2.12.svg)](https://maven-badges.herokuapp.com/maven-central/com.snowplowanalytics/scala-lru-map_2.12) +[![Build Status][ci-image]][ci] +[![Maven Central][release-image]][releases] [![codecov](https://codecov.io/gh/snowplow-incubator/scala-lru-map/branch/master/graph/badge.svg)](https://codecov.io/gh/snowplow-incubator/scala-lru-map) -[![Join the chat at https://gitter.im/snowplow-incubator/scala-lru-map](https://badges.gitter.im/snowplow-incubator/scala-lru-map.svg)](https://gitter.im/snowplow-incubator/scala-lru-map?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Join the chat at https://gitter.im/snowplow-incubator/scala-lru-map][chat-image]][chat] A pure least recently used map based on [`Scaffeine`][scaffeine]. @@ -86,3 +86,12 @@ limitations under the License. [cats-sync]: https://typelevel.org/cats-effect/docs/typeclasses/sync [license]: http://www.apache.org/licenses/LICENSE-2.0 + +[ci]: https://github.com/snowplow-incubator/scala-lru-map/actions?query=workflow%3ACI +[ci-image]: https://github.com/snowplow-incubator/scala-lru-map/workflows/CI/badge.svg + +[releases]: https://maven-badges.herokuapp.com/maven-central/com.snowplowanalytics/scala-lru-map_2.13 +[release-image]: https://img.shields.io/maven-central/v/com.snowplowanalytics/scala-lru-map_2.13.svg + +[chat]: https://gitter.im/snowplow-incubator/scala-lru-map?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge +[chat-image]: https://badges.gitter.im/snowplow-incubator/scala-lru-map.svg diff --git a/build.sbt b/build.sbt index 487ed47..af01a20 100644 --- a/build.sbt +++ b/build.sbt @@ -15,7 +15,6 @@ lazy val root = project .settings( organization := "com.snowplowanalytics", name := "scala-lru-map", - version := "0.5.0", description := "Simple LRU Map for caching", scalaVersion := "2.13.8", crossScalaVersions := Seq("2.12.15", "2.13.8"), diff --git a/project/BuildSettings.scala b/project/BuildSettings.scala index 433d6bf..66aca06 100644 --- a/project/BuildSettings.scala +++ b/project/BuildSettings.scala @@ -13,42 +13,33 @@ import sbt._ import Keys._ +// dynver plugin +import sbtdynver.DynVerPlugin.autoImport._ + // Scoverage import scoverage.ScoverageKeys._ -// Bintray plugin -import bintray.BintrayPlugin._ -import bintray.BintrayKeys._ - // Scaladocs import com.typesafe.sbt.site.SitePlugin.autoImport._ import com.typesafe.sbt.SbtGit.GitKeys._ object BuildSettings { - lazy val publishSettings = bintraySettings ++ Seq( - publishMavenStyle := true, - publishArtifact := true, - publishArtifact in Test := false, - licenses += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0.html")), - bintrayOrganization := Some("snowplow"), - bintrayRepository := "snowplow-maven", - pomIncludeRepository := { _ => false }, - homepage := Some(url("https://github.com/snowplow-incubator/scala-lru-map")), - scmInfo := Some( - ScmInfo( - url("https://github.com/snowplow-incubator/scala-lru-map"), - "scm:git@github.com:snowplow-incubator/scala-lru-map.git" + lazy val publishSettings = Seq[Setting[_]]( + publishArtifact := true, + Test / publishArtifact := false, + pomIncludeRepository := { _ => false }, + homepage := Some(url("http://snowplowanalytics.com")), + licenses += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0.html")), + ThisBuild / dynverVTagPrefix := false, // Otherwise git tags required to have v-prefix + developers := List( + Developer( + "Snowplow Analytics Ltd", + "Snowplow Analytics Ltd", + "support@snowplowanalytics.com", + url("https://snowplowanalytics.com") ) - ), - pomExtra := ( - - Snowplow Analytics Ltd - support@snowplowanalytics.com - Snowplow Analytics Ltd - http://snowplowanalytics.com - - ) + ) ) lazy val docSettings = Seq( diff --git a/project/plugins.sbt b/project/plugins.sbt index dcfbd43..43309d8 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,6 +1,6 @@ -addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.3") -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") -addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") -addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3") -addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20") +addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") +addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") +addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3") +addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20") From 9e7ffbf043f53967e3a6499670bef6337857de3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Poniedzia=C5=82ek?= Date: Wed, 9 Feb 2022 12:06:18 +0100 Subject: [PATCH 14/21] Add sbt-mima-plugin (close #48) --- build.sbt | 1 + project/BuildSettings.scala | 18 ++++++++++++++++++ project/plugins.sbt | 13 +++++++------ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/build.sbt b/build.sbt index af01a20..613690d 100644 --- a/build.sbt +++ b/build.sbt @@ -29,3 +29,4 @@ lazy val root = project .settings(BuildSettings.publishSettings) .settings(BuildSettings.docSettings) .settings(BuildSettings.coverageSettings) + .settings(BuildSettings.mimaSettings) diff --git a/project/BuildSettings.scala b/project/BuildSettings.scala index 66aca06..fdf1ca5 100644 --- a/project/BuildSettings.scala +++ b/project/BuildSettings.scala @@ -16,6 +16,9 @@ import Keys._ // dynver plugin import sbtdynver.DynVerPlugin.autoImport._ +// Mima plugin +import com.typesafe.tools.mima.plugin.MimaKeys._ + // Scoverage import scoverage.ScoverageKeys._ @@ -56,4 +59,19 @@ object BuildSettings { (coverageReport dependsOn (Test / test)).value } ) + + // If a new version introduces breaking changes, + // clear `mimaBinaryIssueFilters` and `mimaPreviousVersions`. + // Otherwise, add previous version to the set without + // removing older versions. + lazy val mimaPreviousVersions = Set("0.5.0") + lazy val mimaSettings = Seq( + mimaPreviousArtifacts := mimaPreviousVersions.map { organization.value %% name.value % _ }, + ThisBuild / mimaFailOnNoPrevious := false, + mimaBinaryIssueFilters ++= Seq(), + Test / test := { + mimaReportBinaryIssues.value + (Test / test).value + } + ) } diff --git a/project/plugins.sbt b/project/plugins.sbt index 43309d8..11bde87 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,6 +1,7 @@ -addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7") -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") -addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") -addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3") -addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20") +addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7") +addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") +addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.0.1") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") +addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3") +addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20") From 7fcf5858bd6860c0ee63eb7e1b0642b7edfb0601 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Poniedzia=C5=82ek?= Date: Wed, 9 Feb 2022 13:49:01 +0100 Subject: [PATCH 15/21] Update copyright to 2022 (close #49) --- LICENSE-2.0.txt | 2 +- README.md | 2 +- build.sbt | 2 +- project/BuildSettings.scala | 2 +- project/Dependencies.scala | 2 +- src/main/scala/com.snowplowanalytics.lrumap/CreateLruMap.scala | 2 +- src/main/scala/com.snowplowanalytics.lrumap/LruMap.scala | 2 +- src/test/scala/com.snowplowanalytics.lrumap/LruMapTest.scala | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/LICENSE-2.0.txt b/LICENSE-2.0.txt index d1b9ac6..8a9a449 100644 --- a/LICENSE-2.0.txt +++ b/LICENSE-2.0.txt @@ -187,7 +187,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2012 - 2020 Snowplow Analytics Ltd. + Copyright 2012 - 2022 Snowplow Analytics Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index 1eb36c5..c472d33 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ concurrency concerns are left up to the choice of `Sync`. ## Copyright and license -Copyright 2012-2020 Snowplow Analytics Ltd. +Copyright 2012-2022 Snowplow Analytics Ltd. Licensed under the [Apache License, Version 2.0][license] (the "License"); you may not use this software except in compliance with the License. diff --git a/build.sbt b/build.sbt index 613690d..c9ee3bf 100644 --- a/build.sbt +++ b/build.sbt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2020 Snowplow Analytics Ltd. All rights reserved. + * Copyright (c) 2012-2022 Snowplow Analytics Ltd. All rights reserved. * * This program is licensed to you under the Apache License Version 2.0, * and you may not use this file except in compliance with the Apache License Version 2.0. diff --git a/project/BuildSettings.scala b/project/BuildSettings.scala index fdf1ca5..ff864c5 100644 --- a/project/BuildSettings.scala +++ b/project/BuildSettings.scala @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2020 Snowplow Analytics Ltd. All rights reserved. + * Copyright (c) 2012-2022 Snowplow Analytics Ltd. All rights reserved. * * This program is licensed to you under the Apache License Version 2.0, * and you may not use this file except in compliance with the Apache License Version 2.0. diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 8dadd92..318aa3a 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2020 Snowplow Analytics Ltd. All rights reserved. + * Copyright (c) 2012-2022 Snowplow Analytics Ltd. All rights reserved. * * This program is licensed to you under the Apache License Version 2.0, * and you may not use this file except in compliance with the Apache License Version 2.0. diff --git a/src/main/scala/com.snowplowanalytics.lrumap/CreateLruMap.scala b/src/main/scala/com.snowplowanalytics.lrumap/CreateLruMap.scala index c4e284e..3a3f396 100644 --- a/src/main/scala/com.snowplowanalytics.lrumap/CreateLruMap.scala +++ b/src/main/scala/com.snowplowanalytics.lrumap/CreateLruMap.scala @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2020 Snowplow Analytics Ltd. All rights reserved. + * Copyright (c) 2012-2022 Snowplow Analytics Ltd. All rights reserved. * * This program is licensed to you under the Apache License Version 2.0, * and you may not use this file except in compliance with the Apache License Version 2.0. diff --git a/src/main/scala/com.snowplowanalytics.lrumap/LruMap.scala b/src/main/scala/com.snowplowanalytics.lrumap/LruMap.scala index 4380b2a..d3c6df7 100644 --- a/src/main/scala/com.snowplowanalytics.lrumap/LruMap.scala +++ b/src/main/scala/com.snowplowanalytics.lrumap/LruMap.scala @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2020 Snowplow Analytics Ltd. All rights reserved. + * Copyright (c) 2012-2022 Snowplow Analytics Ltd. All rights reserved. * * This program is licensed to you under the Apache License Version 2.0, * and you may not use this file except in compliance with the Apache License Version 2.0. diff --git a/src/test/scala/com.snowplowanalytics.lrumap/LruMapTest.scala b/src/test/scala/com.snowplowanalytics.lrumap/LruMapTest.scala index 6e074a3..3c33d67 100644 --- a/src/test/scala/com.snowplowanalytics.lrumap/LruMapTest.scala +++ b/src/test/scala/com.snowplowanalytics.lrumap/LruMapTest.scala @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2020 Snowplow Analytics Ltd. All rights reserved. + * Copyright (c) 2012-2022 Snowplow Analytics Ltd. All rights reserved. * * This program is licensed to you under the Apache License Version 2.0, * and you may not use this file except in compliance with the Apache License Version 2.0. From 761e90f2dcaa919a02b5fb18c24303ea12eec538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Poniedzia=C5=82ek?= Date: Wed, 9 Feb 2022 14:55:09 +0100 Subject: [PATCH 16/21] Add sbt-coveralls (close #50) --- .github/workflows/ci.yml | 7 ++++++- README.md | 5 ++++- project/BuildSettings.scala | 2 +- project/plugins.sbt | 1 + 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a34af0a..80283a8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: java-version: 11 - name: Run tests - run: sbt coverage +test coverageReport + run: sbt coverage +test - name: Check Scala formatting run: sbt scalafmtCheckAll @@ -29,3 +29,8 @@ jobs: - name: Check assets can be published run: sbt +publishLocal + + - name: Submit coveralls data + run: sbt coverageReport coveralls + env: + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index c472d33..e54fcf2 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Build Status][ci-image]][ci] [![Maven Central][release-image]][releases] -[![codecov](https://codecov.io/gh/snowplow-incubator/scala-lru-map/branch/master/graph/badge.svg)](https://codecov.io/gh/snowplow-incubator/scala-lru-map) +[![Coverage Status][coveralls-image]][coveralls] [![Join the chat at https://gitter.im/snowplow-incubator/scala-lru-map][chat-image]][chat] A pure least recently used map based on [`Scaffeine`][scaffeine]. @@ -93,5 +93,8 @@ limitations under the License. [releases]: https://maven-badges.herokuapp.com/maven-central/com.snowplowanalytics/scala-lru-map_2.13 [release-image]: https://img.shields.io/maven-central/v/com.snowplowanalytics/scala-lru-map_2.13.svg +[coveralls]: https://coveralls.io/github/snowplow-incubator/scala-lru-map?branch=master +[coveralls-image]: https://coveralls.io/repos/github/snowplow-incubator/scala-lru-map/badge.svg?branch=master + [chat]: https://gitter.im/snowplow-incubator/scala-lru-map?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge [chat-image]: https://badges.gitter.im/snowplow-incubator/scala-lru-map.svg diff --git a/project/BuildSettings.scala b/project/BuildSettings.scala index ff864c5..b8d1568 100644 --- a/project/BuildSettings.scala +++ b/project/BuildSettings.scala @@ -64,7 +64,7 @@ object BuildSettings { // clear `mimaBinaryIssueFilters` and `mimaPreviousVersions`. // Otherwise, add previous version to the set without // removing older versions. - lazy val mimaPreviousVersions = Set("0.5.0") + lazy val mimaPreviousVersions = Set() lazy val mimaSettings = Seq( mimaPreviousArtifacts := mimaPreviousVersions.map { organization.value %% name.value % _ }, ThisBuild / mimaFailOnNoPrevious := false, diff --git a/project/plugins.sbt b/project/plugins.sbt index 11bde87..7bb907f 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,5 @@ addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7") +addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.3.1") addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.0.1") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") From ecfdbfc76d480edcaa35f54995ea43abe14041c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Poniedzia=C5=82ek?= Date: Wed, 9 Feb 2022 17:08:12 +0100 Subject: [PATCH 17/21] Add publishing ScalaDocs (close #51) --- .github/workflows/release.yml | 20 ++++++++++++++++++++ build.sbt | 3 ++- project/BuildSettings.scala | 27 ++++++++++++++++++--------- src/site-preprocess/index.html | 20 ++++++++++++++++++++ 4 files changed, 60 insertions(+), 10 deletions(-) create mode 100644 src/site-preprocess/index.html diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a532a9c..988497e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,3 +19,23 @@ jobs: PGP_SECRET: ${{ secrets.SONA_PGP_SECRET }} SONATYPE_USERNAME: ${{ secrets.SONA_USER }} SONATYPE_PASSWORD: ${{ secrets.SONA_PASS }} + + - name: Publish ScalaDoc + run: | + project_version=$(sbt version -Dsbt.log.noformat=true | perl -ne 'print "$1\n" if /info.*(\d+\.\d+\.\d+[^\r\n]*)/' | tail -n 1 | tr -d '\n') + if [[ "${{ github.ref }}" = "refs/tags/${project_version}" ]] + then + sbt makeSite + echo Publishing Scaladoc + git fetch + git checkout gh-pages + cp -r target/site/* . + git config user.name "GitHub Actions" + git config user.email "<>" + git add $project_version + git commit -m "Added Scaladoc for $project_version" + git push origin gh-pages + else + echo "${{ github.ref }} does not match project version $project_version => not publishing" + exit 1 + fi diff --git a/build.sbt b/build.sbt index c9ee3bf..7bca374 100644 --- a/build.sbt +++ b/build.sbt @@ -27,6 +27,7 @@ lazy val root = project ) ) .settings(BuildSettings.publishSettings) - .settings(BuildSettings.docSettings) + .settings(BuildSettings.ghPagesSettings) .settings(BuildSettings.coverageSettings) .settings(BuildSettings.mimaSettings) + .enablePlugins(SiteScaladocPlugin, GhpagesPlugin, PreprocessPlugin) diff --git a/project/BuildSettings.scala b/project/BuildSettings.scala index b8d1568..9883c46 100644 --- a/project/BuildSettings.scala +++ b/project/BuildSettings.scala @@ -22,9 +22,12 @@ import com.typesafe.tools.mima.plugin.MimaKeys._ // Scoverage import scoverage.ScoverageKeys._ -// Scaladocs -import com.typesafe.sbt.site.SitePlugin.autoImport._ -import com.typesafe.sbt.SbtGit.GitKeys._ +// GHPages plugin +import com.typesafe.sbt.sbtghpages.GhpagesPlugin.autoImport._ +import com.typesafe.sbt.site.SitePlugin.autoImport.{makeSite, siteSubdirName} +import com.typesafe.sbt.SbtGit.GitKeys.{gitBranch, gitRemoteRepo} +import com.typesafe.sbt.site.SiteScaladocPlugin.autoImport._ +import com.typesafe.sbt.site.preprocess.PreprocessPlugin.autoImport._ object BuildSettings { @@ -44,12 +47,6 @@ object BuildSettings { ) ) ) - - lazy val docSettings = Seq( - gitRemoteRepo := "https://github.com/snowplow-incubator/scala-lru-map.git", - siteSubdirName := "" - ) - lazy val javaCompilerOptions = Seq("-source", "11", "-target", "11") lazy val coverageSettings = Seq( @@ -74,4 +71,16 @@ object BuildSettings { (Test / test).value } ) + + lazy val ghPagesSettings = Seq( + ghpagesPushSite := (ghpagesPushSite dependsOn makeSite).value, + ghpagesNoJekyll := false, + gitRemoteRepo := "git@github.com:snowplow-incubator/scala-lru-map.git", + gitBranch := Some("gh-pages"), + SiteScaladoc / siteSubdirName := s"${version.value}", + Preprocess / preprocessVars := Map("VERSION" -> version.value), + ghpagesCleanSite / excludeFilter := new FileFilter { + def accept(f: File) = true + } + ) } diff --git a/src/site-preprocess/index.html b/src/site-preprocess/index.html new file mode 100644 index 0000000..66e62a4 --- /dev/null +++ b/src/site-preprocess/index.html @@ -0,0 +1,20 @@ + + + + + Project Documentation + + + +Go to the project documentation + + + From aaf1831763f5522200fbaf3d11ee8fb73aee2d19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Poniedzia=C5=82ek?= Date: Thu, 10 Feb 2022 15:20:51 +0100 Subject: [PATCH 18/21] Use `cats.effect.Sync` bound on pure cache instance (close #52) --- .../scala/com.snowplowanalytics.lrumap/CreateLruMap.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com.snowplowanalytics.lrumap/CreateLruMap.scala b/src/main/scala/com.snowplowanalytics.lrumap/CreateLruMap.scala index 3a3f396..7e6a053 100644 --- a/src/main/scala/com.snowplowanalytics.lrumap/CreateLruMap.scala +++ b/src/main/scala/com.snowplowanalytics.lrumap/CreateLruMap.scala @@ -13,7 +13,7 @@ package com.snowplowanalytics.lrumap import cats.Id -import cats.effect.Async +import cats.effect.Sync import cats.syntax.functor._ import com.github.blemale.scaffeine.Scaffeine @@ -55,7 +55,7 @@ object CreateLruMap { } /** Pure instance */ - implicit def asyncInitCache[F[_], K, V](implicit F: Async[F]): CreateLruMap[F, K, V] = + implicit def syncInitCache[F[_], K, V](implicit F: Sync[F]): CreateLruMap[F, K, V] = new CreateLruMap[F, K, V] { def create(size: Int): F[LruMap[F, K, V]] = From b4b92d7044a19298cff760f6292d0cc55102de88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Poniedzia=C5=82ek?= Date: Wed, 16 Feb 2022 10:52:01 +0100 Subject: [PATCH 19/21] Prepare for 0.6.0 release --- CHANGELOG | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 76ac765..0ed62f5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,24 @@ +Version 0.6.0 (2022-02-16) +-------------------------- +Use `cats.effect.Sync` bound on pure cache instance (#52) +Add publishing ScalaDocs (#51) +Add sbt-coveralls (#50) +Update copyright to 2022 (#49) +Add sbt-mima-plugin (#48) +Migrate from travis to github actions (#35) +Bump sbt-tpolecat to 0.1.20 (#45) +Bump sbt-scoverage to 1.9.3 (#44) +Bump sbt-ghpages to 0.6.3 (#43) +Bump sbt-site to 1.4.1 (#42) +Bump sbt-scalafmt to 2.4.6 (#41) +Remove specs2-core dependency (#39) +Bump scalacheck to 1.15.4 (#38) +Bump cats-core to 2.7.0 (#36) +Bump cats-effect to 3.3.5 (#37) +Bump sbt to 1.6.2 (#40) +Bump scala to 2.13.8, 2.12.15 (#46) +Replacement for scalacache-guava (#34) + Version 0.5.0 (2020-07-12) -------------------------- Cherry-pick #29 from 0.3.1 (#31) From 239f211e9eb55ba25b085379492938577b07e411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Poniedzia=C5=82ek?= Date: Thu, 17 Feb 2022 13:23:45 +0100 Subject: [PATCH 20/21] Simplify ghpages publish task --- .github/workflows/release.yml | 39 +++++++++++++---------------------- project/BuildSettings.scala | 2 +- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 988497e..41b1014 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,30 +12,19 @@ jobs: - uses: actions/checkout@v2 - uses: coursier/cache-action@v6 - - name: Deploy scala-lru-map to Maven Central - run: sbt ci-release - env: - PGP_PASSPHRASE: ${{ secrets.SONA_PGP_PASSPHRASE }} - PGP_SECRET: ${{ secrets.SONA_PGP_SECRET }} - SONATYPE_USERNAME: ${{ secrets.SONA_USER }} - SONATYPE_PASSWORD: ${{ secrets.SONA_PASS }} +# - name: Deploy scala-lru-map to Maven Central +# run: sbt ci-release +# env: +# PGP_PASSPHRASE: ${{ secrets.SONA_PGP_PASSPHRASE }} +# PGP_SECRET: ${{ secrets.SONA_PGP_SECRET }} +# SONATYPE_USERNAME: ${{ secrets.SONA_USER }} +# SONATYPE_PASSWORD: ${{ secrets.SONA_PASS }} + + - name: Make site + run: sbt makeSite - name: Publish ScalaDoc - run: | - project_version=$(sbt version -Dsbt.log.noformat=true | perl -ne 'print "$1\n" if /info.*(\d+\.\d+\.\d+[^\r\n]*)/' | tail -n 1 | tr -d '\n') - if [[ "${{ github.ref }}" = "refs/tags/${project_version}" ]] - then - sbt makeSite - echo Publishing Scaladoc - git fetch - git checkout gh-pages - cp -r target/site/* . - git config user.name "GitHub Actions" - git config user.email "<>" - git add $project_version - git commit -m "Added Scaladoc for $project_version" - git push origin gh-pages - else - echo "${{ github.ref }} does not match project version $project_version => not publishing" - exit 1 - fi + uses: JamesIves/github-pages-deploy-action@v4.2.5 + with: + branch: gh-pages + folder: target/site \ No newline at end of file diff --git a/project/BuildSettings.scala b/project/BuildSettings.scala index 9883c46..3f8aac2 100644 --- a/project/BuildSettings.scala +++ b/project/BuildSettings.scala @@ -75,7 +75,7 @@ object BuildSettings { lazy val ghPagesSettings = Seq( ghpagesPushSite := (ghpagesPushSite dependsOn makeSite).value, ghpagesNoJekyll := false, - gitRemoteRepo := "git@github.com:snowplow-incubator/scala-lru-map.git", + gitRemoteRepo := "https://github.com/snowplow-incubator/scala-lru-map.git", gitBranch := Some("gh-pages"), SiteScaladoc / siteSubdirName := s"${version.value}", Preprocess / preprocessVars := Map("VERSION" -> version.value), From f9f5795cdbf2172d3295212c9169d8e60ef69744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Poniedzia=C5=82ek?= Date: Thu, 17 Feb 2022 16:41:12 +0100 Subject: [PATCH 21/21] Simplify ghpages publish task --- .github/workflows/release.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 41b1014..bb99d3d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,14 +12,6 @@ jobs: - uses: actions/checkout@v2 - uses: coursier/cache-action@v6 -# - name: Deploy scala-lru-map to Maven Central -# run: sbt ci-release -# env: -# PGP_PASSPHRASE: ${{ secrets.SONA_PGP_PASSPHRASE }} -# PGP_SECRET: ${{ secrets.SONA_PGP_SECRET }} -# SONATYPE_USERNAME: ${{ secrets.SONA_USER }} -# SONATYPE_PASSWORD: ${{ secrets.SONA_PASS }} - - name: Make site run: sbt makeSite @@ -27,4 +19,13 @@ jobs: uses: JamesIves/github-pages-deploy-action@v4.2.5 with: branch: gh-pages - folder: target/site \ No newline at end of file + folder: target/site + clean: false + + - name: Deploy scala-lru-map to Maven Central + run: sbt ci-release + env: + PGP_PASSPHRASE: ${{ secrets.SONA_PGP_PASSPHRASE }} + PGP_SECRET: ${{ secrets.SONA_PGP_SECRET }} + SONATYPE_USERNAME: ${{ secrets.SONA_USER }} + SONATYPE_PASSWORD: ${{ secrets.SONA_PASS }} \ No newline at end of file