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

Merged
merged 9 commits into from
Jan 20, 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
57 changes: 35 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ on:
tags: [v*]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
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:
build:
Expand All @@ -27,20 +28,20 @@ jobs:
matrix:
os: [ubuntu-latest]
scala: [3.0.2, 2.11.12, 2.12.15, 2.13.8]
java: [temurin@11]
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@11)
if: matrix.java == 'temurin@11'
- name: Setup Java (temurin@8)
if: matrix.java == 'temurin@8'
uses: actions/setup-java@v2
with:
distribution: temurin
java-version: 11
java-version: 8

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

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

- run: |
sbt ++${{ matrix.scala }} fmtCheck \
"++${{ matrix.scala }} test" \
"++${{ matrix.scala }} doc" \
"++${{ matrix.scala }} mimaReportBinaryIssues"

- name: Make target directories
run: mkdir -p target docs/target core/js/target core/jvm/target project/target

- name: Compress target directories
run: tar cf targets.tar target core/js/target core/jvm/target project/target
run: tar cf targets.tar target docs/target core/js/target core/jvm/target project/target

- name: Upload target directories
uses: actions/upload-artifact@v2
Expand All @@ -80,20 +84,20 @@ jobs:
matrix:
os: [ubuntu-latest]
scala: [2.13.8]
java: [temurin@11]
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@11)
if: matrix.java == 'temurin@11'
- name: Setup Java (temurin@8)
if: matrix.java == 'temurin@8'
uses: actions/setup-java@v2
with:
distribution: temurin
java-version: 11
java-version: 8

- name: Cache sbt
uses: actions/cache@v2
Expand Down Expand Up @@ -148,11 +152,20 @@ jobs:
rm targets.tar

- name: Import signing key
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == ''
run: echo $PGP_SECRET | base64 -d | gpg --import

- run: sbt ++${{ matrix.scala }} release
- 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 }} docs/makeSite
- run: sbt '++${{ matrix.scala }}' docs/makeSite

- uses: JamesIves/github-pages-deploy-action@3.7.1
with:
Expand All @@ -172,12 +185,12 @@ jobs:
- name: Checkout current branch (fast)
uses: actions/checkout@v2

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

- name: Cache sbt
uses: actions/cache@v2
Expand All @@ -191,7 +204,7 @@ jobs:
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- run: sbt ++${{ matrix.scala }} docs/mdoc
- run: sbt '++${{ matrix.scala }}' docs/mdoc

coverage:
name: Generate coverage report
Expand All @@ -205,12 +218,12 @@ jobs:
- name: Checkout current branch (fast)
uses: actions/checkout@v2

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

- name: Cache sbt
uses: actions/cache@v2
Expand All @@ -224,6 +237,6 @@ jobs:
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- run: sbt ++${{ matrix.scala }} coverage test coverageAggregate
- run: sbt '++${{ matrix.scala }}' coverage test coverageAggregate

- run: 'bash <(curl -s https://codecov.io/bash)'
53 changes: 17 additions & 36 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,14 @@ import Dependencies._
addCommandAlias("fmt", "; scalafmtAll; scalafmtSbt")
addCommandAlias("fmtCheck", "; scalafmtCheckAll; scalafmtSbtCheck")

addCommandAlias("prePR", "; githubWorkflowGenerate ; +fmt; bench/compile; +test")
tlReplaceCommandAlias("prePR", "; githubWorkflowGenerate ; +fmt; bench/compile; +test")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sbt-typelevel defines its own prePR so we replace the alias.


ThisBuild / baseVersion := "0.3"

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

ThisBuild / publishGithubUser := "johnynek"
ThisBuild / publishFullName := "P. Oscar Boykin"
ThisBuild / tlBaseVersion := "0.3"
ThisBuild / startYear := Some(2021)
ThisBuild / developers += tlGitHubDev("johnynek", "P. Oscar Boykin")

ThisBuild / crossScalaVersions := List("3.0.2", "2.11.12", "2.12.15", "2.13.8")

ThisBuild / spiewakCiReleaseSnapshots := true

ThisBuild / spiewakMainBranches := List("main")
ThisBuild / tlVersionIntroduced := Map("3" -> "0.3.4")

ThisBuild / githubWorkflowBuild := Seq(
WorkflowStep.Run(
Expand Down Expand Up @@ -66,19 +59,8 @@ ThisBuild / githubWorkflowPublish ++= Seq(
)
)

ThisBuild / homepage := Some(url("https://github.com/typelevel/cats-parse"))

ThisBuild / scmInfo := Some(
ScmInfo(
url("https://github.com/typelevel/cats-parse"),
"git@github.com:typelevel/cats-parse.git"
)
)
Comment on lines -69 to -76
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sbt-typelevel sets this automatically.


ThisBuild / licenses := List(("MIT", url("http://opensource.org/licenses/MIT")))

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

lazy val jvmVersionSettings = VersionNumber(sys.props("java.version")) match {
case v if v.matchesSemVer(SemanticSelector(">1.8")) =>
Def.settings(
Expand All @@ -96,7 +78,7 @@ lazy val jvmVersionSettings = VersionNumber(sys.props("java.version")) match {
lazy val root = project
.in(file("."))
.aggregate(core.jvm, core.js, bench)
.enablePlugins(NoPublishPlugin, SonatypeCiReleasePlugin)
.enablePlugins(NoPublishPlugin)
.settings(scalaVersion := "2.13.8")

lazy val docs = project
Expand All @@ -115,7 +97,6 @@ lazy val docs = project
"empty" -> "",
"version" -> version.value
),
githubWorkflowArtifactUpload := false,
git.remoteRepo := "git@github.com:typelevel/cats-parse.git",
mdocIn := (Compile / baseDirectory).value / "src",
Compile / paradox / sourceDirectory := mdocOut.value,
Expand All @@ -132,6 +113,7 @@ lazy val core = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Full)
.settings(
name := "cats-parse",
tlFatalWarningsInCi := !tlIsScala3.value,
libraryDependencies ++= {
val isScala211 = CrossVersion.partialVersion(scalaVersion.value).contains((2, 11))
Seq(
Expand All @@ -141,8 +123,7 @@ lazy val core = crossProject(JSPlatform, JVMPlatform)
)
},
libraryDependencies ++= {
val isScala2 = CrossVersion.partialVersion(scalaVersion.value).exists(_._1 == 2)
if (isScala2) Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value) else Nil
if (tlIsScala3.value) Nil else Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value)
},
scalacOptions ++= {
val isScala211 = CrossVersion.partialVersion(scalaVersion.value).contains((2, 11))
Expand All @@ -152,19 +133,19 @@ lazy val core = crossProject(JSPlatform, JVMPlatform)
mimaPreviousArtifacts := {
val isScala211 = CrossVersion.partialVersion(scalaVersion.value).contains((2, 11))
if (isScala211) Set.empty else mimaPreviousArtifacts.value
},
mimaBinaryIssueFilters ++= {
if (tlIsScala3.value)
List(
ProblemFilters.exclude[IncompatibleResultTypeProblem]("cats.parse.Parser#State.error"),
ProblemFilters.exclude[IncompatibleMethTypeProblem]("cats.parse.Parser#State.error_=")
)
else Nil
}
)
.jsSettings(
crossScalaVersions := (ThisBuild / crossScalaVersions).value.filterNot(_.startsWith("2.11")),
Global / scalaJSStage := FastOptStage,
parallelExecution := false,
jsEnv := new org.scalajs.jsenv.nodejs.NodeJSEnv(),
// batch mode decreases the amount of memory needed to compile scala.js code
scalaJSLinkerConfig := scalaJSLinkerConfig.value
.withBatchMode(scala.sys.env.get("TRAVIS").isDefined)
.withModuleKind(ModuleKind.CommonJSModule),
coverageEnabled := false,
scalaJSUseMainModuleInitializer := false
Comment on lines -159 to -167
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure these are all redundant.

coverageEnabled := false
)

lazy val coreJVM = core.jvm.settings(jvmVersionSettings)
Expand Down
4 changes: 1 addition & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3")
addSbtPlugin("com.codecommit" % "sbt-spiewak-sonatype" % "0.23.0")
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.14.2")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.4.0")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.24")
addSbtPlugin("io.github.jonas" % "sbt-paradox-material-theme" % "0.6.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1")
Expand Down