Skip to content

Commit

Permalink
Merge pull request #98 from armanbilge/topic/sbt-typelevel
Browse files Browse the repository at this point in the history
Adopt sbt-typelevel
  • Loading branch information
Baccata authored Nov 17, 2022
2 parents 47824b0 + 63f10d7 commit 5a4250b
Show file tree
Hide file tree
Showing 5 changed files with 218 additions and 30 deletions.
203 changes: 194 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ name: Continuous Integration

on:
pull_request:
branches: ['**']
branches: ['**', '!update/**', '!pr/**']
push:
branches: ['**']
branches: ['**', '!update/**', '!pr/**']
tags: [v*]

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

jobs:
Expand All @@ -23,20 +29,35 @@ jobs:
matrix:
os: [ubuntu-latest]
scala: [2.12.17, 2.13.10, 3.2.1]
java: [temurin@11]
java: [temurin@8]
project: [rootJS, rootJVM, rootNative]
exclude:
- scala: 2.12.17
project: rootNative
- scala: 2.13.10
project: rootNative
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'
uses: actions/setup-java@v2
- name: Download Java (temurin@8)
id: download-java-temurin-8
if: matrix.java == 'temurin@8'
uses: typelevel/download-java@v1
with:
distribution: temurin
java-version: 11
java-version: 8

- name: Setup Java (temurin@8)
if: matrix.java == 'temurin@8'
uses: actions/setup-java@v2
with:
distribution: jdkfile
java-version: 8
jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }}

- name: Cache sbt
uses: actions/cache@v2
Expand All @@ -51,6 +72,170 @@ 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 githubWorkflowCheck

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

- name: scalaJSLink
if: matrix.project == 'rootJS'
run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' Test/scalaJSLinkerResult

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

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

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

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

- 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 .js/target core/native/target core/js/target core/jvm/target .jvm/target .native/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 .js/target core/native/target core/js/target core/jvm/target .jvm/target .native/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 }}-${{ matrix.project }}
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: [3.2.1]
java: [temurin@8]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Download Java (temurin@8)
id: download-java-temurin-8
if: matrix.java == 'temurin@8'
uses: typelevel/download-java@v1
with:
distribution: temurin
java-version: 8

- name: Setup Java (temurin@8)
if: matrix.java == 'temurin@8'
uses: actions/setup-java@v2
with:
distribution: jdkfile
java-version: 8
jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }}

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

- name: Inflate target directories (2.12.17, rootJS)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (2.12.17, rootJVM)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.17-rootJVM

- name: Inflate target directories (2.12.17, rootJVM)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (2.13.10, rootJS)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.10-rootJS

- name: Inflate target directories (2.13.10, rootJS)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (2.13.10, rootJVM)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.10-rootJVM

- name: Inflate target directories (2.13.10, rootJVM)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (3.2.1, rootJS)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-3.2.1-rootJS

- name: Inflate target directories (3.2.1, rootJS)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (3.2.1, rootJVM)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-3.2.1-rootJVM

- name: Inflate target directories (3.2.1, rootJVM)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (3.2.1, rootNative)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-3.2.1-rootNative

- name: Inflate target directories (3.2.1, rootNative)
run: |
tar xf targets.tar
rm targets.tar
- name: Import signing key
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == ''
run: echo $PGP_SECRET | base64 -di | gpg --import

- name: Import signing key and strip passphrase
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE != ''
run: |
echo "$PGP_SECRET" | base64 -di > /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 }} ci
- name: Publish
run: sbt '++ ${{ matrix.scala }}' tlRelease
3 changes: 3 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version = "3.6.1"
runner.dialect = Scala213Source3
project.includePaths = [] # disables formatting
34 changes: 17 additions & 17 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -16,51 +16,51 @@

name := "cats-effect-cps"

ThisBuild / baseVersion := "0.4"

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

ThisBuild / startYear := Some(2021)
ThisBuild / endYear := Some(2022)

ThisBuild / homepage := Some(url("https://github.com/typelevel/cats-effect-cps"))
ThisBuild / scmInfo := Some(
ScmInfo(
url("https://github.com/typelevel/cats-effect-cps"),
"scm:git@github.com:typelevel/cats-effect-cps.git"))

ThisBuild / developers := List(
Developer("djspiewak", "Daniel Spiewak", "@djspiewak", url("https://github.com/djspiewak")),
Developer("baccata", "Olivier Melois", "@baccata", url("https://github.com/baccata")))
tlGitHubDev("djspiewak", "Daniel Spiewak"),
tlGitHubDev("baccata", "Olivier Melois"))

ThisBuild / crossScalaVersions := Seq("2.12.17", "2.13.10", "3.2.1")

ThisBuild / githubWorkflowBuildMatrixExclusions ++= {
crossScalaVersions.value.filter(_.startsWith("2.")).map { scala =>
MatrixExclude(Map("scala" -> scala, "project" -> "rootNative"))
}
}

val CatsEffectVersion = "3.4.1"

lazy val root = project.in(file(".")).aggregate(core.jvm, core.js, core.native).enablePlugins(NoPublishPlugin)
lazy val root = tlCrossRootProject.aggregate(core)

lazy val core = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.in(file("core"))
.settings(
name := "cats-effect-cps",
headerEndYear := Some(2022),

scalacOptions ++= {
if (isDotty.value)
if (tlIsScala3.value)
Seq()
else
Seq("-Xasync")
},

resolvers ++= Resolver.sonatypeOssRepos("snapshots"),
tlFatalWarnings := {
tlFatalWarnings.value && !tlIsScala3.value
},

libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-effect-std" % CatsEffectVersion,

"org.typelevel" %%% "cats-effect" % CatsEffectVersion % Test,
"org.typelevel" %%% "cats-effect-testing-specs2" % "1.5.0" % Test),

libraryDependencies ++= {
if (isDotty.value)
if (tlIsScala3.value)
Seq("com.github.rssh" %%% "dotty-cps-async" % "0.9.11")
else
Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided")
Expand Down
2 changes: 1 addition & 1 deletion core/shared/src/main/scala-2/cats/effect/cps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import cats.effect.cpsinternal.AsyncAwaitDsl
* }}}
*
* The code is transformed at compile time into a state machine
* that sequentially calls upon a [[Dispatcher]] every time it reaches
* that sequentially calls upon a [[cats.effect.std.Dispatcher]] every time it reaches
* an "await" block.
*/
object cps {
Expand Down
6 changes: 3 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
addSbtPlugin("com.codecommit" % "sbt-spiewak-sonatype" % "0.23.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.11.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")
addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.4.17")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.11.0")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.7")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.9.0")

0 comments on commit 5a4250b

Please sign in to comment.