diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ebb8659..1d02519 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,88 +1,156 @@ -name: CI +# This file was automatically generated by sbt-github-actions using the +# githubWorkflowGenerate task. You should add and commit this file to +# your git repository. It goes without saying that you shouldn't edit +# this file by hand! Instead, if you wish to make changes, you should +# change your sbt build configuration to revise the workflow description +# to meet your needs, then regenerate this file. + +name: Continuous Integration on: pull_request: + branches: ['**'] push: - branches: ['series/1.x', 'series/2.x'] - release: - types: - - published + branches: ['**'] + tags: [v*] + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: - lint: - runs-on: ubuntu-20.04 + build: + name: Build and Test strategy: - fail-fast: false + matrix: + os: [ubuntu-latest] + scala: [3.3.3, 2.13.14, 2.12.19] + java: [temurin@11, temurin@17, temurin@21] + runs-on: ${{ matrix.os }} steps: - - name: Checkout current branch - uses: actions/checkout@v2.3.4 + - name: Checkout current branch (full) + uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Setup Scala and Java - uses: olafurpg/setup-scala@v10 - - name: Cache scala dependencies - uses: coursier/cache-action@v5 - - name: Lint code - run: sbt check - - test: - runs-on: ubuntu-20.04 + + - name: Setup Java (temurin@11) + if: matrix.java == 'temurin@11' + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 11 + cache: sbt + + - name: Setup Java (temurin@17) + if: matrix.java == 'temurin@17' + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + cache: sbt + + - name: Setup Java (temurin@21) + if: matrix.java == 'temurin@21' + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 21 + cache: sbt + + - name: Setup sbt + uses: sbt/setup-sbt@v1 + + - name: Check that workflows are up to date + run: sbt '++ ${{ matrix.scala }}' githubWorkflowCheck + + - name: Build project + run: sbt '++ ${{ matrix.scala }}' test + + - name: Compress target directories + run: tar cf targets.tar target zio-sqs/target zio-sqs-docs/target project/target + + - name: Upload target directories + uses: actions/upload-artifact@v4 + with: + name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }} + path: targets.tar + + publish: + name: Publish Artifacts + needs: [build] + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v')) strategy: - fail-fast: false matrix: - java: ['adopt@1.8', 'adopt@1.11'] - scala: ['2.12.18', '2.13.11', '3.3.0'] + os: [ubuntu-latest] + scala: [2.13.14] + java: [temurin@11] + runs-on: ${{ matrix.os }} steps: - - name: Checkout current branch - uses: actions/checkout@v2.3.4 + - name: Checkout current branch (full) + uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Setup Scala and Java - uses: olafurpg/setup-scala@v10 + + - name: Setup Java (temurin@11) + if: matrix.java == 'temurin@11' + uses: actions/setup-java@v4 with: - java-version: ${{ matrix.java }} - - name: Cache scala dependencies - uses: coursier/cache-action@v5 - - name: Run tests - run: sbt ++${{ matrix.scala }}! test - - website: - runs-on: ubuntu-20.04 - timeout-minutes: 60 - steps: - - name: Checkout current branch - uses: actions/checkout@v3.1.0 - - name: Setup Scala and Java - uses: olafurpg/setup-scala@v13 - - name: Cache scala dependencies - uses: coursier/cache-action@v6 - - name: Check Document Generation - run: sbt docs/compileDocs - - ci: - runs-on: ubuntu-20.04 - needs: [lint, website, test] - steps: - - name: Aggregate of lint, docs, and all tests - run: echo "ci passed" - - publish: - runs-on: ubuntu-20.04 - needs: [ci] - if: github.event_name != 'pull_request' - steps: - - name: Checkout current branch - uses: actions/checkout@v2.3.4 + distribution: temurin + java-version: 11 + cache: sbt + + - name: Setup Java (temurin@17) + if: matrix.java == 'temurin@17' + uses: actions/setup-java@v4 with: - fetch-depth: 0 - - name: Setup Scala and Java - uses: olafurpg/setup-scala@v10 - - name: Cache scala dependencies - uses: coursier/cache-action@v5 - - name: Release artifacts - run: sbt ci-release + distribution: temurin + java-version: 17 + cache: sbt + + - name: Setup Java (temurin@21) + if: matrix.java == 'temurin@21' + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 21 + cache: sbt + + - name: Setup sbt + uses: sbt/setup-sbt@v1 + + - name: Download target directories (3.3.3) + uses: actions/download-artifact@v4 + with: + name: target-${{ matrix.os }}-3.3.3-${{ matrix.java }} + + - name: Inflate target directories (3.3.3) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.13.14) + uses: actions/download-artifact@v4 + with: + name: target-${{ matrix.os }}-2.13.14-${{ matrix.java }} + + - name: Inflate target directories (2.13.14) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.12.19) + uses: actions/download-artifact@v4 + with: + name: target-${{ matrix.os }}-2.12.19-${{ matrix.java }} + + - name: Inflate target directories (2.12.19) + run: | + tar xf targets.tar + rm targets.tar + + - name: Publish project env: PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} PGP_SECRET: ${{ secrets.PGP_SECRET }} SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + run: sbt ci-release diff --git a/.github/workflows/clean.yml b/.github/workflows/clean.yml new file mode 100644 index 0000000..bfc865d --- /dev/null +++ b/.github/workflows/clean.yml @@ -0,0 +1,60 @@ +# This file was automatically generated by sbt-github-actions using the +# githubWorkflowGenerate task. You should add and commit this file to +# your git repository. It goes without saying that you shouldn't edit +# this file by hand! Instead, if you wish to make changes, you should +# change your sbt build configuration to revise the workflow description +# to meet your needs, then regenerate this file. + +name: Clean + +on: push + +jobs: + delete-artifacts: + name: Delete Artifacts + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Delete artifacts + shell: bash {0} + run: | + # Customize those three lines with your repository and credentials: + REPO=${GITHUB_API_URL}/repos/${{ github.repository }} + + # A shortcut to call GitHub API. + ghapi() { curl --silent --location --user _:$GITHUB_TOKEN "$@"; } + + # A temporary file which receives HTTP response headers. + TMPFILE=$(mktemp) + + # An associative array, key: artifact name, value: number of artifacts of that name. + declare -A ARTCOUNT + + # Process all artifacts on this repository, loop on returned "pages". + URL=$REPO/actions/artifacts + while [[ -n "$URL" ]]; do + + # Get current page, get response headers in a temporary file. + JSON=$(ghapi --dump-header $TMPFILE "$URL") + + # Get URL of next page. Will be empty if we are at the last page. + URL=$(grep '^Link:' "$TMPFILE" | tr ',' '\n' | grep 'rel="next"' | head -1 | sed -e 's/.*.*//') + rm -f $TMPFILE + + # Number of artifacts on this page: + COUNT=$(( $(jq <<<$JSON -r '.artifacts | length') )) + + # Loop on all artifacts on this page. + for ((i=0; $i < $COUNT; i++)); do + + # Get name of artifact and count instances of this name. + name=$(jq <<<$JSON -r ".artifacts[$i].name?") + ARTCOUNT[$name]=$(( $(( ${ARTCOUNT[$name]} )) + 1)) + + id=$(jq <<<$JSON -r ".artifacts[$i].id?") + size=$(( $(jq <<<$JSON -r ".artifacts[$i].size_in_bytes?") )) + printf "Deleting '%s' #%d, %'d bytes\n" $name ${ARTCOUNT[$name]} $size + ghapi -X DELETE $REPO/actions/artifacts/$id + done + done diff --git a/.github/workflows/site.yml b/.github/workflows/site.yml index f77baca..3973954 100644 --- a/.github/workflows/site.yml +++ b/.github/workflows/site.yml @@ -1,16 +1,15 @@ -# This file was autogenerated using `zio-sbt-website` via `sbt generateGithubWorkflow` -# task and should be included in the git repository. Please do not edit it manually. - name: Website 'on': workflow_dispatch: {} release: types: - - published + - published push: branches: - - series/2.x - pull_request: {} + - series/2.x + pull_request: + branches-ignore: + - gh-pages jobs: build: name: Build and Test @@ -22,17 +21,19 @@ jobs: with: fetch-depth: '0' - name: Setup Scala - uses: actions/setup-java@v3.9.0 + uses: actions/setup-java@v4 with: distribution: temurin java-version: 17 check-latest: true - name: Check that site workflow is up to date - run: sbt docs/checkGithubWorkflow + run: sbt docs/compileDocs - name: Check artifacts build process - run: sbt +publishLocal + run: sbt +publishLocal - name: Check website build process - run: sbt docs/buildWebsite + run: | + sbt docs/clean + sbt docs/buildWebsite publish-docs: name: Publish Docs runs-on: ubuntu-latest @@ -43,7 +44,7 @@ jobs: with: fetch-depth: '0' - name: Setup Scala - uses: actions/setup-java@v3.9.0 + uses: actions/setup-java@v4 with: distribution: temurin java-version: 17 @@ -57,40 +58,64 @@ jobs: run: sbt docs/publishToNpm env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - generate-readme: - name: Generate README + update-readme: + name: Update README runs-on: ubuntu-latest - if: ${{ (github.event_name == 'push') || ((github.event_name == 'release') && (github.event_name == 'published')) }} + continue-on-error: false + if: ${{ github.event_name == 'push' }} steps: - name: Git Checkout - uses: actions/checkout@v3.3.0 + uses: actions/checkout@v4 with: - ref: ${{ github.head_ref }} 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@v3.9.0 + uses: actions/setup-java@v4 with: - distribution: temurin - java-version: 17 + distribution: corretto + java-version: '17' check-latest: true + - name: Cache Dependencies + uses: coursier/cache-action@v6 - name: Generate Readme - run: sbt docs/generateReadme + run: sbt docs/generateReadme - name: Commit Changes run: | - git config --local user.email "github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" + 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 - uses: peter-evans/create-pull-request@v4.2.3 + 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. + I will automatically update the README.md file whenever there is a 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 }} \ No newline at end of file diff --git a/README.md b/README.md index 70da3cb..d90d86b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [ZIO SQS](https://zio.dev/zio-sqs) is a ZIO-powered client for AWS SQS. It is built on top of the [AWS SDK for Java 2.0](https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/basics.html) via the automatically generated wrappers from [zio-aws](https://zio.dev/zio-aws). -[![Production Ready](https://img.shields.io/badge/Project%20Stage-Production%20Ready-brightgreen.svg)](https://github.com/zio/zio/wiki/Project-Stages) ![CI Badge](https://github.com/zio/zio-sqs/workflows/CI/badge.svg) [![Sonatype Releases](https://img.shields.io/nexus/r/https/oss.sonatype.org/dev.zio/zio-sqs_2.13.svg?label=Sonatype%20Release)](https://oss.sonatype.org/content/repositories/releases/dev/zio/zio-sqs_2.13/) [![Sonatype Snapshots](https://img.shields.io/nexus/s/https/oss.sonatype.org/dev.zio/zio-sqs_2.13.svg?label=Sonatype%20Snapshot)](https://oss.sonatype.org/content/repositories/snapshots/dev/zio/zio-sqs_2.13/) [![javadoc](https://javadoc.io/badge2/dev.zio/zio-sqs_2.13/javadoc.svg)](https://javadoc.io/doc/dev.zio/zio-sqs_2.13) [![ZIO SQS](https://img.shields.io/github/stars/zio/zio-sqs?style=social)](https://github.com/zio/zio-sqs) +[![Production Ready](https://img.shields.io/badge/Project%20Stage-Production%20Ready-brightgreen.svg)](https://github.com/zio/zio/wiki/Project-Stages) ![CI Badge](https://github.com/zio/zio-sqs/workflows/CI/badge.svg) [![Sonatype Releases](https://img.shields.io/nexus/r/https/oss.sonatype.org/dev.zio/zio-sqs_2.13.svg?label=Sonatype%20Release)](https://oss.sonatype.org/content/repositories/releases/dev/zio/zio-sqs_2.13/) [![Sonatype Snapshots](https://img.shields.io/nexus/s/https/oss.sonatype.org/dev.zio/zio-sqs_2.13.svg?label=Sonatype%20Snapshot)](https://oss.sonatype.org/content/repositories/snapshots/dev/zio/zio-sqs_2.13/) [![javadoc](https://javadoc.io/badge2/dev.zio/zio-sqs-docs_2.13/javadoc.svg)](https://javadoc.io/doc/dev.zio/zio-sqs-docs_2.13) [![ZIO SQS](https://img.shields.io/github/stars/zio/zio-sqs?style=social)](https://github.com/zio/zio-sqs) ## Introduction @@ -17,7 +17,7 @@ ZIO SQS enables us to produce and consume elements to/from the Amazon SQS servic In order to use this library, we need to add the following line in our `build.sbt` file: ```scala -libraryDependencies += "dev.zio" %% "zio-sqs" % "0.5.0" +libraryDependencies += "dev.zio" %% "zio-sqs" % "0.6.0" ``` ## Example @@ -66,11 +66,11 @@ Learn more on the [ZIO SQS homepage](https://zio.dev/zio-sqs)! ## Contributing -For the general guidelines, see ZIO [contributor's guide](https://zio.dev/about/contributing). +For the general guidelines, see ZIO [contributor's guide](https://zio.dev/contributor-guidelines). ## Code of Conduct -See the [Code of Conduct](https://zio.dev/about/code-of-conduct) +See the [Code of Conduct](https://zio.dev/code-of-conduct) ## Support diff --git a/build.sbt b/build.sbt index 5a972fd..0c4ffa8 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,7 @@ -val mainScala = "2.13.11" -val allScala = Seq("3.3.0", "2.13.11", "2.12.18") -val zioVersion = "2.0.15" -val zioAwsVersion = "6.20.83.2" +val mainScala = "2.13.14" +val allScala = Seq("3.3.3", "2.13.14", "2.12.19") +val zioVersion = "2.1.9" +val zioAwsVersion = "7.21.15.15" inThisBuild( List( @@ -26,6 +26,25 @@ inThisBuild( "ghostdogpr@gmail.com", url("https://github.com/ghostdogpr") ) + ), + githubWorkflowTargetTags ++= Seq("v*"), + githubWorkflowPublishTargetBranches := Seq(RefPredicate.StartsWith(Ref.Tag("v"))), + githubWorkflowJavaVersions := List( + JavaSpec.temurin("11"), + JavaSpec.temurin("17"), + JavaSpec.temurin("21") + ), + githubWorkflowPublish := Seq( + WorkflowStep.Sbt( + commands = List("ci-release"), + name = Some("Publish project"), + env = Map( + "PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}", + "PGP_SECRET" -> "${{ secrets.PGP_SECRET }}", + "SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}", + "SONATYPE_USERNAME" -> "${{ secrets.SONATYPE_USERNAME }}" + ) + ) ) ) ) @@ -57,17 +76,15 @@ lazy val sqs = "dev.zio" %% "zio-streams" % zioVersion, "dev.zio" %% "zio-aws-sqs" % zioAwsVersion, "dev.zio" %% "zio-aws-netty" % zioAwsVersion, - "org.scala-lang.modules" %% "scala-collection-compat" % "2.8.0", + "org.scala-lang.modules" %% "scala-collection-compat" % "2.12.0", "dev.zio" %% "zio-test" % zioVersion % "test", "dev.zio" %% "zio-test-sbt" % zioVersion % "test", - "org.elasticmq" %% "elasticmq-rest-sqs" % "1.3.7" % "test" cross CrossVersion.for3Use2_13, - "org.elasticmq" %% "elasticmq-core" % "1.3.7" % "test" cross CrossVersion.for3Use2_13 + "org.elasticmq" %% "elasticmq-rest-sqs" % "1.6.7" % "test" cross CrossVersion.for3Use2_13, + "org.elasticmq" %% "elasticmq-core" % "1.6.7" % "test" cross CrossVersion.for3Use2_13 ) ++ (CrossVersion.partialVersion(scalaVersion.value) match { - case Some((2, 12)) => - Seq("org.typelevel" %% "kind-projector" % "0.10.3") - case Some((2, 13)) => - Seq("org.typelevel" %% "kind-projector" % "0.10.3") - case _ => + case Some((2, 12 | 13)) => + Seq("org.typelevel" %% "kind-projector" % "0.13.3" cross CrossVersion.full) + case _ => Nil }), scalacOptions ++= Seq( @@ -109,7 +126,8 @@ lazy val sqs = "-Ywarn-unused", "-Ywarn-value-discard" ) - case _ => Nil + case _ => + Nil }), testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework") ) @@ -123,7 +141,6 @@ lazy val docs = project projectName := "ZIO SQS", mainModuleName := (sqs / moduleName).value, projectStage := ProjectStage.ProductionReady, - docsPublishBranch := "series/2.x", ScalaUnidoc / unidoc / unidocProjectFilter := inProjects(sqs), libraryDependencies ++= Seq( "dev.zio" %% "zio" % zioVersion diff --git a/project/build.properties b/project/build.properties index 46e43a9..ee4c672 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.8.2 +sbt.version=1.10.1 diff --git a/project/plugins.sbt b/project/plugins.sbt index 2fc513e..a8133e1 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,7 @@ -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.3") -addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") -addSbtPlugin("dev.zio" % "zio-sbt-website" % "0.3.2") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.3") +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.6.1") +addSbtPlugin("com.github.sbt" % "sbt-github-actions" % "0.24.0") +addSbtPlugin("dev.zio" % "zio-sbt-website" % "0.4.0-alpha.28") +addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.4") resolvers ++= Resolver.sonatypeOssRepos("public") diff --git a/zio-sqs/src/test/scala/zio/sqs/producer/ProducerSpec.scala b/zio-sqs/src/test/scala/zio/sqs/producer/ProducerSpec.scala index 8f9f90b..a2478f6 100644 --- a/zio-sqs/src/test/scala/zio/sqs/producer/ProducerSpec.scala +++ b/zio-sqs/src/test/scala/zio/sqs/producer/ProducerSpec.scala @@ -7,7 +7,6 @@ import zio.aws.core.{ aspects, AwsError } import zio.aws.sqs.model._ import zio.aws.sqs.{ model, Sqs } import software.amazon.awssdk.services.sqs.SqsAsyncClient -import zio.durationInt import zio.sqs.ZioSqsMockServer._ import zio.sqs.producer.Producer.{ DefaultProducer, SqsRequest, SqsRequestEntry, SqsResponseErrorEntry } import zio.sqs.serialization.Serializer