Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Scala 3 Support #543

Merged
merged 8 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @Dwolla/scala-oss
136 changes: 120 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,57 +9,79 @@ name: Continuous Integration

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

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


concurrency:
group: ${{ github.workflow }} @ ${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build and Test
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.10, 2.12.17]
scala: [3, 2.13, 2.12]
java: [temurin@8, temurin@11]
runs-on: ${{ matrix.os }}
timeout-minutes: 60
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Java (temurin@8)
id: setup-java-temurin-8
if: matrix.java == 'temurin@8'
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 8
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
run: sbt '++ ${{ matrix.scala }}' reload +update

- name: Setup Java (temurin@11)
id: setup-java-temurin-11
if: matrix.java == 'temurin@11'
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@11' && steps.setup-java-temurin-11.outputs.cache-hit == 'false'
run: sbt '++ ${{ matrix.scala }}' reload +update

- name: Check that workflows are up to date
run: sbt '++ ${{ matrix.scala }}' githubWorkflowCheck
run: sbt githubWorkflowCheck

- run: sbt '++ ${{ matrix.scala }}' test mimaReportBinaryIssues doc

- name: Make target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v'))
run: mkdir -p core/js/target core/jvm/target aws-java-sdk2/target project/target

- name: Compress target directories
run: tar cf targets.tar target core/js/target core/jvm/target aws-java-sdk2/target project/target
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v'))
run: tar cf targets.tar core/js/target core/jvm/target aws-java-sdk2/target project/target

- name: Upload target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v'))
uses: actions/upload-artifact@v3
with:
name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }}
name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }}
path: targets.tar

publish:
Expand All @@ -69,7 +91,6 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.10]
java: [temurin@8]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -79,44 +100,127 @@ jobs:
fetch-depth: 0

- name: Setup Java (temurin@8)
id: setup-java-temurin-8
if: matrix.java == 'temurin@8'
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 8
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
run: sbt reload +update

- name: Setup Java (temurin@11)
id: setup-java-temurin-11
if: matrix.java == 'temurin@11'
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
cache: sbt

- name: Download target directories (2.13.10)
- name: sbt update
if: matrix.java == 'temurin@11' && steps.setup-java-temurin-11.outputs.cache-hit == 'false'
run: sbt reload +update

- name: Download target directories (3)
uses: actions/download-artifact@v3
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-3

- name: Inflate target directories (3)
run: |
tar xf targets.tar
rm targets.tar

- name: Download target directories (2.13)
uses: actions/download-artifact@v3
with:
name: target-${{ matrix.os }}-2.13.10-${{ matrix.java }}
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13

- name: Inflate target directories (2.13.10)
- name: Inflate target directories (2.13)
run: |
tar xf targets.tar
rm targets.tar

- name: Download target directories (2.12.17)
- name: Download target directories (2.12)
uses: actions/download-artifact@v3
with:
name: target-${{ matrix.os }}-2.12.17-${{ matrix.java }}
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12

- name: Inflate target directories (2.12.17)
- name: Inflate target directories (2.12)
run: |
tar xf targets.tar
rm targets.tar

- env:
- name: Import signing key
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == ''
env:
PGP_SECRET: ${{ secrets.PGP_SECRET }}
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
run: echo $PGP_SECRET | base64 -di | gpg --import

- name: Import signing key and strip passphrase
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE != ''
env:
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
PGP_PASSPHRASE: ${{ secrets.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)

- name: Publish
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
run: sbt ci-release
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_CREDENTIAL_HOST: ${{ secrets.SONATYPE_CREDENTIAL_HOST }}
run: sbt tlCiRelease

dependency-submission:
name: Submit Dependencies
if: github.event_name != 'pull_request'
strategy:
matrix:
os: [ubuntu-latest]
java: [temurin@8]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Java (temurin@8)
id: setup-java-temurin-8
if: matrix.java == 'temurin@8'
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 8
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
run: sbt reload +update

- name: Setup Java (temurin@11)
id: setup-java-temurin-11
if: matrix.java == 'temurin@11'
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@11' && steps.setup-java-temurin-11.outputs.cache-hit == 'false'
run: sbt reload +update

- name: Submit Dependencies
uses: scalacenter/sbt-dependency-submission@v2
with:
modules-ignore: fs2-aws
configs-ignore: test scala-tool scala-doc-tool
69 changes: 36 additions & 33 deletions .mergify.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
queue_rules:
- name: default
conditions:
- status-success=Build and Test (ubuntu-latest, 2.13.10, temurin@8)
- status-success=Build and Test (ubuntu-latest, 2.13.10, temurin@11)
- status-success=Build and Test (ubuntu-latest, 2.12.17, temurin@8)
- status-success=Build and Test (ubuntu-latest, 2.12.17, temurin@11)
# This file was automatically generated by sbt-typelevel-mergify using the
# mergifyGenerate 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 mergify configuration
# to meet your needs, then regenerate this file.

pull_request_rules:
- name: assign and label scala-steward's PRs
conditions:
- author=dwolla-oss-scala-steward[bot]
actions:
request_reviews:
users: [bpholt]
label:
add: [dependency-update]
- name: automatic update pull requests
conditions:
- author=scala-steward
- -conflict # skip PRs with conflicts
- -draft # filter-out GH draft PRs
actions:
update:
- name: merge scala-steward's PRs
conditions:
- author=dwolla-oss-scala-steward[bot]
- status-success=Build and Test (ubuntu-latest, 2.13.10, temurin@8)
- status-success=Build and Test (ubuntu-latest, 2.13.10, temurin@11)
- status-success=Build and Test (ubuntu-latest, 2.12.17, temurin@8)
- status-success=Build and Test (ubuntu-latest, 2.12.17, temurin@11)
actions:
queue:
method: squash
name: default
- name: merge scala-steward's PRs
conditions:
- author=dwolla-oss-scala-steward[bot]
- or:
- body~=labels:.*early-semver-patch
- body~=labels:.*early-semver-minor
- status-success=Build and Test (ubuntu-latest, 3, temurin@8)
- status-success=Build and Test (ubuntu-latest, 3, temurin@11)
- status-success=Build and Test (ubuntu-latest, 2.13, temurin@8)
- status-success=Build and Test (ubuntu-latest, 2.13, temurin@11)
- status-success=Build and Test (ubuntu-latest, 2.12, temurin@8)
- status-success=Build and Test (ubuntu-latest, 2.12, temurin@11)
actions:
merge: {}
- name: Label aws-java-sdk2 PRs
conditions:
- files~=^aws-java-sdk2/
actions:
label:
add:
- aws-java-sdk2
remove: []
- name: Label core PRs
conditions:
- files~=^core/
actions:
label:
add:
- core
remove: []
54 changes: 47 additions & 7 deletions aws-java-sdk2/src/main/scala/com/dwolla/fs2aws/kms/KmsAlg.scala
Original file line number Diff line number Diff line change
@@ -1,23 +1,37 @@
package com.dwolla.fs2aws.kms

import com.dwolla.fs2aws.AwsEval._
import cats.effect._
import cats.implicits._
import cats.tagless._
import software.amazon.awssdk.services.kms._
import cats.effect.*
import cats.syntax.all.*
import cats.tagless.*
import cats.tagless.aop.*
import cats.~>
import com.dwolla.fs2aws.AwsEval.*
import software.amazon.awssdk.core.SdkBytes
import software.amazon.awssdk.services.kms.*
import software.amazon.awssdk.services.kms.model.DecryptRequest
import software.amazon.awssdk.utils.BinaryUtils

import scala.util.Try

@autoFunctorK
@autoInstrument
trait KmsAlg[F[_]] {
def decrypt(string: String): F[String]
}

object KmsAlg {
implicit def instrumentForKmsAlg(): Instrument[KmsAlg] = instrument

// do this manually until cats-tagless-macros are published for Scala 3
private val instrument = new Instrument[KmsAlg] {
override def instrument[F[_]](af: KmsAlg[F]): KmsAlg[Instrumentation[F, *]] = new KmsAlg[Instrumentation[F, *]] {
override def decrypt(string: String): Instrumentation[F, String] =
Instrumentation(af.decrypt(string), "KmsAlg", "decrypt")
}

override def mapK[F[_], G[_]](af: KmsAlg[F])(fk: F ~> G): KmsAlg[G] = new KmsAlg[G] {
override def decrypt(string: String): G[String] = fk(af.decrypt(string))
}
}

private def acquireKmsClient[F[_] : Sync]: F[KmsAsyncClient] =
Sync[F].delay(KmsAsyncClient.builder().build())

Expand All @@ -38,4 +52,30 @@ object KmsAlg {
} yield resp

}

@deprecated("only kept for binary compatibility purposes", "3.0.0-RC2")
def mapK[F[_], G[_]](alg: KmsAlg[F], fk: F ~> G): KmsAlg[G] = instrumentForKmsAlg().mapK(alg)(fk)

@deprecated("only kept for binary compatibility purposes", "3.0.0-RC2")
def functorKForKmsAlg(): FunctorK[KmsAlg] = instrumentForKmsAlg()

@deprecated("only kept for binary compatibility purposes", "3.0.0-RC2")
object fullyRefined {
@deprecated("only kept for binary compatibility purposes", "3.0.0-RC2")
implicit val functorKForFullyRefinedKmsAlg: FunctorK[_root_.com.dwolla.fs2aws.kms.KmsAlg] = functorKForKmsAlg()

@deprecated("only kept for binary compatibility purposes", "3.0.0-RC2")
object autoDerive {
@deprecated("only kept for binary compatibility purposes", "3.0.0-RC2")
@_root_.java.lang.SuppressWarnings(value = _root_.scala.Array("org.wartremover.warts.ImplicitParameter"))
implicit def fromFunctorKFullyRefinedKmsAlg[F[_], G[_]](implicit fk: F ~> G, af: KmsAlg[F]): KmsAlg[G] = mapK(af, fk)
}
}

@deprecated("only kept for binary compatibility purposes", "3.0.0-RC2")
object autoDerive {
@deprecated("only kept for binary compatibility purposes", "3.0.0-RC2")
@_root_.java.lang.SuppressWarnings(value = _root_.scala.Array("org.wartremover.warts.ImplicitParameter"))
implicit def fromFunctorKKmsAlg[F[_], G[_]](implicit fk: F ~> G, af: KmsAlg[F]): KmsAlg[G] = mapK(af, fk)
}
}
Loading