Skip to content

Commit

Permalink
Upgrade Dependencies (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
austek authored Aug 21, 2024
1 parent 18fb814 commit abc10e8
Show file tree
Hide file tree
Showing 24 changed files with 117 additions and 126 deletions.
98 changes: 42 additions & 56 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,58 +23,51 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [3.3.1]
java: [temurin@17, temurin@20]
scala: [3.3.4-RC1]
java: [zulu@17, zulu@20]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Java (temurin@17)
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v2
- name: Setup Java (zulu@17)
if: matrix.java == 'zulu@17'
uses: actions/setup-java@v4
with:
distribution: temurin
distribution: zulu
java-version: 17
cache: sbt

- name: Setup Java (temurin@20)
if: matrix.java == 'temurin@20'
uses: actions/setup-java@v2
- name: Setup Java (zulu@20)
if: matrix.java == 'zulu@20'
uses: actions/setup-java@v4
with:
distribution: temurin
distribution: zulu
java-version: 20
cache: sbt

- 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: Setup sbt
uses: sbt/setup-sbt@v1

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

- name: Start containers
run: docker compose -f docker-compose.yml up -d

- name: Build project
run: sbt ++${{ matrix.scala }} compile scalafmtCheckAll javafmtCheckAll plugin/test
run: sbt '++ ${{ matrix.scala }}' compile scalafmtCheckAll javafmtCheckAll plugin/test

- name: Test Consumer
run: sbt ++${{ matrix.scala }} consumer/test
run: sbt '++ ${{ matrix.scala }}' consumer/test

- name: Upload Consumer Pact
run: ./scripts/pact-publish.sh

- name: Test Provider
run: sbt ++${{ matrix.scala }} provider/test
run: sbt '++ ${{ matrix.scala }}' provider/test

- name: Stop containers
if: always()
Expand All @@ -84,7 +77,7 @@ jobs:
run: tar cf targets.tar target modules/plugin/target modules/examples/provider/target modules/examples/consumer/target project/target

- name: Upload target directories
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }}
path: targets.tar
Expand All @@ -96,47 +89,40 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [3.3.1]
java: [temurin@17]
scala: [3.3.4-RC1]
java: [zulu@17]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Java (temurin@17)
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v2
- name: Setup Java (zulu@17)
if: matrix.java == 'zulu@17'
uses: actions/setup-java@v4
with:
distribution: temurin
distribution: zulu
java-version: 17
cache: sbt

- name: Setup Java (temurin@20)
if: matrix.java == 'temurin@20'
uses: actions/setup-java@v2
- name: Setup Java (zulu@20)
if: matrix.java == 'zulu@20'
uses: actions/setup-java@v4
with:
distribution: temurin
distribution: zulu
java-version: 20
cache: sbt

- 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 (3.3.1)
uses: actions/download-artifact@v2
- name: Setup sbt
uses: sbt/setup-sbt@v1

- name: Download target directories (3.3.4-RC1)
uses: actions/download-artifact@v4
with:
name: target-${{ matrix.os }}-3.3.1-${{ matrix.java }}
name: target-${{ matrix.os }}-3.3.4-RC1-${{ matrix.java }}

- name: Inflate target directories (3.3.1)
- name: Inflate target directories (3.3.4-RC1)
run: |
tar xf targets.tar
rm targets.tar
Expand All @@ -153,7 +139,7 @@ jobs:
run: ./scripts/docBuild.sh ${{ github.ref }}

- name: Build package
run: 'sbt ++${{ matrix.scala }} universal:packageZipTarball'
run: 'sbt universal:packageZipTarball'

- name: Prepare Artifacts
run: ./scripts/prepArtifacts.sh
Expand All @@ -170,4 +156,4 @@ jobs:
- name: Publish docs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: sbt ++${{ matrix.scala }} publishToGitHubPages
run: sbt publishToGitHubPages
3 changes: 2 additions & 1 deletion .github/workflows/clean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
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 }}
Expand All @@ -25,7 +26,7 @@ jobs:
ghapi() { curl --silent --location --user _:$GITHUB_TOKEN "$@"; }
# A temporary file which receives HTTP response headers.
TMPFILE=/tmp/tmp.$$
TMPFILE=$(mktemp)
# An associative array, key: artifact name, value: number of artifacts of that name.
declare -A ARTCOUNT
Expand Down
3 changes: 3 additions & 0 deletions .sdkmanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=17.0.12-zulu
2 changes: 0 additions & 2 deletions docker-compose-pulsar.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3"

services:
standalone-pulsar:
image: apachepulsar/pulsar:2.8.1
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3"

services:
postgres:
image: postgres:15.2-alpine
Expand Down
21 changes: 12 additions & 9 deletions github-actions.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
// sbt-github-actions

// Add windows-latest when https://github.com/sbt/sbt/issues/7082 is resolved
// Add macos-latest when step to install docker on it is done
ThisBuild / githubWorkflowOSes := Seq("ubuntu-latest")
ThisBuild / githubWorkflowJavaVersions := Seq(
JavaSpec.zulu("17"),
JavaSpec.zulu("20")
)
ThisBuild / githubWorkflowTargetBranches := Seq("main")
ThisBuild / githubWorkflowTargetTags := Seq("v*")

ThisBuild / githubWorkflowBuild := Seq(
WorkflowStep.Run(
name = Some("Start containers"),
Expand Down Expand Up @@ -26,15 +37,7 @@ ThisBuild / githubWorkflowBuild := Seq(
commands = List("docker compose -f docker-compose.yml down")
)
)
// Add windows-latest when https://github.com/sbt/sbt/issues/7082 is resolved
// Add macos-latest when step to install docker on it is done
ThisBuild / githubWorkflowOSes := Seq("ubuntu-latest")
ThisBuild / githubWorkflowJavaVersions := Seq(
JavaSpec.temurin("17"),
JavaSpec.temurin("20")
)
ThisBuild / githubWorkflowTargetBranches := Seq("main")
ThisBuild / githubWorkflowTargetTags := Seq("v*")

ThisBuild / githubWorkflowPublishTargetBranches := Seq(
RefPredicate.StartsWith(Ref.Tag("v"))
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import scala.jdk.CollectionConverters.*
case class FieldRule(value: String, rules: Seq[MatchingRule])

object RuleParser {
def parseRules(inValue: Value): Either[PluginError[_], FieldRule] = parseRules(inValue.getStringValue)
def parseRules(inValue: Value): Either[PluginError[?], FieldRule] = parseRules(inValue.getStringValue)

def parseRules(inValue: StringValue): Either[PluginError[_], FieldRule] = parseRules(inValue.value)
def parseRules(inValue: StringValue): Either[PluginError[?], FieldRule] = parseRules(inValue.value)

def parseRules(in: String): Either[PluginError[_], FieldRule] = {
def parseRules(in: String): Either[PluginError[?], FieldRule] = {
fromPactResult(MatchingRuleDefinition.parseMatchingRuleDefinition(in)) match {
case Right(ok) =>
ok.getRules.asScala.toSeq
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ object Avro {
schema: Schema,
inValue: Value,
appendPath: Boolean = true
): Either[Seq[PluginError[_]], AvroValue] = {
): Either[Seq[PluginError[?]], AvroValue] = {
def valueSchema = schema.getType match {
case ARRAY => schema.getElementType
case MAP => schema.getValueType
Expand Down Expand Up @@ -94,7 +94,7 @@ object Avro {
schemaType: Schema.Type,
fieldValue: Object,
rules: Seq[MatchingRule]
): Either[PluginError[_], AvroValue] = {
): Either[PluginError[?], AvroValue] = {
fieldValue match {
case value: String => fromString(path, fieldName, schemaType, value, rules)
case _: JsonProperties.Null => Right(AvroNull(path, fieldName))
Expand Down Expand Up @@ -123,7 +123,7 @@ object Avro {
schemaType: Schema.Type,
fieldValue: String,
rules: Seq[MatchingRule]
): Either[PluginError[_], AvroValue] = {
): Either[PluginError[?], AvroValue] = {
(schemaType match {
case BOOLEAN => Right(AvroBoolean(path, fieldName, fieldValue.toLowerCase == "true", rules))
case BYTES => Right(AvroString(path, fieldName, fieldValue, rules))
Expand Down Expand Up @@ -199,7 +199,7 @@ object Avro {
}

object AvroArray {
def apply(rootPath: PactFieldPath, fieldName: AvroFieldName, schema: Schema, inValue: Value): Either[Seq[PluginError[_]], AvroArray] = {
def apply(rootPath: PactFieldPath, fieldName: AvroFieldName, schema: Schema, inValue: Value): Either[Seq[PluginError[?]], AvroArray] = {
inValue.kind match {
case Empty => Right(AvroArray(rootPath, fieldName))
case NullValue(_) => Right(AvroArray(rootPath, fieldName))
Expand Down Expand Up @@ -258,7 +258,7 @@ object Avro {
}

object AvroMap {
def apply(rootPath: PactFieldPath, fieldName: AvroFieldName, schema: Schema, inValue: Value): Either[Seq[PluginError[_]], AvroMap] = {
def apply(rootPath: PactFieldPath, fieldName: AvroFieldName, schema: Schema, inValue: Value): Either[Seq[PluginError[?]], AvroMap] = {
val path = rootPath :+ fieldName
inValue.kind match {
case Empty => Right(AvroMap(path, fieldName))
Expand Down Expand Up @@ -370,10 +370,10 @@ object Avro {

object AvroRecord {

def apply(schema: Schema, configFields: Map[String, Value]): Either[Seq[PluginError[_]], AvroRecord] =
def apply(schema: Schema, configFields: Map[String, Value]): Either[Seq[PluginError[?]], AvroRecord] =
this("$".toPactPath, ".".toFieldName, schema, configFields)

def apply(rootPath: PactFieldPath, fieldName: AvroFieldName, schema: Schema, configFields: Map[String, Value]): Either[Seq[PluginError[_]], AvroRecord] = {
def apply(rootPath: PactFieldPath, fieldName: AvroFieldName, schema: Schema, configFields: Map[String, Value]): Either[Seq[PluginError[?]], AvroRecord] = {
schema.getFields.asScala.toSeq
.map { schemaField =>
val fieldName = AvroFieldName(schemaField.name())
Expand Down Expand Up @@ -406,7 +406,7 @@ object Avro {
fieldName: AvroFieldName,
schemaField: Schema.Field,
maybeConfigValue: Option[Value]
): Either[Seq[PluginError[_]], AvroValue] =
): Either[Seq[PluginError[?]], AvroValue] =
maybeConfigValue match
case Some(configValue) => handleConfiguredField(rootPath, fieldName, schemaField.schema(), configValue)
case None => handleNoneConfiguredField(rootPath, fieldName, schemaField)
Expand All @@ -425,7 +425,7 @@ object Avro {
rootPath: PactFieldPath,
fieldName: AvroFieldName,
schemaField: Schema.Field
): Either[Seq[PluginError[_]], AvroValue] = {
): Either[Seq[PluginError[?]], AvroValue] = {
if (schemaField.hasDefaultValue) {
handleDefaultValue(rootPath, fieldName, schemaField, schemaField.schema())
} else {
Expand All @@ -438,7 +438,7 @@ object Avro {
fieldName: AvroFieldName,
schemaField: Schema.Field,
schema: Schema
): Either[Seq[PluginError[_]], AvroValue] =
): Either[Seq[PluginError[?]], AvroValue] =
Option(schemaField.defaultVal()) match
case Some(value) => AvroValue(rootPath :+ fieldName, fieldName, schema.getType, value, Seq.empty).left.map(e => Seq(e))
case None => handleNullField(rootPath, fieldName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class PactAvroPluginService extends PactPlugin with StrictLogging {
case None => Left(PluginErrorMessage(errorMsg))
}

private def getAvroSchema(configuration: Struct): Either[PluginError[_], Schema] = {
private def getAvroSchema(configuration: Struct): Either[PluginError[?], Schema] = {
getConfigStringValue(
configuration.fields,
"pact:avro",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import scala.jdk.CollectionConverters.*

object AvroContentMatcher extends StrictLogging {

def compare(expected: GenericRecord, actual: GenericRecord, context: MatchingContext): Either[Seq[PluginError[_]], BodyMatchResult] =
def compare(expected: GenericRecord, actual: GenericRecord, context: MatchingContext): Either[Seq[PluginError[?]], BodyMatchResult] =
expected.compare(List("$"), actual)(context).map { result =>
new BodyMatchResult(null, result.asJava)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object CompareContentsResponseBuilder extends StrictLogging {

private val ContentTypeRegex: Regex = raw"(\w+/\*?\+?\w+);\s*record=(\w+)".r

def build(request: CompareContentsRequest, avroSchema: Schema): Either[PluginError[_], CompareContentsResponse] = {
def build(request: CompareContentsRequest, avroSchema: Schema): Either[PluginError[?], CompareContentsResponse] = {
for {
actualBody <- getBody(request.actual, "Actual body required")
expectedBody <- getBody(request.expected, "Expected body required")
Expand Down Expand Up @@ -54,7 +54,7 @@ object CompareContentsResponseBuilder extends StrictLogging {
request: CompareContentsRequest,
actual: GenericRecord,
expected: GenericRecord
): Either[PluginError[_], CompareContentsResponse] = {
): Either[PluginError[?], CompareContentsResponse] = {
val matchingContext = buildMatchingContext(request)
AvroContentMatcher.compare(expected, actual, matchingContext).map { bodyMatchResult =>
CompareContentsResponse(
Expand Down Expand Up @@ -108,8 +108,8 @@ object CompareContentsResponseBuilder extends StrictLogging {
)
}

private def extractRecordName(actual: Body, expected: Body): Either[PluginError[_], String] = {
def extract(body: Body, name: String): Either[PluginError[_], String] = {
private def extractRecordName(actual: Body, expected: Body): Either[PluginError[?], String] = {
def extract(body: Body, name: String): Either[PluginError[?], String] = {
body.contentType match {
case ContentTypeRegex(contentType, recordName) =>
Either.cond(
Expand All @@ -134,7 +134,7 @@ object CompareContentsResponseBuilder extends StrictLogging {
}
}

private def getBody(body: Option[Body], msg: String): Either[PluginError[_], Body] = {
private def getBody(body: Option[Body], msg: String): Either[PluginError[?], Body] = {
Either.cond(
body.isDefined,
body.get,
Expand Down
Loading

0 comments on commit abc10e8

Please sign in to comment.