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 #395

Merged
merged 4 commits into from
Feb 6, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
130 changes: 123 additions & 7 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: [3.1.1, 2.12.14, 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@v13
- 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 @@ -57,10 +64,119 @@ jobs:
run: gem install jekyll -v 4.0.0

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

- run: sbt ++${{ matrix.scala }} ci
- name: Check headers and formatting
if: matrix.java == 'temurin@8'
run: sbt '++${{ matrix.scala }}' headerCheckAll scalafmtCheckAll 'project /' scalafmtSbtCheck

- name: Test
run: sbt '++${{ matrix.scala }}' test

- name: Check binary compatibility
if: matrix.java == 'temurin@8'
run: sbt '++${{ matrix.scala }}' mimaReportBinaryIssues

- name: Generate API documentation
if: matrix.java == 'temurin@8'
run: sbt '++${{ matrix.scala }}' doc

- name: Make microsite
if: matrix.scala == '2.13.6'
run: sbt ++${{ matrix.scala }} makeMicrosite
run: sbt '++${{ matrix.scala }}' makeMicrosite

- name: Make target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: mkdir -p target docs/target core/.js/target laws/.js/target core/.jvm/target tests/.js/target laws/.jvm/target tests/.jvm/target project/target

- name: Compress target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: tar cf targets.tar target docs/target core/.js/target laws/.js/target core/.jvm/target tests/.js/target laws/.jvm/target tests/.jvm/target project/target

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

publish:
name: Publish Artifacts
needs: [build]
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]
java: [temurin@8]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Java (temurin@8)
if: matrix.java == 'temurin@8'
uses: actions/setup-java@v2
with:
distribution: temurin
java-version: 8

- 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 (3.1.1)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.1

- name: Inflate target directories (3.1.1)
run: |
tar xf targets.tar
rm targets.tar

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

- name: Inflate target directories (2.12.14)
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 }}-${{ matrix.java }}-2.13.6

- name: Inflate target directories (2.13.6)
run: |
tar xf targets.tar
rm targets.tar

- 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

- run: sbt '++${{ matrix.scala }}' publishMicrosite
54 changes: 16 additions & 38 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
import microsites._
import sbtcrossproject.{crossProject, CrossType}

replaceCommandAlias(
"ci",
"; project /; headerCheck; scalafmtCheckAll; clean; testIfRelevant; mimaReportBinaryIssues")
replaceCommandAlias(
"release",
"; reload; project /; +mimaReportBinaryIssues; +publishIfRelevant; sonatypeBundleRelease; publishMicrosite")

ThisBuild / organization := "org.typelevel"
ThisBuild / organizationName := "Typelevel"

ThisBuild / baseVersion := "1.2"

ThisBuild / tlBaseVersion := "1.2"
ThisBuild / startYear := Some(2021)
ThisBuild / homepage := Some(url("https://typelevel.org/cats-mtl/"))
ThisBuild / developers := List(
Developer("SystemFw", "Fabio Labella", "", url("https://github.com/SystemFw/")),
Developer("andyscott", "Andy Scott", "", url("https://github.com/andyscott/")),
Developer("kailuowang", "Kailuo Wang", "", url("https://github.com/kailuowang/")),
Developer("djspiewak", "Daniel Spiewak", "", url("https://github.com/djspiewak/")),
Developer("LukaJCB", "Luka Jacobowitz", "", url("https://github.com/LukaJCB/")),
Developer("edmundnoble", "Edmund Noble", "", url("https://github.com/edmundnoble/"))
tlGitHubDev("SystemFw", "Fabio Labella"),
tlGitHubDev("andyscott", "Andy Scott"),
tlGitHubDev("kailuowang", "Kailuo Wang"),
tlGitHubDev("djspiewak", "Daniel Spiewak"),
tlGitHubDev("LukaJCB", "Luka Jacobowitz"),
tlGitHubDev("edmundnoble", "Edmund Noble")
)

val Scala213 = "2.13.6"

ThisBuild / scalaVersion := crossScalaVersions.value.last
ThisBuild / crossScalaVersions := Seq("3.1.1", "2.12.14", Scala213)
ThisBuild / tlVersionIntroduced := Map("3" -> "1.2.1")

ThisBuild / githubWorkflowBuildPreamble ++= Seq(
WorkflowStep.Use(
Expand All @@ -35,25 +25,19 @@ ThisBuild / githubWorkflowBuildPreamble ++= Seq(
WorkflowStep.Run(List("gem install jekyll -v 4.0.0"), name = Some("Install Jekyll"))
)

ThisBuild / githubWorkflowBuild := Seq(
WorkflowStep.Sbt(List("ci")),
ThisBuild / githubWorkflowBuild +=
WorkflowStep.Sbt(
List("makeMicrosite"),
name = Some("Make microsite"),
cond = Some(s"matrix.scala == '$Scala213'")))
cond = Some(s"matrix.scala == '$Scala213'"))

ThisBuild / githubWorkflowPublishTargetBranches := Seq()
ThisBuild / githubWorkflowPublishPostamble += WorkflowStep.Sbt(List("publishMicrosite"))

ThisBuild / testFrameworks += new TestFramework("munit.Framework")

lazy val commonJvmSettings = Seq(
Test / testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-oDF"),
mimaPreviousArtifacts := {
if (isDotty.value)
Set()
else
mimaPreviousArtifacts.value
})
Test / testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-oDF")
)

lazy val commonJsSettings = Seq(
doctestGenTests := Seq.empty
Expand All @@ -72,12 +56,6 @@ lazy val core = crossProject(JSPlatform, JVMPlatform)
.settings(name := "cats-mtl")
.settings(
libraryDependencies += "org.typelevel" %%% "cats-core" % CatsVersion,
Compile / unmanagedSourceDirectories ++= {
val major = if (isDotty.value) "-3" else "-2"
List(CrossType.Pure, CrossType.Full).flatMap(
_.sharedSrcDir(baseDirectory.value, "main").toList.map(f => file(f.getPath + major))
)
},
Compile / packageSrc / mappings ++= {
val base = (Compile / sourceManaged).value
(Compile / managedSources).value.map(file => file -> file.relativeTo(base).get.getPath)
Expand Down Expand Up @@ -136,7 +114,7 @@ lazy val docs = project
addMappingsToSiteDir(ScalaUnidoc / packageDoc / mappings, docsMappingsAPIDir),
scalacOptions := scalacOptions.value.filterNot(_ == "-Werror"),
ghpagesNoJekyll := false,
fatalWarningsInCI := false,
tlFatalWarningsInCi := false,
ScalaUnidoc / unidoc / scalacOptions ++= Seq(
"-Xfatal-warnings",
"-doc-source-url",
Expand Down
18 changes: 0 additions & 18 deletions project/Settings.scala

This file was deleted.

4 changes: 1 addition & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0")
addSbtPlugin("com.github.tkawachi" % "sbt-doctest" % "0.9.9")
addSbtPlugin("com.47deg" % "sbt-microsites" % "1.3.4")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0")
addSbtPlugin("com.codecommit" % "sbt-spiewak-sonatype" % "0.22.0")
addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.4.3")