diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e100c1c..9d36221 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: @@ -23,7 +29,13 @@ 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) @@ -31,12 +43,21 @@ jobs: 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 @@ -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 diff --git a/.scalafmt.conf b/.scalafmt.conf new file mode 100644 index 0000000..2ee8f30 --- /dev/null +++ b/.scalafmt.conf @@ -0,0 +1,3 @@ +version = "3.6.1" +runner.dialect = Scala213Source3 +project.includePaths = [] # disables formatting diff --git a/build.sbt b/build.sbt index a87a373..26f5945 100644 --- a/build.sbt +++ b/build.sbt @@ -16,43 +16,43 @@ 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, @@ -60,7 +60,7 @@ lazy val core = crossProject(JVMPlatform, JSPlatform, NativePlatform) "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") diff --git a/core/shared/src/main/scala-2/cats/effect/cps.scala b/core/shared/src/main/scala-2/cats/effect/cps.scala index e3a07a0..2065c14 100644 --- a/core/shared/src/main/scala-2/cats/effect/cps.scala +++ b/core/shared/src/main/scala-2/cats/effect/cps.scala @@ -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 { diff --git a/project/plugins.sbt b/project/plugins.sbt index 95832e4..e0c81f3 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -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")