From f4692e495b45f8d816a845daada6a5f9b61c61b8 Mon Sep 17 00:00:00 2001 From: Chris Davenport Date: Wed, 11 Dec 2019 14:15:28 -0800 Subject: [PATCH 1/2] Upgrade to New Versions --- .travis.yml | 58 ++-- build.sbt | 268 +++++------------- .../epimetheus/mules/CacheLookupCounter.scala | 4 + .../mules/CacheLookupCounterSpec.scala | 8 +- project/build.properties | 2 +- project/plugins.sbt | 17 +- {docs/src/main/tut => site/docs}/index.md | 0 version.sbt | 1 - 8 files changed, 129 insertions(+), 229 deletions(-) rename {docs/src/main/tut => site/docs}/index.md (100%) delete mode 100644 version.sbt diff --git a/.travis.yml b/.travis.yml index 8902dd4..cee421e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,30 +1,56 @@ sudo: false language: scala -scala: - - 2.12.8 - - 2.11.12 - jdk: - openjdk11 before_install: + - git fetch --tags - export PATH=${PATH}:./vendor/bundle -install: - - rvm use 2.6.0 --install --fuzzy - - gem update --system - - gem install sass - - gem install jekyll -v 3.2.1 +stages: + - name: test + - name: release + if: ((branch = master AND type = push) OR (tag IS present)) AND NOT fork -script: - - sbt ++$TRAVIS_SCALA_VERSION test - - sbt ++$TRAVIS_SCALA_VERSION mimaReportBinaryIssues - - sbt ++$TRAVIS_SCALA_VERSION docs/makeMicrosite +scala_version_213: &scala_version_213 "2.13.1" +scala_version_212: &scala_version_212 "2.12.10" -after_success: - - test $TRAVIS_PULL_REQUEST == "false" && test $TRAVIS_BRANCH == "master" && test $TRAVIS_REPO_SLUG == "ChristopherDavenport/epimetheus-mules" && sbt ++$TRAVIS_SCALA_VERSION publish - - test $TRAVIS_PULL_REQUEST == "false" && test $TRAVIS_BRANCH == "master" && test $TRAVIS_REPO_SLUG == "ChristopherDavenport/epimetheus-mules" && test $TRAVIS_SCALA_VERSION == "2.12.8" && sbt docs/publishMicrosite +jobs: + include: + # stage="test" if no stage is specified + - + name: test 2.13 + scala: *scala_version_213 + script: sbt ++$TRAVIS_SCALA_VERSION test + - name: test 2.12 + scala: *scala_version_212 + script: sbt ++$TRAVIS_SCALA_VERSION test + # - + # name: mima + # script: sbt +mimaReportBinaryIssues + - + name: docs + scala: *scala_version_213 + install: + - rvm use 2.6.0 --install --fuzzy + - gem update --system + - gem install sass + - gem install jekyll -v 4.0.0 + script: sbt ++$TRAVIS_SCALA_VERSION site/makeMicrosite + # run ci-release only if previous stages passed + - stage: release + name: release + script: sbt ci-release + - stage: release + name: microsite + scala: *scala_version_213 + install: + - rvm use 2.6.0 --install --fuzzy + - gem update --system + - gem install sass + - gem install jekyll -v 4.0.0 + script: sbt ++$TRAVIS_SCALA_VERSION site/publishMicrosite cache: directories: diff --git a/build.sbt b/build.sbt index 20fdb16..7cb3db5 100644 --- a/build.sbt +++ b/build.sbt @@ -2,52 +2,80 @@ import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType} lazy val `epimetheus-mules` = project.in(file(".")) .disablePlugins(MimaPlugin) - .settings(commonSettings, releaseSettings, skipOnPublishSettings) - .aggregate(core, docs) + .settings(skip in publish := true) + .settings(commonSettings) + .aggregate(core, site) lazy val core = project.in(file("core")) - .settings(commonSettings, releaseSettings, mimaSettings) + .settings(commonSettings) .settings( name := "epimetheus-mules" ) -lazy val docs = project.in(file("docs")) +lazy val site = project.in(file("site")) .disablePlugins(MimaPlugin) - .settings(commonSettings, skipOnPublishSettings, micrositeSettings) + .settings(skip in publish := true) + .settings(commonSettings) .dependsOn(core) .enablePlugins(MicrositesPlugin) .enablePlugins(TutPlugin) + .settings{ + import microsites._ + Seq( + micrositeName := "epimetheus-mules", + micrositeDescription := "Metrics for Mules Caches", + micrositeAuthor := "Christopher Davenport", + micrositeGithubOwner := "ChristopherDavenport", + micrositeGithubRepo := "epimetheus-mules", + micrositeBaseUrl := "/epimetheus-mules", + micrositeDocumentationUrl := "https://www.javadoc.io/doc/io.chrisdavenport/epimetheus-mules_2.12", + micrositeFooterText := None, + micrositeHighlightTheme := "atom-one-light", + micrositePalette := Map( + "brand-primary" -> "#3e5b95", + "brand-secondary" -> "#294066", + "brand-tertiary" -> "#2d5799", + "gray-dark" -> "#49494B", + "gray" -> "#7B7B7E", + "gray-light" -> "#E5E5E6", + "gray-lighter" -> "#F4F3F4", + "white-color" -> "#FFFFFF" + ), + fork in tut := true, + scalacOptions in Tut --= Seq( + "-Xfatal-warnings", + "-Ywarn-unused-import", + "-Ywarn-numeric-widen", + "-Ywarn-dead-code", + "-Ywarn-unused:imports", + "-Xlint:-missing-interpolator,_" + ), + micrositePushSiteWith := GitHub4s, + micrositeGithubToken := sys.env.get("GITHUB_TOKEN"), + micrositeExtraMdFiles := Map( + file("CHANGELOG.md") -> ExtraMdFileConfig("changelog.md", "page", Map("title" -> "changelog", "section" -> "changelog", "position" -> "100")), + file("CODE_OF_CONDUCT.md") -> ExtraMdFileConfig("code-of-conduct.md", "page", Map("title" -> "code of conduct", "section" -> "code of conduct", "position" -> "101")), + file("LICENSE") -> ExtraMdFileConfig("license.md", "page", Map("title" -> "license", "section" -> "license", "position" -> "102")) + ) + ) + } -lazy val contributors = Seq( - "ChristopherDavenport" -> "Christopher Davenport" -) - -val catsV = "1.6.1" -val catsEffectV = "1.4.0" - -val epimetheusV = "0.2.2" -val mulesV = "0.2.1" +val catsV = "2.0.0" +val catsEffectV = "2.0.0" +val epimetheusV = "0.3.0" +val mulesV = "0.3.0-M2" val specs2V = "4.8.1" -val kindProjectorV = "0.10.3" +val kindProjectorV = "0.11.0" val betterMonadicForV = "0.3.1" // General Settings lazy val commonSettings = Seq( - organization := "io.chrisdavenport", - - scalaVersion := "2.12.8", - crossScalaVersions := Seq(scalaVersion.value, "2.11.12"), - scalacOptions += "-Yrangepos", - - scalacOptions in (Compile, doc) ++= Seq( - "-groups", - "-sourcepath", (baseDirectory in LocalRootProject).value.getAbsolutePath, - "-doc-source-url", "https://github.com/ChristopherDavenport/epimetheus-mules/blob/v" + version.value + "€{FILE_PATH}.scala" - ), + scalaVersion := "2.13.1", + crossScalaVersions := Seq(scalaVersion.value, "2.12.1"), - addCompilerPlugin("org.typelevel" % "kind-projector" % kindProjectorV cross CrossVersion.binary), + addCompilerPlugin("org.typelevel" %% "kind-projector" % kindProjectorV cross CrossVersion.full), addCompilerPlugin("com.olegpy" %% "better-monadic-for" % betterMonadicForV), libraryDependencies ++= Seq( "org.typelevel" %% "cats-core" % catsV, @@ -60,173 +88,21 @@ lazy val commonSettings = Seq( ) ) -lazy val releaseSettings = { - import ReleaseTransformations._ - Seq( - releaseCrossBuild := true, - releaseProcess := Seq[ReleaseStep]( - checkSnapshotDependencies, - inquireVersions, - runClean, - runTest, - setReleaseVersion, - commitReleaseVersion, - tagRelease, - // For non cross-build projects, use releaseStepCommand("publishSigned") - releaseStepCommandAndRemaining("+publishSigned"), - setNextVersion, - commitNextVersion, - releaseStepCommand("sonatypeReleaseAll"), - pushChanges - ), - publishTo := { - val nexus = "https://oss.sonatype.org/" - if (isSnapshot.value) - Some("snapshots" at nexus + "content/repositories/snapshots") - else - Some("releases" at nexus + "service/local/staging/deploy/maven2") - }, - credentials ++= ( - for { - username <- Option(System.getenv().get("SONATYPE_USERNAME")) - password <- Option(System.getenv().get("SONATYPE_PASSWORD")) - } yield - Credentials( - "Sonatype Nexus Repository Manager", - "oss.sonatype.org", - username, - password - ) - ).toSeq, - publishArtifact in Test := false, - releasePublishArtifactsAction := PgpKeys.publishSigned.value, - scmInfo := Some( - ScmInfo( - url("https://github.com/ChristopherDavenport/epimetheus-mules"), - "git@github.com:ChristopherDavenport/epimetheus-mules.git" - ) - ), - homepage := Some(url("https://github.com/ChristopherDavenport/epimetheus-mules")), - licenses += ("MIT", url("http://opensource.org/licenses/MIT")), - publishMavenStyle := true, - pomIncludeRepository := { _ => - false - }, - pomExtra := { - - {for ((username, name) <- contributors) yield - - {username} - {name} - http://github.com/{username} - - } - - } - ) -} - -lazy val mimaSettings = { - import sbtrelease.Version - - def semverBinCompatVersions(major: Int, minor: Int, patch: Int): Set[(Int, Int, Int)] = { - val majorVersions: List[Int] = - if (major == 0 && minor == 0) List.empty[Int] // If 0.0.x do not check MiMa - else List(major) - val minorVersions : List[Int] = - if (major >= 1) Range(0, minor).inclusive.toList - else List(minor) - def patchVersions(currentMinVersion: Int): List[Int] = - if (minor == 0 && patch == 0) List.empty[Int] - else if (currentMinVersion != minor) List(0) - else Range(0, patch - 1).inclusive.toList - - val versions = for { - maj <- majorVersions - min <- minorVersions - pat <- patchVersions(min) - } yield (maj, min, pat) - versions.toSet - } - - def mimaVersions(version: String): Set[String] = { - Version(version) match { - case Some(Version(major, Seq(minor, patch), _)) => - semverBinCompatVersions(major.toInt, minor.toInt, patch.toInt) - .map{case (maj, min, pat) => maj.toString + "." + min.toString + "." + pat.toString} - case _ => - Set.empty[String] - } - } - // Safety Net For Exclusions - lazy val excludedVersions: Set[String] = Set() - - // Safety Net for Inclusions - lazy val extraVersions: Set[String] = Set() - - Seq( - mimaFailOnNoPrevious := false, - mimaFailOnProblem := mimaVersions(version.value).toList.headOption.isDefined, - mimaPreviousArtifacts := (mimaVersions(version.value) ++ extraVersions) - .filterNot(excludedVersions.contains(_)) - .map{v => - val moduleN = moduleName.value + "_" + scalaBinaryVersion.value.toString - organization.value % moduleN % v - }, - mimaBinaryIssueFilters ++= { - import com.typesafe.tools.mima.core._ - import com.typesafe.tools.mima.core.ProblemFilters._ - Seq() - } - ) -} - -lazy val micrositeSettings = { - import microsites._ - Seq( - micrositeName := "epimetheus-mules", - micrositeDescription := "Metrics for Mules Caches", - micrositeAuthor := "Christopher Davenport", - micrositeGithubOwner := "ChristopherDavenport", - micrositeGithubRepo := "epimetheus-mules", - micrositeBaseUrl := "/epimetheus-mules", - micrositeDocumentationUrl := "https://www.javadoc.io/doc/io.chrisdavenport/epimetheus-mules_2.12", - micrositeFooterText := None, - micrositeHighlightTheme := "atom-one-light", - micrositePalette := Map( - "brand-primary" -> "#3e5b95", - "brand-secondary" -> "#294066", - "brand-tertiary" -> "#2d5799", - "gray-dark" -> "#49494B", - "gray" -> "#7B7B7E", - "gray-light" -> "#E5E5E6", - "gray-lighter" -> "#F4F3F4", - "white-color" -> "#FFFFFF" - ), - fork in tut := true, - scalacOptions in Tut --= Seq( - "-Xfatal-warnings", - "-Ywarn-unused-import", - "-Ywarn-numeric-widen", - "-Ywarn-dead-code", - "-Ywarn-unused:imports", - "-Xlint:-missing-interpolator,_" - ), - libraryDependencies += "com.47deg" %% "github4s" % "0.20.1", - micrositePushSiteWith := GitHub4s, - micrositeGithubToken := sys.env.get("GITHUB_TOKEN"), - micrositeExtraMdFiles := Map( - file("CHANGELOG.md") -> ExtraMdFileConfig("changelog.md", "page", Map("title" -> "changelog", "section" -> "changelog", "position" -> "100")), - file("CODE_OF_CONDUCT.md") -> ExtraMdFileConfig("code-of-conduct.md", "page", Map("title" -> "code of conduct", "section" -> "code of conduct", "position" -> "101")), - file("LICENSE") -> ExtraMdFileConfig("license.md", "page", Map("title" -> "license", "section" -> "license", "position" -> "102")) +inThisBuild(List( + organization := "io.chrisdavenport", + homepage := Some(url("https://github.com/ChristopherDavenport/epimetheus-mules")), + licenses += ("MIT", url("http://opensource.org/licenses/MIT")), + developers := List( + Developer( + "ChristopherDavenport", + "Christopher Davenport", + "chris@christopherdavenport.tech", + url("https://github.com/ChristopherDavenport") ) - ) -} - -lazy val skipOnPublishSettings = Seq( - skip in publish := true, - publish := (()), - publishLocal := (()), - publishArtifact := false, - publishTo := None -) + ), + scalacOptions in (Compile, doc) ++= Seq( + "-groups", + "-sourcepath", (baseDirectory in LocalRootProject).value.getAbsolutePath, + "-doc-source-url", "https://github.com/ChristopherDavenport/epimetheus-mules/blob/v" + version.value + "€{FILE_PATH}.scala" + ), +)) \ No newline at end of file diff --git a/core/src/main/scala/io/chrisdavenport/epimetheus/mules/CacheLookupCounter.scala b/core/src/main/scala/io/chrisdavenport/epimetheus/mules/CacheLookupCounter.scala index d9f1902..faf34e6 100644 --- a/core/src/main/scala/io/chrisdavenport/epimetheus/mules/CacheLookupCounter.scala +++ b/core/src/main/scala/io/chrisdavenport/epimetheus/mules/CacheLookupCounter.scala @@ -98,6 +98,8 @@ object CacheLookupCounter { override def delete(k: K): F[Unit] = innerL.delete(k) override def insert(k: K, v: V): F[Unit] = innerL.insert(k, v) + override def insertWithTimeout(optionTimeout: Option[TimeSpec])(k: K, v: V): F[Unit] = + innerL.insertWithTimeout(optionTimeout)(k, v) } private class LookupCounted[F[_]: Monad, K, V]( @@ -124,6 +126,8 @@ object CacheLookupCounter { } def delete(k: K): F[Unit] = innerL.delete(k) def insert(k: K, v: V): F[Unit] = innerL.insert(k, v) + def insertWithTimeout(optionTimeout: Option[TimeSpec])(k: K, v: V): F[Unit] = + innerL.insertWithTimeout(optionTimeout)(k, v) } diff --git a/core/src/test/scala/io/chrisdavenport/epimetheus/mules/CacheLookupCounterSpec.scala b/core/src/test/scala/io/chrisdavenport/epimetheus/mules/CacheLookupCounterSpec.scala index 6c132de..c43595c 100644 --- a/core/src/test/scala/io/chrisdavenport/epimetheus/mules/CacheLookupCounterSpec.scala +++ b/core/src/test/scala/io/chrisdavenport/epimetheus/mules/CacheLookupCounterSpec.scala @@ -5,7 +5,7 @@ import io.chrisdavenport.mules._ import org.specs2._ import cats.effect._ -object CacheLookupCounterSpec extends mutable.Specification { +class CacheLookupCounterSpec extends mutable.Specification { implicit val T = IO.timer(scala.concurrent.ExecutionContext.global) @@ -13,7 +13,7 @@ object CacheLookupCounterSpec extends mutable.Specification { "modify a cache" in { val test = for { cr <- CollectorRegistry.build[IO] - cache <- MemoryCache.createMemoryCache[IO, String, String](None) + cache <- MemoryCache.ofSingleImmutableMap[IO, String, String](None) modifier <- CacheLookupCounter.register(cr) newCache = modifier.meteredMemoryCache(cache, "foo") _ <- newCache.insert("yellow", "green") @@ -35,8 +35,8 @@ object CacheLookupCounterSpec extends mutable.Specification { "modify multiple caches" in { val test = for { cr <- CollectorRegistry.build[IO] - cache <- MemoryCache.createMemoryCache[IO, String, String](None) - cache2 <- MemoryCache.createMemoryCache[IO, Int, Double](None) + cache <- MemoryCache.ofSingleImmutableMap[IO, String, String](None) + cache2 <- MemoryCache.ofSingleImmutableMap[IO, Int, Double](None) modifier <- CacheLookupCounter.register(cr) newCache = modifier.meteredMemoryCache(cache, "foo") newCache2 = modifier.meteredMemoryCache(cache2, "bar") diff --git a/project/build.properties b/project/build.properties index c0bab04..5a9ed92 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.2.8 +sbt.version=1.3.4 diff --git a/project/plugins.sbt b/project/plugins.sbt index b3d1ab9..378e784 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,14 +1,9 @@ -addSbtPlugin("com.dwijnand" % "sbt-travisci" % "1.2.0") -addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0") -addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.2") -addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.7") -addSbtPlugin("org.lyranthe.sbt" % "partial-unification" % "1.1.2") -addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.12") -addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.8.1") -addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.6.0") -addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.6.13") -addSbtPlugin("com.47deg" % "sbt-microsites" % "0.9.4") +addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.4.31") +addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.10") +addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.6.1") +addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.0.3") +addSbtPlugin("com.47deg" % "sbt-microsites" % "1.0.2") addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") -addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.7") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.1") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.31") +addSbtPlugin("io.chrisdavenport" % "sbt-mima-version-check" % "0.1.2") diff --git a/docs/src/main/tut/index.md b/site/docs/index.md similarity index 100% rename from docs/src/main/tut/index.md rename to site/docs/index.md diff --git a/version.sbt b/version.sbt deleted file mode 100644 index 9904311..0000000 --- a/version.sbt +++ /dev/null @@ -1 +0,0 @@ -version in ThisBuild := "0.2.2-SNAPSHOT" From b5d8cb1797f951c62727d1af636a46a8db913546 Mon Sep 17 00:00:00 2001 From: Chris Davenport Date: Wed, 11 Dec 2019 14:23:39 -0800 Subject: [PATCH 2/2] Go around 2.12 Weirdness --- .../chrisdavenport/epimetheus/mules/CacheLookupCounter.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/scala/io/chrisdavenport/epimetheus/mules/CacheLookupCounter.scala b/core/src/main/scala/io/chrisdavenport/epimetheus/mules/CacheLookupCounter.scala index faf34e6..3dc5c87 100644 --- a/core/src/main/scala/io/chrisdavenport/epimetheus/mules/CacheLookupCounter.scala +++ b/core/src/main/scala/io/chrisdavenport/epimetheus/mules/CacheLookupCounter.scala @@ -110,7 +110,7 @@ object CacheLookupCounter { def lookup(k: K): F[Option[V]] = innerL.lookup(k).flatMap{ case s@Some(_) => c.label(CacheLookupCounterStatus(cacheName, CacheHit)).inc.as(s) - case n@None => c.label(CacheLookupCounterStatus(cacheName, CacheMiss)).inc.as(n) + case None => c.label(CacheLookupCounterStatus(cacheName, CacheMiss)).inc.as(None) } } @@ -122,7 +122,7 @@ object CacheLookupCounter { def lookup(k: K): F[Option[V]] = innerL.lookup(k).flatMap{ case s@Some(_) => c.label(CacheLookupCounterStatus(cacheName, CacheHit)).inc.as(s) - case n@None => c.label(CacheLookupCounterStatus(cacheName, CacheMiss)).inc.as(n) + case None => c.label(CacheLookupCounterStatus(cacheName, CacheMiss)).inc.as(None) } def delete(k: K): F[Unit] = innerL.delete(k) def insert(k: K, v: V): F[Unit] = innerL.insert(k, v)