diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3129bdc1f..1873a179e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,14 +8,14 @@ env: workflow_dispatch: {} release: types: - - published - push: - branches: - - master - - series/0.x + - published pull_request: branches-ignore: - - gh-pages + - gh-pages + push: + branches: + - master + - series/0.x concurrency: group: ${{ github.workflow }}-${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.run_id || github.ref }} cancel-in-progress: true @@ -25,234 +25,239 @@ jobs: runs-on: ubuntu-latest continue-on-error: true steps: - - name: Git Checkout - uses: actions/checkout@v4 - with: - fetch-depth: '0' - - name: Install libuv - run: sudo apt-get update && sudo apt-get install -y libuv1-dev - - name: Setup Scala - uses: actions/setup-java@v4 - with: - distribution: corretto - java-version: '17' - check-latest: true - - name: Cache Dependencies - uses: coursier/cache-action@v6 - - name: Check all code compiles - run: sbt +Test/compile - - name: Check artifacts build process - run: sbt +publishLocal - - name: Check website build process - run: sbt docs/clean; sbt docs/buildWebsite + - name: Git Checkout + uses: actions/checkout@v4 + with: + fetch-depth: '0' + - name: Install libuv + run: sudo apt-get update && sudo apt-get install -y libuv1-dev + - name: Setup Scala + uses: actions/setup-java@v4 + with: + distribution: corretto + java-version: '17' + check-latest: true + - name: Cache Dependencies + uses: coursier/cache-action@v6 + - name: Check all code compiles + run: sbt +Test/compile + - name: Check artifacts build process + run: sbt +publishLocal + - name: Check website build process + run: sbt docs/clean; sbt docs/buildWebsite lint: name: Lint runs-on: ubuntu-latest continue-on-error: false steps: - - name: Git Checkout - uses: actions/checkout@v4 - with: - fetch-depth: '0' - - name: Install libuv - run: sudo apt-get update && sudo apt-get install -y libuv1-dev - - name: Setup Scala - uses: actions/setup-java@v4 - with: - distribution: corretto - java-version: '17' - check-latest: true - - name: Cache Dependencies - uses: coursier/cache-action@v6 - - name: Check if the site workflow is up to date - run: sbt ciCheckGithubWorkflow - - name: Lint - run: sbt lint + - name: Git Checkout + uses: actions/checkout@v4 + with: + fetch-depth: '0' + - name: Install libuv + run: sudo apt-get update && sudo apt-get install -y libuv1-dev + - name: Setup Scala + uses: actions/setup-java@v4 + with: + distribution: corretto + java-version: '17' + check-latest: true + - name: Cache Dependencies + uses: coursier/cache-action@v6 + - name: Check if the site workflow is up to date + run: sbt ciCheckGithubWorkflow + - name: Lint + run: sbt lint test: name: Test runs-on: ubuntu-latest continue-on-error: false strategy: - fail-fast: false matrix: java: - - '11' - - '17' - - '21' + - '11' + - '17' + - '21' + scalaVersion: + - 2.13.15 + - 3.3.4 + fail-fast: false steps: - - name: Install libuv - run: sudo apt-get update && sudo apt-get install -y libuv1-dev - - name: Setup Scala - uses: actions/setup-java@v4 - with: - distribution: corretto - java-version: ${{ matrix.java }} - check-latest: true - - name: Cache Dependencies - uses: coursier/cache-action@v6 - - name: Git Checkout - uses: actions/checkout@v4 - with: - fetch-depth: '0' - - name: Test - run: sbt +test + - name: Install libuv + run: sudo apt-get update && sudo apt-get install -y libuv1-dev + - name: Setup Scala + uses: actions/setup-java@v4 + with: + distribution: corretto + java-version: ${{ matrix.java }} + check-latest: true + - name: Cache Dependencies + uses: coursier/cache-action@v6 + - name: Git Checkout + uses: actions/checkout@v4 + with: + fetch-depth: '0' + - name: Test + run: sbt +test${{ startsWith(matrix.scalaVersion, '2.12') && '2_12' || (startsWith(matrix.scalaVersion, '2.13') && '2_13' || (startsWith(matrix.scalaVersion, '3') && '3' || '')) }} update-readme: name: Update README runs-on: ubuntu-latest continue-on-error: false if: ${{ github.event_name == 'push' }} steps: - - name: Git Checkout - uses: actions/checkout@v4 - with: - fetch-depth: '0' - - name: Install libuv - run: sudo apt-get update && sudo apt-get install -y libuv1-dev - - name: Setup Scala - uses: actions/setup-java@v4 - with: - distribution: corretto - java-version: '17' - check-latest: true - - name: Cache Dependencies - uses: coursier/cache-action@v6 - - name: Generate Readme - run: sbt docs/generateReadme - - name: Commit Changes - run: | - git config --local user.email "zio-assistant[bot]@users.noreply.github.com" - git config --local user.name "ZIO Assistant" - git add README.md - git commit -m "Update README.md" || echo "No changes to commit" - - name: Generate Token - id: generate-token - uses: zio/generate-github-app-token@v1.0.0 - with: - app_id: ${{ secrets.APP_ID }} - app_private_key: ${{ secrets.APP_PRIVATE_KEY }} - - name: Create Pull Request - id: cpr - uses: peter-evans/create-pull-request@v6 - with: - body: |- - Autogenerated changes after running the `sbt docs/generateReadme` command of the [zio-sbt-website](https://zio.dev/zio-sbt) plugin. + - name: Git Checkout + uses: actions/checkout@v4 + with: + fetch-depth: '0' + - name: Install libuv + run: sudo apt-get update && sudo apt-get install -y libuv1-dev + - name: Setup Scala + uses: actions/setup-java@v4 + with: + distribution: corretto + java-version: '17' + check-latest: true + - name: Cache Dependencies + uses: coursier/cache-action@v6 + - name: Generate Readme + run: sbt docs/generateReadme + - name: Commit Changes + run: | + git config --local user.email "zio-assistant[bot]@users.noreply.github.com" + git config --local user.name "ZIO Assistant" + git add README.md + git commit -m "Update README.md" || echo "No changes to commit" + - name: Generate Token + id: generate-token + uses: zio/generate-github-app-token@v1.0.0 + with: + app_id: ${{ secrets.APP_ID }} + app_private_key: ${{ secrets.APP_PRIVATE_KEY }} + - name: Create Pull Request + id: cpr + uses: peter-evans/create-pull-request@v6 + with: + body: |- + Autogenerated changes after running the `sbt docs/generateReadme` command of the [zio-sbt-website](https://zio.dev/zio-sbt) plugin. - I will automatically update the README.md file whenever there is new change for README.md, e.g. - - After each release, I will update the version in the installation section. - - After any changes to the "docs/index.md" file, I will update the README.md file accordingly. - branch: zio-sbt-website/update-readme - commit-message: Update README.md - token: ${{ steps.generate-token.outputs.token }} - delete-branch: true - title: Update README.md - - name: Approve PR - if: ${{ steps.cpr.outputs.pull-request-number }} - run: gh pr review "$PR_URL" --approve - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_URL: ${{ steps.cpr.outputs.pull-request-url }} - - name: Enable Auto-Merge - if: ${{ steps.cpr.outputs.pull-request-number }} - run: gh pr merge --auto --squash "$PR_URL" || gh pr merge --squash "$PR_URL" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_URL: ${{ steps.cpr.outputs.pull-request-url }} + I will automatically update the README.md file whenever there is new change for README.md, e.g. + - After each release, I will update the version in the installation section. + - After any changes to the "docs/index.md" file, I will update the README.md file accordingly. + branch: zio-sbt-website/update-readme + commit-message: Update README.md + token: ${{ steps.generate-token.outputs.token }} + delete-branch: true + title: Update README.md + - name: Approve PR + if: ${{ steps.cpr.outputs.pull-request-number }} + run: gh pr review "$PR_URL" --approve + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_URL: ${{ steps.cpr.outputs.pull-request-url }} + - name: Enable Auto-Merge + if: ${{ steps.cpr.outputs.pull-request-number }} + run: gh pr merge --auto --squash "$PR_URL" || gh pr merge --squash "$PR_URL" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_URL: ${{ steps.cpr.outputs.pull-request-url }} ci: name: ci runs-on: ubuntu-latest continue-on-error: false needs: - - lint - - test - - build + - lint + - test + - build steps: - - name: Report Successful CI - run: echo "ci passed" + - name: Report Successful CI + run: echo "ci passed" release: name: Release runs-on: ubuntu-latest continue-on-error: false needs: - - ci + - ci if: ${{ github.event_name != 'pull_request' }} steps: - - name: Git Checkout - uses: actions/checkout@v4 - with: - fetch-depth: '0' - - name: Install libuv - run: sudo apt-get update && sudo apt-get install -y libuv1-dev - - name: Setup Scala - uses: actions/setup-java@v4 - with: - distribution: corretto - java-version: '17' - check-latest: true - - name: Cache Dependencies - uses: coursier/cache-action@v6 - - name: Release - run: sbt ci-release - env: - PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} - PGP_SECRET: ${{ secrets.PGP_SECRET }} - SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + - name: Git Checkout + uses: actions/checkout@v4 + with: + fetch-depth: '0' + - name: Install libuv + run: sudo apt-get update && sudo apt-get install -y libuv1-dev + - name: Setup Scala + uses: actions/setup-java@v4 + with: + distribution: corretto + java-version: '17' + check-latest: true + - name: Cache Dependencies + uses: coursier/cache-action@v6 + - name: Release + run: sbt ci-release + env: + PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} + PGP_SECRET: ${{ secrets.PGP_SECRET }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + CI_RELEASE: +publishSigned + CI_SNAPSHOT_RELEASE: +publish release-docs: name: Release Docs runs-on: ubuntu-latest continue-on-error: false needs: - - release + - release if: ${{ ((github.event_name == 'release') && (github.event.action == 'published')) || (github.event_name == 'workflow_dispatch') }} steps: - - name: Git Checkout - uses: actions/checkout@v4 - with: - fetch-depth: '0' - - name: Install libuv - run: sudo apt-get update && sudo apt-get install -y libuv1-dev - - name: Setup Scala - uses: actions/setup-java@v4 - with: - distribution: corretto - java-version: '17' - check-latest: true - - name: Cache Dependencies - uses: coursier/cache-action@v6 - - name: Setup NodeJs - uses: actions/setup-node@v4 - with: - node-version: 16.x - registry-url: https://registry.npmjs.org - - name: Publish Docs to NPM Registry - run: sbt docs/publishToNpm - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Git Checkout + uses: actions/checkout@v4 + with: + fetch-depth: '0' + - name: Install libuv + run: sudo apt-get update && sudo apt-get install -y libuv1-dev + - name: Setup Scala + uses: actions/setup-java@v4 + with: + distribution: corretto + java-version: '17' + check-latest: true + - name: Cache Dependencies + uses: coursier/cache-action@v6 + - name: Setup NodeJs + uses: actions/setup-node@v4 + with: + node-version: 16.x + registry-url: https://registry.npmjs.org + - name: Publish Docs to NPM Registry + run: sbt docs/publishToNpm + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} notify-docs-release: name: Notify Docs Release runs-on: ubuntu-latest continue-on-error: false needs: - - release-docs + - release-docs if: ${{ (github.event_name == 'release') && (github.event.action == 'published') }} steps: - - name: Git Checkout - uses: actions/checkout@v4 - with: - fetch-depth: '0' - - name: notify the main repo about the new release of docs package - run: | - PACKAGE_NAME=$(cat docs/package.json | grep '"name"' | awk -F'"' '{print $4}') - PACKAGE_VERSION=$(npm view $PACKAGE_NAME version) - curl -L \ - -X POST \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: token ${{ secrets.PAT_TOKEN }}"\ - https://api.github.com/repos/zio/zio/dispatches \ - -d '{ - "event_type":"update-docs", - "client_payload":{ - "package_name":"'"${PACKAGE_NAME}"'", - "package_version": "'"${PACKAGE_VERSION}"'" - } - }' + - name: Git Checkout + uses: actions/checkout@v4 + with: + fetch-depth: '0' + - name: notify the main repo about the new release of docs package + run: | + PACKAGE_NAME=$(cat docs/package.json | grep '"name"' | awk -F'"' '{print $4}') + PACKAGE_VERSION=$(npm view $PACKAGE_NAME version) + curl -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: token ${{ secrets.PAT_TOKEN }}"\ + https://api.github.com/repos/zio/zio/dispatches \ + -d '{ + "event_type":"update-docs", + "client_payload":{ + "package_name":"'"${PACKAGE_NAME}"'", + "package_version": "'"${PACKAGE_VERSION}"'" + } + }' diff --git a/build.sbt b/build.sbt index f1bbc88ca..bdba4336b 100644 --- a/build.sbt +++ b/build.sbt @@ -1,32 +1,8 @@ import sbt.Def -import MimaSettings.mimaSettings import scala.sys.process._ import scala.util.Try - -/** - * As of zio-kafka version 2.8.0 releases are binary compatible. This is checked with Mima. - * - * Keep this value set to the oldest minor release (with patch version set to "0") that is still binary compatible. - * - * Set this value to `None` when master is _not_ binary compatible with the latest minor release, the next release shall - * increase the minor version. - */ -lazy val binCompatVersionToCompare = - // Note, "git describe --tags" - // either produces something like "v2.8.2-40-ge8a844a1" (not building from a release tag), - // or "v2.8.2" (building from a release tag), - Try("git describe --tags".!!).toOption - .map(_.strip()) - // Only continue when we're building from a release tag - .filter(_.matches("v[0-9]+\\.[0-9]+\\.[0-9]+")) - // Do not continue when this is a new minor version (when patch version is set to "0") - .filterNot(_.endsWith(".0")) - .map { tag => - // Remove `v` and set patch version to `0` - val compatVersion = tag.stripPrefix("v").split('.').take(2).mkString(".") + ".0" - println(s"Mima check compares against version $compatVersion") - compatVersion - } +import com.typesafe.tools.mima.core.Problem +import com.typesafe.tools.mima.core.ProblemFilters.exclude lazy val kafkaVersion = "3.8.1" lazy val embeddedKafkaVersion = "3.8.1" // Should be the same as kafkaVersion, except for the patch part @@ -59,6 +35,9 @@ inThisBuild( "com.github.vovapolu" %% "scaluzzi" % "0.1.23", "io.github.ghostbuster91.scalafix-unified" %% "unified" % "0.0.9" ), + mimaBinaryIssueFilters ++= Seq( + exclude[Problem]("zio.kafka.consumer.internal.*") + ), developers := List( Developer( "iravid", @@ -95,8 +74,7 @@ lazy val root = project .settings( name := "zio-kafka", publish / skip := true, - crossScalaVersions := Nil, // https://www.scala-sbt.org/1.x/docs/Cross-Build.html#Cross+building+a+project+statefully, - commands += lint + crossScalaVersions := Nil // https://www.scala-sbt.org/1.x/docs/Cross-Build.html#Cross+building+a+project+statefully, ) .aggregate( zioKafka, @@ -132,7 +110,6 @@ lazy val zioKafka = .enablePlugins(BuildInfoPlugin) .settings(stdSettings("zio-kafka")) .settings(buildInfoSettings("zio.kafka")) - .settings(mimaSettings(binCompatVersionToCompare, failOnProblem = true)) .settings(enableZIO(enableStreaming = true)) .settings( libraryDependencies ++= Seq(kafkaClients) @@ -152,7 +129,6 @@ lazy val zioKafkaTestkit = .dependsOn(zioKafka) .enablePlugins(BuildInfoPlugin) .settings(stdSettings("zio-kafka-testkit")) - .settings(mimaSettings(binCompatVersionToCompare, failOnProblem = false)) .settings( libraryDependencies ++= Seq( "dev.zio" %% "zio" % zioVersion.value, @@ -214,10 +190,6 @@ lazy val zioKafkaExample = crossScalaVersions -= scala3.value ) -addCommandAlias("fmt", "all scalafmtSbt scalafmt test:scalafmt") -addCommandAlias("check", "all scalafmtSbtCheck scalafmtCheck test:scalafmtCheck") -addCommandAlias("mimaCheck", "+zioKafka/mimaReportBinaryIssues;+zioKafkaTestkit/mimaReportBinaryIssues") - lazy val docs = project .in(file("zio-kafka-docs")) .settings( @@ -236,9 +208,3 @@ lazy val docs = project ) .enablePlugins(WebsitePlugin) .dependsOn(zioKafka, zioKafkaTestkit) - -// Extend 'lint' with mimaCheck -lazy val lint = { - val defaultLint = zio.sbt.Commands.ComposableCommand.lint - defaultLint.copy(commandStrings = defaultLint.commandStrings :+ "mimaCheck").toCommand -} diff --git a/project/MimaSettings.scala b/project/MimaSettings.scala deleted file mode 100644 index 71cdbafe6..000000000 --- a/project/MimaSettings.scala +++ /dev/null @@ -1,24 +0,0 @@ -import com.typesafe.tools.mima.core.* -import com.typesafe.tools.mima.core.ProblemFilters.* -import com.typesafe.tools.mima.plugin.MimaKeys.* -import sbt.* -import sbt.Keys.{ name, organization } - -object MimaSettings { - - def mimaSettings(binCompatVersionToCompare: Option[String], failOnProblem: Boolean): Seq[Def.Setting[?]] = - binCompatVersionToCompare match { - case None => - Seq(mimaPreviousArtifacts := Set.empty) - case Some(binCompatVersion) => - Seq( - mimaPreviousArtifacts := Set(organization.value %% name.value % binCompatVersion), - mimaBinaryIssueFilters ++= Seq( - exclude[Problem]("zio.kafka.consumer.internal.*") - ), - mimaFailOnProblem := failOnProblem - ) - - } - -} diff --git a/project/plugins.sbt b/project/plugins.sbt index a2a45ec4b..0fafd5650 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,12 +1,12 @@ -val zioSbtVersion = "0.4.0-alpha.28" +val zioSbtVersion = "0.0.0+529-d9aba4fa-SNAPSHOT" -addSbtPlugin("dev.zio" % "zio-sbt-ecosystem" % zioSbtVersion) -addSbtPlugin("dev.zio" % "zio-sbt-website" % zioSbtVersion) -addSbtPlugin("dev.zio" % "zio-sbt-ci" % zioSbtVersion) +addSbtPlugin("nl.thijsbroersen" % "zio-sbt-ecosystem" % zioSbtVersion) +addSbtPlugin("nl.thijsbroersen" % "zio-sbt-website" % zioSbtVersion) +addSbtPlugin("nl.thijsbroersen" % "zio-sbt-ci" % zioSbtVersion) -addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.13.0") addSbtPlugin("org.typelevel" % "sbt-tpolecat" % "0.5.2") addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.10.4") -addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.4") + +addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.7") resolvers ++= Resolver.sonatypeOssRepos("public")