Skip to content

Commit

Permalink
Merge pull request #63 from armanbilge/topic/sbt-typelevel
Browse files Browse the repository at this point in the history
Migrate to sbt-typelevel-ci-release
  • Loading branch information
joroKr21 authored Jan 22, 2022
2 parents 705919c + 0df4974 commit aa13627
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 106 deletions.
75 changes: 55 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@ on:
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:
build:
name: Build and Test
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
scala: [3.1.0]
java: [temurin@8]
platform: [jvm, js, native]
project: [rootJS, rootJVM, rootNative]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
Expand Down Expand Up @@ -54,24 +57,41 @@ 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 'project ${{ matrix.project }}' '++${{ matrix.scala }}' 'project /' githubWorkflowCheck

- name: Validate JVM
if: matrix.platform == 'jvm'
run: sbt ++${{ matrix.scala }} validateJVM
- name: fastOptJS
if: matrix.project == 'rootJS'
run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' Test/fastOptJS

- name: Validate JS
if: matrix.platform == 'js'
run: sbt ++${{ matrix.scala }} validateJS
- name: nativeLink
if: matrix.project == 'rootNative'
run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' Test/nativeLink

- name: Validate Native
if: matrix.platform == 'native'
run: sbt ++${{ matrix.scala }} validateNative
- name: Test
run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' test

- name: Check binary compatibility
run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' mimaReportBinaryIssues

- name: Generate API documentation
run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' doc

- name: Make target directories
run: mkdir -p modules/deriving/.js/target modules/test/.jvm/target modules/test/.native/target target .js/target modules/typeable/.js/target modules/deriving/.jvm/target modules/typeable/.native/target .jvm/target .native/target local/.native/target local/.js/target modules/test/.js/target modules/typeable/.jvm/target local/.jvm/target modules/deriving/.native/target project/target

- name: Compress target directories
run: tar cf targets.tar modules/deriving/.js/target modules/test/.jvm/target modules/test/.native/target target .js/target modules/typeable/.js/target modules/deriving/.jvm/target modules/typeable/.native/target .jvm/target .native/target local/.native/target local/.js/target modules/test/.js/target modules/typeable/.jvm/target local/.jvm/target modules/deriving/.native/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' && (github.ref == 'refs/heads/main' || 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]
Expand Down Expand Up @@ -103,11 +123,26 @@ jobs:
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- uses: olafurpg/setup-gpg@v3
- name: Download target directories (3.1.0)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-3.1.0-${{ matrix.java }}

- name: Inflate target directories (3.1.0)
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)
- 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
- name: Publish
run: sbt '++${{ matrix.scala }}' tlRelease
104 changes: 22 additions & 82 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,23 @@ import com.typesafe.tools.mima.core.{ProblemFilters, ReversedMissingMethodProble
val scala3Version = "3.1.0"

ThisBuild / organization := "org.typelevel"
ThisBuild / tlBaseVersion := "3.1"
ThisBuild / scalaVersion := scala3Version
ThisBuild / crossScalaVersions := Seq(scala3Version)
ThisBuild / mimaFailOnNoPrevious := false
ThisBuild / updateOptions := updateOptions.value.withLatestSnapshots(false)

val previousVersion = "3.0.0"

// GHA configuration
ThisBuild / tlCiReleaseBranches := Seq("main")

ThisBuild / githubWorkflowJavaVersions := List(JavaSpec.temurin("8"))
ThisBuild / githubWorkflowArtifactUpload := false
ThisBuild / githubWorkflowBuildMatrixFailFast := Some(false)

val JvmCond = s"matrix.platform == 'jvm'"
val JsCond = s"matrix.platform == 'js'"
val NativeCond = s"matrix.platform == 'native'"

ThisBuild / githubWorkflowBuild := Seq(
WorkflowStep.Sbt(List("validateJVM"), name = Some("Validate JVM"), cond = Some(JvmCond)),
WorkflowStep.Sbt(List("validateJS"), name = Some("Validate JS"), cond = Some(JsCond)),
WorkflowStep.Sbt(List("validateNative"), name = Some("Validate Native"), cond = Some(NativeCond)),
)

ThisBuild / githubWorkflowTargetTags ++= Seq("v*")
ThisBuild / githubWorkflowPublishTargetBranches :=
Seq(RefPredicate.Equals(Ref.Branch("main")), RefPredicate.StartsWith(Ref.Tag("v")))

ThisBuild / githubWorkflowBuildMatrixAdditions +=
"platform" -> List("jvm", "js", "native")

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

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 }}"
)
)
val jsSettings = Def.settings(
tlVersionIntroduced := Map("3" -> "3.0.1")
)

val nativeSettings = Def.settings(
libraryDependencies += "org.scala-native" %%% "junit-runtime" % nativeVersion % Test,
addCompilerPlugin("org.scala-native" % "junit-plugin" % nativeVersion cross CrossVersion.full),
testOptions += Tests.Argument(TestFrameworks.JUnit, "-a", "-s", "-v"),
mimaPreviousArtifacts := Set.empty,
)

// Aliases
Expand All @@ -72,20 +40,11 @@ addCommandAlias("testNative", ";derivingNative/test;testNative/test;typeableNati

// Projects

lazy val root = project
.in(file("."))
.settings(commonSettings)
.settings(crossScalaVersions := Seq())
.settings(noPublishSettings)
lazy val root = tlCrossRootProject
.aggregate(
derivingJVM,
derivingJS,
derivingNative,
testJVM,
testJS,
testNative,
typeableJVM,
typeableJS
deriving,
test,
typeable
)

lazy val deriving = crossProject(JSPlatform, JVMPlatform, NativePlatform)
Expand All @@ -98,6 +57,7 @@ lazy val deriving = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.platformsSettings(JVMPlatform, JSPlatform)(
libraryDependencies += "org.typelevel" %%% "cats-core" % "2.7.0" % "test",
)
.jsSettings(jsSettings)
.nativeSettings(
nativeSettings,
Test / sources := {
Expand All @@ -114,16 +74,14 @@ lazy val deriving = crossProject(JSPlatform, JVMPlatform, NativePlatform)
},
)
.settings(commonSettings)
.settings(mimaSettings)
.settings(
mimaBinaryIssueFilters ++= Seq(
ProblemFilters.exclude[ReversedMissingMethodProblem]("shapeless3.deriving.internals.ErasedInstances.erasedMapK"),
ProblemFilters.exclude[ReversedMissingMethodProblem]("shapeless3.deriving.internals.ErasedProductInstances.erasedProject"),
ProblemFilters.exclude[ReversedMissingMethodProblem]("shapeless3.deriving.internals.ErasedProductInstances.erasedMapK")
)
)
.settings(publishSettings)
.jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin))
.jsEnablePlugins(ScalaJSJUnitPlugin)

lazy val derivingJVM = deriving.jvm
lazy val derivingJS = deriving.js
Expand All @@ -136,10 +94,9 @@ lazy val test = crossProject(JSPlatform, JVMPlatform, NativePlatform)
moduleName := "shapeless3-test"
)
.settings(commonSettings)
.settings(mimaSettings)
.settings(publishSettings)
.jsSettings(jsSettings)
.nativeSettings(nativeSettings)
.jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin))
.jsEnablePlugins(ScalaJSJUnitPlugin)

lazy val testJVM = test.jvm
lazy val testJS = test.js
Expand All @@ -153,10 +110,9 @@ lazy val typeable = crossProject(JSPlatform, JVMPlatform, NativePlatform)
moduleName := "shapeless3-typeable"
)
.settings(commonSettings)
//.settings(mimaSettings) // Not yet
.settings(publishSettings)
.settings(mimaPreviousArtifacts := Set.empty) // Not yet
.nativeSettings(nativeSettings)
.jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin))
.jsEnablePlugins(ScalaJSJUnitPlugin)

lazy val typeableJVM = typeable.jvm
lazy val typeableJS = typeable.js
Expand All @@ -174,14 +130,12 @@ lazy val local = crossProject(JSPlatform, JVMPlatform, NativePlatform)
console / initialCommands := """import shapeless3.deriving.* ; import scala.deriving.*"""
)
.settings(commonSettings)
.settings(noPublishSettings)
.jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin))
.enablePlugins(NoPublishPlugin)
.jsEnablePlugins(ScalaJSJUnitPlugin)

// Settings

lazy val commonSettings = Seq(
crossScalaVersions := (ThisBuild / crossScalaVersions).value,

scalacOptions ++= Seq(
"-Xfatal-warnings",
"-Yexplicit-nulls"
Expand All @@ -191,23 +145,9 @@ lazy val commonSettings = Seq(
libraryDependencies += "com.github.sbt" % "junit-interface" % "0.13.3" % "test",
)

lazy val mimaSettings = Seq(
mimaPreviousArtifacts := Set("org.typelevel" %% moduleName.value % previousVersion),
mimaBinaryIssueFilters := Seq()
)

lazy val publishSettings: Seq[Setting[_]] = Seq(
Test / publishArtifact := false,
pomIncludeRepository := (_ => false),
homepage := Some(url("https://github.com/typelevel/shapeless-3")),
licenses := Seq("Apache 2" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt")),
scmInfo := Some(ScmInfo(url("https://github.com/typelevel/shapeless-3"), "scm:git:[email protected]:typelevel/shapeless-3.git")),
developers := List(
Developer("milessabin", "Miles Sabin", "[email protected]", url("http://milessabin.com/blog")),
Developer("joroKr21", "Georgi Krastev", "[email protected]", url("https://twitter.com/Joro_Kr")),
Developer("TimWSpence", "Tim Spence", "[email protected]", url("https://twitter.com/timwspence"))
)
ThisBuild / licenses := Seq("Apache 2" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt"))
ThisBuild / developers := List(
Developer("milessabin", "Miles Sabin", "[email protected]", url("http://milessabin.com/blog")),
Developer("joroKr21", "Georgi Krastev", "[email protected]", url("https://twitter.com/Joro_Kr")),
Developer("TimWSpence", "Tim Spence", "[email protected]", url("https://twitter.com/timwspence"))
)

lazy val noPublishSettings =
publish / skip := true
6 changes: 2 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10")
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.14.2")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.0.1")
addSbtPlugin("org.typelevel" % "sbt-typelevel-ci-release" % "0.4.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.3")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.1.0")

0 comments on commit aa13627

Please sign in to comment.