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

Merged
merged 1 commit into from
Jan 8, 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
25 changes: 20 additions & 5 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 @@ -28,11 +29,16 @@ jobs:
os: [ubuntu-latest]
scala: [2.12.15, 3.1.0, 2.13.7]
java: [temurin@8, temurin@11]
ci: [ciJS, ciJVM]
exclude:
- scala: 2.12.15
java: temurin@11
- scala: 3.1.0
java: temurin@11
- ci: ciJS
java: temurin@11
- ci: ciJS
scala: 2.12.15
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
Expand Down Expand Up @@ -67,6 +73,7 @@ jobs:
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Setup NodeJS v14 LTS
if: matrix.ci == 'ciJS'
uses: actions/setup-node@v2
with:
node-version: 14
Expand All @@ -75,17 +82,17 @@ jobs:
run: sbt ++${{ matrix.scala }} githubWorkflowCheck

- if: matrix.scala != '2.12.15'
run: sbt ++${{ matrix.scala }} ci
run: sbt ++${{ matrix.scala }} '${{ matrix.ci }}'

- name: Run sbt scripted tests
if: matrix.scala == '2.12.15'
run: sbt ++${{ matrix.scala }} scripted

- name: Make target directories
run: mkdir -p target lambda-cloudformation-custom-resource/.js/target lambda-http4s/.jvm/target core/.js/target examples/.js/target lambda-http4s/.js/target core/.jvm/target lambda/js/target examples/.jvm/target lambda/jvm/target sbt-lambda/target lambda-cloudformation-custom-resource/.jvm/target project/target
run: mkdir -p target lambda-cloudformation-custom-resource/.js/target lambda-http4s/.jvm/target .js/target core/.js/target examples/.js/target lambda-http4s/.js/target core/.jvm/target .jvm/target lambda/js/target .native/target examples/.jvm/target lambda/jvm/target sbt-lambda/target lambda-cloudformation-custom-resource/.jvm/target project/target

- name: Compress target directories
run: tar cf targets.tar target lambda-cloudformation-custom-resource/.js/target lambda-http4s/.jvm/target core/.js/target examples/.js/target lambda-http4s/.js/target core/.jvm/target lambda/js/target examples/.jvm/target lambda/jvm/target sbt-lambda/target lambda-cloudformation-custom-resource/.jvm/target project/target
run: tar cf targets.tar target lambda-cloudformation-custom-resource/.js/target lambda-http4s/.jvm/target .js/target core/.js/target examples/.js/target lambda-http4s/.js/target core/.jvm/target .jvm/target lambda/js/target .native/target examples/.jvm/target lambda/jvm/target sbt-lambda/target lambda-cloudformation-custom-resource/.jvm/target project/target

- name: Upload target directories
uses: actions/upload-artifact@v2
Expand Down Expand Up @@ -166,6 +173,14 @@ jobs:
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)

- run: sbt ++${{ matrix.scala }} release
82 changes: 21 additions & 61 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,21 @@

name := "feral"

ThisBuild / baseVersion := "0.1"

ThisBuild / organization := "org.typelevel"
ThisBuild / organizationName := "Typelevel"
ThisBuild / tlBaseVersion := "0.1"
ThisBuild / startYear := Some(2021)

ThisBuild / developers := List(
Developer("armanbilge", "Arman Bilge", "@armanbilge", url("https://github.com/armanbilge")),
Developer("bpholt", "Brian Holt", "@bpholt", url("https://github.com/bpholt")),
Developer("djspiewak", "Daniel Spiewak", "@djspiewak", url("https://github.com/djspiewak"))
tlGitHubDev("armanbilge", "Arman Bilge"),
tlGitHubDev("bpholt", "Brian Holt"),
tlGitHubDev("djspiewak", "Daniel Spiewak")
)

enablePlugins(SonatypeCiReleasePlugin)
ThisBuild / spiewakCiReleaseSnapshots := true
ThisBuild / spiewakMainBranches := Seq("main")
ThisBuild / homepage := Some(url("https://github.com/typelevel/feral"))
ThisBuild / scmInfo := Some(
ScmInfo(url("https://github.com/typelevel/feral"), "git@github.com:typelevel/feral.git"))
enablePlugins(TypelevelCiReleasePlugin)
ThisBuild / tlCiReleaseBranches := Seq("main")

ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("8"), JavaSpec.temurin("11"))
ThisBuild / githubWorkflowBuildMatrixExclusions ++= {
for {
scala <- (ThisBuild / crossScalaVersions).value.init
java <- (ThisBuild / githubWorkflowJavaVersions).value.tail
} yield MatrixExclude(Map("scala" -> scala, "java" -> java.render))
}

ThisBuild / githubWorkflowGeneratedUploadSteps ~= { steps =>
val mkdirStep = steps.headOption match {
case Some(WorkflowStep.Run(command :: _, _, _, _, _, _)) =>
WorkflowStep.Run(
commands = List(command.replace("tar cf targets.tar", "mkdir -p")),
name = Some("Make target directories")
)
case _ => sys.error("Can't generate make target dirs workflow step")
}
mkdirStep +: steps
}
ThisBuild / githubWorkflowBuildMatrixExclusions +=
MatrixExclude(Map("ci" -> "ciJS", "scala" -> Scala212))

ThisBuild / githubWorkflowBuild ~= { steps =>
val ciStep = steps.headOption match {
Expand All @@ -68,16 +46,12 @@ ThisBuild / githubWorkflowBuild ~= { steps =>
List(ciStep, scriptedStep)
}

replaceCommandAlias(
"ci",
"; project /; headerCheckAll; scalafmtCheckAll; scalafmtSbtCheck; clean; testIfRelevant; mimaReportBinaryIssuesIfRelevant"
)

ThisBuild / githubWorkflowBuildPreamble +=
WorkflowStep.Use(
UseRef.Public("actions", "setup-node", "v2"),
name = Some("Setup NodeJS v14 LTS"),
params = Map("node-version" -> "14")
params = Map("node-version" -> "14"),
cond = Some("matrix.ci == 'ciJS'")
)

val Scala212 = "2.12.15"
Expand All @@ -94,32 +68,18 @@ val munitVersion = "0.7.29"
val munitCEVersion = "1.0.7"

lazy val commonSettings = Seq(
crossScalaVersions := Seq(Scala3, Scala213),
scalacOptions ++= {
if (isDotty.value && githubIsWorkflowBuild.value)
Seq("-Xfatal-warnings")
else
Seq.empty
}
crossScalaVersions := Seq(Scala3, Scala213)
)

lazy val root =
project
.in(file("."))
.aggregate(
core.js,
core.jvm,
lambda.js,
lambda.jvm,
sbtLambda,
lambdaHttp4s.js,
lambdaHttp4s.jvm,
lambdaCloudFormationCustomResource.js,
lambdaCloudFormationCustomResource.jvm,
examples.js,
examples.jvm
)
.enablePlugins(NoPublishPlugin)
tlCrossRootProject.aggregate(
core,
lambda,
sbtLambda,
lambdaHttp4s,
lambdaCloudFormationCustomResource,
examples
)
Comment on lines -107 to +82
Copy link
Member Author

Choose a reason for hiding this comment

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

Not only does this cut down the boilerplate, it also gets CI split into JVM and JS jobs for free.


lazy val core = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
Expand All @@ -144,7 +104,7 @@ lazy val lambda = crossProject(JSPlatform, JVMPlatform)
"org.typelevel" %%% "munit-cats-effect-3" % "1.0.7" % Test
),
libraryDependencies ++= {
if (isDotty.value) Nil
if (tlIsScala3.value) Nil
else
Seq(
"io.circe" %%% "circe-literal" % circeVersion % Test,
Expand Down
6 changes: 2 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.14.2")
addSbtPlugin("com.codecommit" % "sbt-spiewak-sonatype" % "0.23.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0")
resolvers += Resolver.sonatypeRepo("snapshots")
addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.4-690c2d9-SNAPSHOT")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")