Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to sbt-typelevel #429

Merged
merged 12 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 41 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ on:
branches: ['**']
push:
branches: ['**']
tags: [v*]

env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
Expand All @@ -23,18 +28,20 @@ jobs:
matrix:
os: [ubuntu-latest]
scala: [2.12.15, 2.13.6]
java: [adopt@1.8]
java: [temurin@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
- name: Setup Java (temurin@8)
if: matrix.java == 'temurin@8'
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java }}
distribution: temurin
java-version: 8

- name: Cache sbt
uses: actions/cache@v2
Expand All @@ -49,22 +56,26 @@ jobs:
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Check that workflows are up to date
run: sbt --client '++${{ matrix.scala }}; githubWorkflowCheck'
run: sbt '++${{ matrix.scala }}' 'project /' githubWorkflowCheck

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

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

- name: Make target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v'))
run: mkdir -p util/target target effect/target scalafix/input/target effect3/target finagle/target scalafix/rules/target scalafix/tests/target benchmark/target project/target

- name: Compress target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v'))
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
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v'))
uses: actions/upload-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }}
name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }}
path: targets.tar

publish:
Expand All @@ -75,18 +86,20 @@ jobs:
matrix:
os: [ubuntu-latest]
scala: [2.13.6]
java: [adopt@1.8]
java: [temurin@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
- name: Setup Java (temurin@8)
if: matrix.java == 'temurin@8'
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java }}
distribution: temurin
java-version: 8

- name: Cache sbt
uses: actions/cache@v2
Expand All @@ -103,7 +116,7 @@ jobs:
- name: Download target directories (2.12.15)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-2.12.15-${{ matrix.java }}
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15

- name: Inflate target directories (2.12.15)
run: |
Expand All @@ -113,16 +126,23 @@ jobs:
- name: Download target directories (2.13.6)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-2.13.6-${{ matrix.java }}
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.6

- 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'
- name: Import signing key
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == ''
run: echo $PGP_SECRET | base64 -d | gpg --import

- name: Import signing key and strip passphrase
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE != ''
run: |
echo "$PGP_SECRET" | base64 -d > /tmp/signing-key.gpg
echo "$PGP_PASSPHRASE" | gpg --pinentry-mode loopback --passphrase-fd 0 --import /tmp/signing-key.gpg
(echo "$PGP_PASSPHRASE"; echo; echo) | gpg --command-fd 0 --pinentry-mode loopback --change-passphrase $(gpg --list-secret-keys --with-colons 2> /dev/null | grep '^sec:' | cut --delimiter ':' --fields 5 | tail -n 1)

- name: Publish
run: sbt '++${{ matrix.scala }}' tlRelease
2 changes: 1 addition & 1 deletion .github/workflows/clean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ jobs:
printf "Deleting '%s' #%d, %'d bytes\n" $name ${ARTCOUNT[$name]} $size
ghapi -X DELETE $REPO/actions/artifacts/$id
done
done
done
63 changes: 13 additions & 50 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
val catsVersion = "2.6.1"

ThisBuild / tlBaseVersion := "21.8" // TODO
bpholt marked this conversation as resolved.
Show resolved Hide resolved
ThisBuild / tlCiReleaseBranches := Seq()
bpholt marked this conversation as resolved.
Show resolved Hide resolved

// For the transition period, we publish artifacts for both cats-effect 2.x and 3.x
val catsEffectVersion = "2.5.4"
val catsEffect3Version = "3.2.9"
Expand All @@ -8,39 +11,30 @@ val utilVersion = "21.8.0"
val finagleVersion = "21.8.0"

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

ThisBuild / organization := "org.typelevel"

(Global / onChangedBuildSource) := ReloadOnSourceChanges

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

lazy val baseSettings = Seq(
(Compile / console / scalacOptions) ~= {
_.filterNot(Set("-Ywarn-unused-import", "-Ywarn-unused:imports", "-Yno-imports", "-Yno-predef"))
},
(Test / console / scalacOptions) ~= {
_.filterNot(Set("-Ywarn-unused-import", "-Ywarn-unused:imports", "-Yno-imports", "-Yno-predef"))
},
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-core" % catsVersion,
"org.scalacheck" %% "scalacheck" % "1.15.4" % Test,
"org.scalatest" %% "scalatest" % "3.2.10" % Test,
"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.2").cross(CrossVersion.full))
"org.typelevel" %% "discipline-scalatest" % "2.1.5" % Test
),
resolvers += Resolver.sonatypeRepo("snapshots"),
docMappingsApiDir := "api"
docMappingsApiDir := "api",
autoAPIMappings := true
)

lazy val allSettings = baseSettings ++ publishSettings
lazy val allSettings = baseSettings

lazy val root = project
.in(file("."))
.enablePlugins(GhpagesPlugin, ScalaUnidocPlugin)
.enablePlugins(GhpagesPlugin, ScalaUnidocPlugin, NoPublishPlugin)
.settings(allSettings)
.settings(
(ScalaUnidoc / unidoc / unidocProjectFilter) := inAnyProject -- inProjects(
Expand All @@ -51,8 +45,7 @@ lazy val root = project
`scalafix-tests`
),
addMappingsToSiteDir((ScalaUnidoc / packageDoc / mappings), docMappingsApiDir),
git.remoteRepo := "git@github.com:typelevel/catbird.git",
publish / skip := true
git.remoteRepo := "git@github.com:typelevel/catbird.git"
)
.settings(
(console / initialCommands) :=
Expand Down Expand Up @@ -118,10 +111,10 @@ lazy val finagle = project
.dependsOn(util)

lazy val benchmark = project
.enablePlugins(NoPublishPlugin)
.settings(allSettings)
.settings(
moduleName := "catbird-benchmark",
publish / skip := true,
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10",
scalacOptions ~= {
_.filterNot(Set("-Yno-imports", "-Yno-predef"))
Expand All @@ -130,50 +123,20 @@ lazy val benchmark = project
.enablePlugins(JmhPlugin)
.dependsOn(util)

lazy val publishSettings = Seq(
homepage := Some(url("https://github.com/typelevel/catbird")),
licenses := Seq("Apache 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
(Test / publishArtifact) := false,
pomIncludeRepository := { _ => false },
autoAPIMappings := true,
apiURL := Some(url("https://typelevel.org/catbird/api/")),
scmInfo := Some(
ScmInfo(
url("https://github.com/typelevel/catbird"),
"scm:git:git@github.com:typelevel/catbird.git"
)
),
developers += Developer("travisbrown", "Travis Brown", "", url("https://twitter.com/travisbrown"))
)
ThisBuild / apiURL := Some(url("https://typelevel.org/catbird/api/"))
ThisBuild / developers += Developer("travisbrown", "Travis Brown", "", url("https://twitter.com/travisbrown"))

ThisBuild / githubWorkflowJavaVersions := Seq("adopt@1.8")
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(
"clean",
"coverage",
"test",
"scalastyle",
"scalafmtCheck",
"scalafmtCheckAll",
"scalafmtSbtCheck",
"Test / scalafmtCheck",
"unidoc",
"coverageReport"
),
env = Map(
"SBT_OPTS" -> "-J-Xmx8G"
)
),
WorkflowStep.Use(
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.8
sbt.version=1.6.2
7 changes: 1 addition & 6 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
addSbtPlugin("com.github.sbt" % "sbt-unidoc" % "0.5.0")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.9")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.4.3")
bpholt marked this conversation as resolved.
Show resolved Hide resolved
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.1")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.4")
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.2")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3")
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.12.0")
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.31")