Skip to content

Commit

Permalink
Merge pull request #290 from davenverse/scala3
Browse files Browse the repository at this point in the history
Update Build and Deps
  • Loading branch information
ChristopherDavenport authored Aug 3, 2021
2 parents c3bb2ee + 4035990 commit 902c2a0
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 256 deletions.
28 changes: 15 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12.14, 2.13.6]
java: [[email protected]]
scala: [2.12.14, 2.13.6, 3.0.1]
java: [[email protected], [email protected]]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
Expand Down Expand Up @@ -53,30 +53,30 @@ jobs:
if: matrix.scala == '2.13.6'
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6.0
ruby-version: 3.0.1

- name: Install microsite dependencies
if: matrix.scala == '2.13.6'
run: |
gem install saas
gem install jekyll -v 3.2.1
gem install jekyll -v 4.2.0
- name: Check that workflows are up to date
run: sbt ++${{ matrix.scala }} githubWorkflowCheck
run: sbt --client '++${{ matrix.scala }}; githubWorkflowCheck'

- run: sbt ++${{ matrix.scala }} test mimaReportBinaryIssues
- run: sbt --client '++${{ matrix.scala }}; test; mimaReportBinaryIssues'

- if: matrix.scala == '2.13.6'
run: sbt ++${{ matrix.scala }} site/makeMicrosite
run: sbt --client '++${{ matrix.scala }}; site/makeMicrosite'

publish:
name: Publish Artifacts
needs: [build]
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v'))
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.6]
scala: [3.0.1]
java: [[email protected]]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -107,20 +107,22 @@ jobs:
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6.0
ruby-version: 3.0.1

- name: Install microsite dependencies
run: |
gem install saas
gem install jekyll -v 3.2.1
gem install jekyll -v 4.2.0
- name: Publish artifacts to Sonatype
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
run: sbt ++${{ matrix.scala }} ci-release
run: sbt --client '++${{ matrix.scala }}; ci-release'

- uses: christopherdavenport/create-ghpages-ifnotexists@v1

- name: Publish microsite
run: sbt ++${{ matrix.scala }} ++2.13.6 site/publishMicrosite
run: sbt --client '++${{ matrix.scala }}; site/publishMicrosite'
258 changes: 26 additions & 232 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,260 +1,54 @@
import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}
ThisBuild / crossScalaVersions := Seq("2.12.14", "2.13.6", "3.0.1")

val Scala213 = "2.13.6"

ThisBuild / crossScalaVersions := Seq("2.12.14", Scala213)
ThisBuild / scalaVersion := crossScalaVersions.value.last

ThisBuild / githubWorkflowArtifactUpload := false

val Scala213Cond = s"matrix.scala == '$Scala213'"

def rubySetupSteps(cond: Option[String]) = Seq(
WorkflowStep.Use(
UseRef.Public("ruby", "setup-ruby", "v1"),
name = Some("Setup Ruby"),
params = Map("ruby-version" -> "2.6.0"),
cond = cond),

WorkflowStep.Run(
List(
"gem install saas",
"gem install jekyll -v 3.2.1"),
name = Some("Install microsite dependencies"),
cond = cond))

ThisBuild / githubWorkflowBuildPreamble ++=
rubySetupSteps(Some(Scala213Cond))

ThisBuild / githubWorkflowBuild := Seq(
WorkflowStep.Sbt(List("test", "mimaReportBinaryIssues")),

WorkflowStep.Sbt(
List("site/makeMicrosite"),
cond = Some(Scala213Cond)))

ThisBuild / githubWorkflowTargetTags ++= Seq("v*")

// currently only publishing tags
ThisBuild / githubWorkflowPublishTargetBranches :=
Seq(RefPredicate.StartsWith(Ref.Tag("v")))

ThisBuild / githubWorkflowPublishPreamble ++=
WorkflowStep.Use(UseRef.Public("olafurpg", "setup-gpg", "v3")) +: rubySetupSteps(None)

ThisBuild / githubWorkflowPublish := Seq(
WorkflowStep.Sbt(
List("ci-release"),
name = Some("Publish artifacts to Sonatype"),
env = Map(
"PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}",
"PGP_SECRET" -> "${{ secrets.PGP_SECRET }}",
"SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}",
"SONATYPE_USERNAME" -> "${{ secrets.SONATYPE_USERNAME }}")),
val catsV = "2.6.1"
val catsEffectV = "3.1.1"
val shapelessV = "2.3.7"
val fs2V = "3.0.4"
val http4sV = "0.23.0"
lazy val epimetheusV = "0.5.0-M2"
val specs2V = "4.12.3"

WorkflowStep.Sbt(
List(s"++$Scala213", "site/publishMicrosite"),
name = Some("Publish microsite")
)
)

lazy val `epimetheus-http4s` = project.in(file("."))
.disablePlugins(MimaPlugin)
.settings(commonSettings, releaseSettings, skipOnPublishSettings)
.enablePlugins(NoPublishPlugin)
.aggregate(core, push)

lazy val core = project.in(file("core"))
.settings(commonSettings, releaseSettings, mimaSettings)
.settings(
name := "epimetheus-http4s"
)
name := "epimetheus-http4s",
).settings(sharedDeps)

lazy val push = project.in(file("pushgateway"))
.settings(commonSettings, releaseSettings, mimaSettings)
.settings(
name := "epimetheus-http4s-pushgateway",
libraryDependencies ++= Seq(
"org.http4s" %% "http4s-client" % http4sV
)
)
).settings(sharedDeps)

lazy val site = project.in(file("site"))
.settings(commonSettings, skipOnPublishSettings, micrositeSettings)
.dependsOn(core)
.disablePlugins(MimaPlugin)
.enablePlugins(MicrositesPlugin)
.enablePlugins(MdocPlugin)

lazy val contributors = Seq(
"ChristopherDavenport" -> "Christopher Davenport"
)

val catsV = "2.6.1"
val catsEffectV = "3.1.1"
val shapelessV = "2.3.7"
val fs2V = "3.0.4"
val http4sV = "0.23.0-RC1"
lazy val epimetheusV = "0.5.0-M1"

val specs2V = "4.12.1"

val kindProjectorV = "0.13.0"
val betterMonadicForV = "0.3.1"

// General Settings
lazy val commonSettings = Seq(
organization := "io.chrisdavenport",

scalacOptions in (Compile, doc) ++= Seq(
"-groups",
"-sourcepath", (baseDirectory in LocalRootProject).value.getAbsolutePath,
"-doc-source-url", "https://github.com/davenverse/epimetheus-http4s/blob/v" + version.value + "€{FILE_PATH}.scala"
),

addCompilerPlugin("org.typelevel" %% "kind-projector" % kindProjectorV cross CrossVersion.full),
addCompilerPlugin("com.olegpy" %% "better-monadic-for" % betterMonadicForV),
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-core" % catsV,
"org.typelevel" %% "cats-effect" % catsEffectV,

"com.chuusai" %% "shapeless" % shapelessV,

"co.fs2" %% "fs2-core" % fs2V,
"co.fs2" %% "fs2-io" % fs2V,

"org.http4s" %% "http4s-core" % http4sV,
"org.http4s" %% "http4s-dsl" % http4sV,

"io.chrisdavenport" %% "epimetheus" % epimetheusV,

"org.specs2" %% "specs2-core" % specs2V % Test,
"org.specs2" %% "specs2-scalacheck" % specs2V % Test
)
)

lazy val releaseSettings = {
Seq(
publishArtifact in Test := false,
scmInfo := Some(
ScmInfo(
url("https://github.com/ChristopherDavenport/epimetheus-http4s"),
"[email protected]:ChristopherDavenport/epimetheus-http4s.git"
)
),
homepage := Some(url("https://github.com/ChristopherDavenport/epimetheus-http4s")),
licenses += ("MIT", url("http://opensource.org/licenses/MIT")),
publishMavenStyle := true,
pomIncludeRepository := { _ =>
false
},
pomExtra := {
<developers>
{for ((username, name) <- contributors) yield
<developer>
<id>{username}</id>
<name>{name}</name>
<url>http://github.com/{username}</url>
</developer>
}
</developers>
}
.enablePlugins(NoPublishPlugin)
.enablePlugins(DavenverseMicrositePlugin)
.settings(
micrositeDescription := "Epimetheus Http4s Metrics",
)
}

lazy val mimaSettings = {

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
}
lazy val sharedDeps = Seq(
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-core" % catsV,
"org.typelevel" %% "cats-effect" % catsEffectV,

def mimaVersions(version: String): Set[String] = {
VersionNumber(version) match {
case VersionNumber(Seq(major, minor, patch, _*), _, _) if patch.toInt > 0 =>
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(
"0.4.0",
"0.4.1"
)
"co.fs2" %% "fs2-core" % fs2V,
"co.fs2" %% "fs2-io" % fs2V,

// Safety Net for Inclusions
lazy val extraVersions: Set[String] = Set()
"org.http4s" %% "http4s-core" % http4sV,
"org.http4s" %% "http4s-dsl" % http4sV,

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()
}
)
}
"io.chrisdavenport" %% "epimetheus" % epimetheusV,

lazy val micrositeSettings = {
import microsites._
Seq(
micrositeName := "epimetheus-http4s",
micrositeDescription := "Epimetheus Http4s Metrics",
micrositeAuthor := "Christopher Davenport",
micrositeGithubOwner := "davenverse",
micrositeGithubRepo := "epimetheus-http4s",
micrositeBaseUrl := "/epimetheus-http4s",
micrositeDocumentationUrl := "https://www.javadoc.io/doc/io.chrisdavenport/epimetheus-http4s_2.13",
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"
),
libraryDependencies += "com.47deg" %% "github4s" % "0.28.5",
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"))
"org.typelevel" %% "munit-cats-effect-3" % "1.0.5" % Test,
)
)
}

lazy val skipOnPublishSettings = Seq(
skip in publish := true,
publish := (()),
publishLocal := (()),
publishArtifact := false,
publishTo := None
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import org.http4s.{Method, Status}
import org.http4s.metrics.MetricsOps
import org.http4s.metrics.TerminationType
import org.http4s.metrics.TerminationType.{Abnormal, Error, Timeout, Canceled}
import shapeless._

import io.chrisdavenport.epimetheus._

Expand Down Expand Up @@ -156,7 +155,7 @@ object EpimetheusOps {
prefix |+| Name("_") |+| Name("active_request_count"),
"Total Active Requests.",
Sized(Label("classifier")),
{c: Classifier => Sized(c.s)}
{(c: Classifier) => Sized(c.s)}
)
requests <- Counter.labelled(
cr,
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.4
sbt.version=1.5.5
9 changes: 1 addition & 8 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.9.2")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.21")
addSbtPlugin("com.47deg" % "sbt-microsites" % "1.3.4")
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.6.0")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7")
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.12.0")
addSbtPlugin("io.chrisdavenport" % "sbt-davenverse" % "0.0.7")

0 comments on commit 902c2a0

Please sign in to comment.