Skip to content

Commit

Permalink
Merge pull request #384 from Dwolla/ci-release
Browse files Browse the repository at this point in the history
Use sbt-ci-release and update package names
  • Loading branch information
bpholt committed Feb 1, 2022
2 parents c0a7326 + eb53c40 commit d005337
Show file tree
Hide file tree
Showing 52 changed files with 277 additions and 166 deletions.
75 changes: 72 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12.14, 2.13.6]
scala: [2.12.15, 2.13.6]
java: [adopt@1.8]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -53,7 +53,76 @@ jobs:

- env:
SBT_OPTS: '-J-Xmx8G'
run: 'sbt --client ''++${{ matrix.scala }}; clean; coverage; test; scalastyle; scalafmtCheck; scalafmtSbtCheck; test:scalafmtCheck; unidoc; coverageReport'''
run: sbt --client '++${{ matrix.scala }}; clean; coverage; test; scalastyle; scalafmtCheck; scalafmtSbtCheck; Test / scalafmtCheck; unidoc; coverageReport'

- name: Code coverage analysis
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v1

- name: Compress target directories
run: tar cf targets.tar util/target target effect/target scalafix/input/target effect3/target finagle/target scalafix/rules/target scalafix/tests/target benchmark/target project/target

- name: Upload target directories
uses: actions/upload-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }}
path: targets.tar

publish:
name: Publish Artifacts
needs: [build]
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v'))
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.6]
java: [adopt@1.8]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Java and Scala
uses: olafurpg/setup-scala@v12
with:
java-version: ${{ matrix.java }}

- name: Cache sbt
uses: actions/cache@v2
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Download target directories (2.12.15)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-2.12.15-${{ matrix.java }}

- name: Inflate target directories (2.12.15)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (2.13.6)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-2.13.6-${{ matrix.java }}

- name: Inflate target directories (2.13.6)
run: |
tar xf targets.tar
rm targets.tar
- env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
run: sbt --client '++${{ matrix.scala }}; ci-release'
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# catbird

[![Build status](https://img.shields.io/github/workflow/status/travisbrown/catbird/Continuous%20Integration.svg)](http://github.com/travisbrown/catbird/actions)
[![Coverage status](https://img.shields.io/codecov/c/github/travisbrown/catbird/master.svg)](https://codecov.io/github/travisbrown/catbird)
[![Maven Central](https://img.shields.io/maven-central/v/io.catbird/catbird-finagle_2.13.svg)](https://maven-badges.herokuapp.com/maven-central/io.catbird/catbird-finagle_2.13)

[![Build status](https://img.shields.io/github/workflow/status/typelevel/catbird/Continuous%20Integration.svg)](http://github.com/typelevel/catbird/actions)
[![Coverage status](https://img.shields.io/codecov/c/github/typelevel/catbird/master.svg)](https://codecov.io/github/typelevel/catbird)
[![Maven Central](https://img.shields.io/maven-central/v/org.typelevel.catbird/catbird-finagle_2.13.svg)](https://maven-badges.herokuapp.com/maven-central/org.typelevel.catbird/catbird-finagle_2.13)

This project provides [Cats](https://github.com/typelevel/cats) type class instances (and other useful
Cats-related stuff) for various [Twitter Open Source](https://twitter.com/twitteross) Scala
Expand All @@ -13,7 +12,7 @@ It currently includes the following:

* Type class instances for `Future`, `Var`, and `Try` (including `Monad` or `MonadError`, `Semigroup`, and equality)
* Category and profunctor instances for `Service`
* A `Rerunnable` type that wraps `Future` but provides semantics more like Scalaz's `Task`
* A `Rerunnable` type that wraps `Future` but provides semantics more like Cats Effect's `IO`

These are reasonably well-tested (thanks to [Discipline](https://github.com/typelevel/discipline)).

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.catbird.benchmark
package org.typelevel.catbird.benchmark

import com.twitter.util.{ Await, Future, FuturePool }
import io.catbird.util.Rerunnable
import org.typelevel.catbird.util.Rerunnable
import java.util.concurrent.{ ExecutorService, Executors, TimeUnit }
import org.openjdk.jmh.annotations._

Expand All @@ -10,7 +10,7 @@ import org.openjdk.jmh.annotations._
*
* The following command will run the benchmarks with reasonable settings:
*
* > sbt "benchmark/jmh:run -i 20 -wi 10 -f 2 -t 1 io.catbird.benchmark.RerunnableBenchmark"
* > sbt "benchmark/jmh:run -i 20 -wi 10 -f 2 -t 1 org.typelevel.catbird.benchmark.RerunnableBenchmark"
*/
@State(Scope.Thread)
@BenchmarkMode(Array(Mode.Throughput))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.catbird.benchmark
package org.typelevel.catbird.benchmark

import org.scalatest.BeforeAndAfter
import org.scalatest.flatspec.AnyFlatSpec
Expand Down
164 changes: 77 additions & 87 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,16 @@ val catsEffect3Version = "3.2.9"
val utilVersion = "21.8.0"
val finagleVersion = "21.8.0"

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

ThisBuild / organization := "io.catbird"
ThisBuild / organization := "org.typelevel"

(Global / onChangedBuildSource) := ReloadOnSourceChanges

def compilerOptions(scalaVersion: String): Seq[String] = Seq(
"-deprecation",
"-encoding",
"UTF-8",
"-feature",
"-language:existentials",
"-language:higherKinds",
"-unchecked",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Yno-imports",
"-Yno-predef"
) ++ (if (priorTo2_13(scalaVersion))
Seq(
"-Ywarn-unused-import",
"-Yno-adapted-args",
"-Xfuture"
)
else
Seq(
"-Ywarn-unused:imports",
"-Ymacro-annotations"
))

val docMappingsApiDir = settingKey[String]("Subdirectory in site target directory for API docs")

lazy val baseSettings = Seq(
scalacOptions ++= compilerOptions(scalaVersion.value),
(Compile / console / scalacOptions) ~= {
_.filterNot(Set("-Ywarn-unused-import", "-Ywarn-unused:imports", "-Yno-imports", "-Yno-predef"))
},
Expand All @@ -55,7 +30,7 @@ lazy val baseSettings = Seq(
"org.typelevel" %% "cats-laws" % catsVersion % Test,
"org.typelevel" %% "discipline-core" % "1.3.0" % Test,
"org.typelevel" %% "discipline-scalatest" % "2.1.5" % Test,
compilerPlugin(("org.typelevel" %% "kind-projector" % "0.13.0").cross(CrossVersion.full))
compilerPlugin(("org.typelevel" %% "kind-projector" % "0.13.2").cross(CrossVersion.full))
),
resolvers += Resolver.sonatypeRepo("snapshots"),
docMappingsApiDir := "api"
Expand All @@ -66,22 +41,29 @@ lazy val allSettings = baseSettings ++ publishSettings
lazy val root = project
.in(file("."))
.enablePlugins(GhpagesPlugin, ScalaUnidocPlugin)
.settings(allSettings ++ noPublishSettings)
.settings(allSettings)
.settings(
(ScalaUnidoc / unidoc / unidocProjectFilter) := inAnyProject -- inProjects(benchmark, effect3),
(ScalaUnidoc / unidoc / unidocProjectFilter) := inAnyProject -- inProjects(
benchmark,
effect3,
`scalafix-input`,
`scalafix-output`,
`scalafix-tests`
),
addMappingsToSiteDir((ScalaUnidoc / packageDoc / mappings), docMappingsApiDir),
git.remoteRepo := "git@github.com:travisbrown/catbird.git"
git.remoteRepo := "git@github.com:typelevel/catbird.git",
publish / skip := true
)
.settings(
(console / initialCommands) :=
"""
|import com.twitter.finagle._
|import com.twitter.util._
|import io.catbird.finagle._
|import io.catbird.util._
|import org.typelevel.catbird.finagle._
|import org.typelevel.catbird.util._
""".stripMargin
)
.aggregate(util, effect, effect3, finagle, benchmark)
.aggregate(util, effect, effect3, finagle, benchmark, `scalafix-rules`, `scalafix-tests`)
.dependsOn(util, effect, finagle)

lazy val util = project
Expand Down Expand Up @@ -136,10 +118,10 @@ lazy val finagle = project
.dependsOn(util)

lazy val benchmark = project
.settings(moduleName := "catbird-benchmark")
.settings(allSettings)
.settings(noPublishSettings)
.settings(
moduleName := "catbird-benchmark",
publish / skip := true,
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10",
scalacOptions ~= {
_.filterNot(Set("-Yno-imports", "-Yno-predef"))
Expand All @@ -149,67 +131,34 @@ lazy val benchmark = project
.dependsOn(util)

lazy val publishSettings = Seq(
releaseCrossBuild := true,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
releaseVcsSign := true,
homepage := Some(url("https://github.com/travisbrown/catbird")),
homepage := Some(url("https://github.com/typelevel/catbird")),
licenses := Seq("Apache 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
publishMavenStyle := true,
(Test / publishArtifact) := false,
pomIncludeRepository := { _ => false },
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"))
},
autoAPIMappings := true,
apiURL := Some(url("https://travisbrown.github.io/catbird/api/")),
apiURL := Some(url("https://typelevel.org/catbird/api/")),
scmInfo := Some(
ScmInfo(
url("https://github.com/travisbrown/catbird"),
"scm:git:git@github.com:travisbrown/catbird.git"
url("https://github.com/typelevel/catbird"),
"scm:git:git@github.com:typelevel/catbird.git"
)
),
pomExtra := (
<developers>
<developer>
<id>travisbrown</id>
<name>Travis Brown</name>
<url>https://twitter.com/travisbrown</url>
</developer>
</developers>
)
)

lazy val noPublishSettings = Seq(
publish := {},
publishLocal := {},
publishArtifact := false
developers += Developer("travisbrown", "Travis Brown", "", url("https://twitter.com/travisbrown"))
)

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

def priorTo2_13(scalaVersion: String): Boolean =
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, minor)) if minor < 13 => true
case _ => false
}

ThisBuild / githubWorkflowJavaVersions := Seq("adopt@1.8")
// No auto-publish atm. Remove this line to generate publish stage
ThisBuild / githubWorkflowPublishTargetBranches := Seq.empty
ThisBuild / githubWorkflowPublishTargetBranches := Seq(RefPredicate.StartsWith(Ref.Tag("v")))
ThisBuild / githubWorkflowPublish := Seq(
WorkflowStep.Sbt(
List("ci-release"),
env = Map(
"PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}",
"PGP_SECRET" -> "${{ secrets.PGP_SECRET }}",
"SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}",
"SONATYPE_USERNAME" -> "${{ secrets.SONATYPE_USERNAME }}"
)
)
)
ThisBuild / githubWorkflowBuild := Seq(
WorkflowStep.Sbt(
List(
Expand All @@ -219,7 +168,7 @@ ThisBuild / githubWorkflowBuild := Seq(
"scalastyle",
"scalafmtCheck",
"scalafmtSbtCheck",
"test:scalafmtCheck",
"Test / scalafmtCheck",
"unidoc",
"coverageReport"
),
Expand All @@ -232,3 +181,44 @@ ThisBuild / githubWorkflowBuild := Seq(
name = Some("Code coverage analysis")
)
)

lazy val `scalafix-rules` = (project in file("scalafix/rules")).settings(
moduleName := "catbird-scalafix",
libraryDependencies ++= Seq(
"ch.epfl.scala" %% "scalafix-core" % _root_.scalafix.sbt.BuildInfo.scalafixVersion
)
)

lazy val `scalafix-input` = (project in file("scalafix/input")).settings(
publish / skip := true,
libraryDependencies ++= Seq(
"io.catbird" %% "catbird-util" % "21.8.0"
),
scalacOptions ~= { _.filterNot(_ == "-Xfatal-warnings") },
semanticdbEnabled := true,
semanticdbVersion := scalafixSemanticdb.revision
)

lazy val `scalafix-output` = (project in file("scalafix/output"))
.settings(
githubWorkflowArtifactUpload := false,
publish / skip := true,
scalacOptions ~= { _.filterNot(_ == "-Xfatal-warnings") }
)
.dependsOn(util)

lazy val `scalafix-tests` = (project in file("scalafix/tests"))
.settings(
publish / skip := true,
libraryDependencies += {
import _root_.scalafix.sbt.BuildInfo.scalafixVersion
("ch.epfl.scala" % "scalafix-testkit" % scalafixVersion % Test).cross(CrossVersion.full)
},
scalafixTestkitOutputSourceDirectories := (`scalafix-output` / Compile / unmanagedSourceDirectories).value,
scalafixTestkitInputSourceDirectories := (`scalafix-input` / Compile / unmanagedSourceDirectories).value,
scalafixTestkitInputClasspath := (`scalafix-input` / Compile / fullClasspath).value,
scalafixTestkitInputScalacOptions := (`scalafix-input` / Compile / scalacOptions).value,
scalafixTestkitInputScalaVersion := (`scalafix-input` / Compile / scalaVersion).value
)
.dependsOn(`scalafix-rules`)
.enablePlugins(ScalafixTestkitPlugin)
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.catbird.util.effect
package org.typelevel.catbird.util.effect

import cats.effect.{ Bracket, ExitCase }
import com.twitter.util.{ Future, Monitor }
import io.catbird.util.FutureMonadError
import org.typelevel.catbird.util.FutureMonadError
import java.lang.Throwable
import scala.Unit

Expand Down
Loading

0 comments on commit d005337

Please sign in to comment.