From 27e1f8fdb28985690c422dbdba9425b21538b05e Mon Sep 17 00:00:00 2001 From: calvinlfer Date: Sat, 17 Aug 2024 14:12:49 -0400 Subject: [PATCH] Maintenance - Update to Scala 2.13.14 - Update base images for Cassandra --- build.sbt | 7 +- .../virgil/CassandraContainer.scala | 4 +- project/plugins.sbt | 4 +- zio/.github/workflows/ci.yml | 159 ++++++++++++++++++ zio/.github/workflows/clean.yml | 60 +++++++ .../virgil/CassandraContainer.scala | 4 +- 6 files changed, 229 insertions(+), 9 deletions(-) create mode 100644 zio/.github/workflows/ci.yml create mode 100644 zio/.github/workflows/clean.yml diff --git a/build.sbt b/build.sbt index c3d5366b..f3813431 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,6 @@ inThisBuild { val scala212 = "2.12.19" - val scala213 = "2.13.13" + val scala213 = "2.13.14" val scala3 = "3.3.3" List( @@ -47,6 +47,7 @@ inThisBuild { new TestFramework("weaver.framework.CatsEffect") ), semanticdbEnabled := true, + semanticdbVersion := scalafixSemanticdb.revision, versionScheme := Some("early-semver"), sonatypeCredentialHost := "s01.oss.sonatype.org", sonatypeProfileName := "io.kaizen-solutions", @@ -77,7 +78,7 @@ lazy val core = val datastaxV = "4.17.0" val zio = "dev.zio" - val zioV = "2.1.6" + val zioV = "2.1.7" val magnoliaForScala2 = "com.softwaremill.magnolia1_2" %% "magnolia" % "1.1.10" val scalaReflectForScala2 = "org.scala-lang" % "scala-reflect" % scalaVersion.value val magnoliaForScala3 = "com.softwaremill.magnolia1_3" %% "magnolia" % "1.3.7" @@ -90,7 +91,7 @@ lazy val core = zio %% "zio-test-scalacheck" % zioV % Test, zio %% "zio-test-sbt" % zioV % Test, "com.dimafeng" %% "testcontainers-scala" % "0.41.4" % Test, - "com.outr" %% "scribe-slf4j" % "3.14.0" % Test + "com.outr" %% "scribe-slf4j" % "3.15.0" % Test ) val isScala2x = scalaVersion.value.startsWith("2") diff --git a/cats-effect/src/test/scala/io/kaizensolutions/virgil/CassandraContainer.scala b/cats-effect/src/test/scala/io/kaizensolutions/virgil/CassandraContainer.scala index 40358b71..395301f4 100644 --- a/cats-effect/src/test/scala/io/kaizensolutions/virgil/CassandraContainer.scala +++ b/cats-effect/src/test/scala/io/kaizensolutions/virgil/CassandraContainer.scala @@ -13,12 +13,12 @@ trait CassandraContainer { object CassandraContainer { def apply(cassType: CassandraType): Resource[IO, CassandraContainer] = { val nativePort = 9042 - val datastaxEnterprise = "datastax/dse-server:6.8.19" + val datastaxEnterprise = "datastax/dse-server:6.9.1" val datastaxEnv = Map( "DS_LICENSE" -> "accept", "JVM_EXTRA_OPTS" -> "-Dcassandra.skip_wait_for_gossip_to_settle=0 -Dcassandra.load_ring_state=false -Dcassandra.initial_token=1 -Dcassandra.num_tokens=nil -Dcassandra.allocate_tokens_for_local_replication_factor=nil" ) - val vanilla = "cassandra:4" + val vanilla = "cassandra:5" val vanillaEnv = Map( "CASSANDRA_ENDPOINT_SNITCH" -> "GossipingPropertyFileSnitch", "CASSANDRA_DC" -> "dc1", diff --git a/project/plugins.sbt b/project/plugins.sbt index 5e0064d5..64140c45 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,7 +1,7 @@ addSbtPlugin("com.github.sbt" % "sbt-github-actions" % "0.24.0") addSbtPlugin("org.typelevel" % "sbt-tpolecat" % "0.5.1") -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.11") -addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.3.12") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.1.0") +addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.3.13") addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.4") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.12.1") diff --git a/zio/.github/workflows/ci.yml b/zio/.github/workflows/ci.yml new file mode 100644 index 00000000..e6644713 --- /dev/null +++ b/zio/.github/workflows/ci.yml @@ -0,0 +1,159 @@ +# 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: ['**'] + tags: [v*] + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + build: + name: Build and Test + strategy: + matrix: + os: [ubuntu-latest] + scala: [2.12.19, 2.13.14, 3.3.3] + java: [temurin@11, temurin@17, temurin@21] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout current branch (full) + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - 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 & Test + run: sbt '++ ${{ matrix.scala }}' clean coverage test + + - name: Coverage + run: sbt '++ ${{ matrix.scala }}' coverageAggregate + + - name: Compress target directories + run: tar cf targets.tar target core/target zio/target cats-effect/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') || github.ref == 'refs/heads/main') + strategy: + matrix: + os: [ubuntu-latest] + scala: [2.13.14] + java: [temurin@11] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout current branch (full) + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - 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: 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: 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 (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: 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/zio/.github/workflows/clean.yml b/zio/.github/workflows/clean.yml new file mode 100644 index 00000000..bfc865d5 --- /dev/null +++ b/zio/.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/zio/src/test/scala/io/kaizensolutions/virgil/CassandraContainer.scala b/zio/src/test/scala/io/kaizensolutions/virgil/CassandraContainer.scala index e6349910..7f3c6633 100644 --- a/zio/src/test/scala/io/kaizensolutions/virgil/CassandraContainer.scala +++ b/zio/src/test/scala/io/kaizensolutions/virgil/CassandraContainer.scala @@ -10,12 +10,12 @@ trait CassandraContainer { object CassandraContainer { def apply(cassType: CassandraType): URIO[Scope, CassandraContainer] = { val nativePort = 9042 - val datastaxEnterprise = "datastax/dse-server:6.8.19" + val datastaxEnterprise = "datastax/dse-server:6.9.1" val datastaxEnv = Map( "DS_LICENSE" -> "accept", "JVM_EXTRA_OPTS" -> "-Dcassandra.skip_wait_for_gossip_to_settle=0 -Dcassandra.load_ring_state=false -Dcassandra.initial_token=1 -Dcassandra.num_tokens=nil -Dcassandra.allocate_tokens_for_local_replication_factor=nil" ) - val vanilla = "cassandra:4" + val vanilla = "cassandra:5" val vanillaEnv = Map( "CASSANDRA_ENDPOINT_SNITCH" -> "GossipingPropertyFileSnitch", "CASSANDRA_DC" -> "dc1",