diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6fe99b1..7c412c5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,19 +27,19 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - uses: gradle/wrapper-validation-action@88425854a36845f9c881450d9660b5fd46bee142 # v3.4.2 + - uses: gradle/wrapper-validation-action@f9c9c575b8b21b6485636a91ffecd10e558c62f6 # v3.5.0 - name: Fetch version history # Do NOT want to fetch all tags if building a specific tag. # Doing so could result in code published with wrong version, if newer tags have been pushed if: (!startsWith(github.ref, 'refs/tags/')) run: git fetch --tag --unshallow - name: Set up JDK - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 + uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2 with: java-version: '17' distribution: 'adopt' - name: Setup Gradle - uses: gradle/gradle-build-action@3b1b3b9a2104c2b47fbae53f3938079c00c9bb87 # v3.0.0 + uses: gradle/gradle-build-action@ac2d340dc04d9e1113182899e983b5400c17cda1 # v3.5.0 with: gradle-home-cache-cleanup: true - name: Build @@ -72,14 +72,14 @@ jobs: runs-on: windows-latest steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - uses: gradle/wrapper-validation-action@88425854a36845f9c881450d9660b5fd46bee142 # v3.4.2 + - uses: gradle/wrapper-validation-action@f9c9c575b8b21b6485636a91ffecd10e558c62f6 # v3.5.0 - name: Set up JDK - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 + uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2 with: java-version: '17' distribution: 'adopt' - name: Setup Gradle - uses: gradle/gradle-build-action@3b1b3b9a2104c2b47fbae53f3938079c00c9bb87 # v3.0.0 + uses: gradle/gradle-build-action@ac2d340dc04d9e1113182899e983b5400c17cda1 # v3.5.0 with: gradle-home-cache-cleanup: true - name: Build @@ -94,6 +94,6 @@ jobs: steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v3.0.0 - name: Create GitHut Release - uses: softprops/action-gh-release@a74c6b72af54cfa997e81df42d94703d6313a2d0 # v0.1.15 + uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v0.1.15 with: generate_release_notes: true \ No newline at end of file diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml index 8aa3689..7d1c233 100644 --- a/.github/workflows/dependabot-auto-merge.yml +++ b/.github/workflows/dependabot-auto-merge.yml @@ -18,7 +18,7 @@ jobs: steps: - name: Dependabot metadata id: metadata - uses: dependabot/fetch-metadata@5e5f99653a5b510e8555840e80cbf1514ad4af38 # v2.1.0 + uses: dependabot/fetch-metadata@dbb049abf0d677abbd7f7eee0375145b417fdd34 # v2.2.0 with: github-token: "${{ secrets.GITHUB_TOKEN }}" - name: Approve PR diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index afecd1a..da350ee 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -24,12 +24,12 @@ jobs: steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up JDK - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 + uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2 with: java-version: '17' distribution: 'adopt' - name: Setup Gradle - uses: gradle/gradle-build-action@3b1b3b9a2104c2b47fbae53f3938079c00c9bb87 # v3.0.0 + uses: gradle/gradle-build-action@ac2d340dc04d9e1113182899e983b5400c17cda1 # v3.5.0 with: gradle-home-cache-cleanup: true - name: Extract implementation info @@ -37,7 +37,7 @@ jobs: - name: Add results to step summary run: cat docs/_includes/implementations.json >> $GITHUB_STEP_SUMMARY - name: Upload Implementations - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: implementations path: docs/_includes/* @@ -47,12 +47,12 @@ jobs: steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up JDK - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 + uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2 with: java-version: '17' distribution: 'adopt' - name: Setup Gradle - uses: gradle/gradle-build-action@3b1b3b9a2104c2b47fbae53f3938079c00c9bb87 # v3.0.0 + uses: gradle/gradle-build-action@ac2d340dc04d9e1113182899e983b5400c17cda1 # v3.5.0 with: gradle-home-cache-cleanup: true - name: Run functional tests @@ -64,7 +64,7 @@ jobs: echo "# Specific Draft & Implementation results" >> $GITHUB_STEP_SUMMARY cat docs/_includes/per-draft.md >> $GITHUB_STEP_SUMMARY - name: Upload Implementations - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: functional path: docs/_includes/* @@ -74,12 +74,12 @@ jobs: steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up JDK - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 + uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2 with: java-version: '17' distribution: 'adopt' - name: Setup Gradle - uses: gradle/gradle-build-action@3b1b3b9a2104c2b47fbae53f3938079c00c9bb87 # v3.0.0 + uses: gradle/gradle-build-action@ac2d340dc04d9e1113182899e983b5400c17cda1 # v3.5.0 with: gradle-home-cache-cleanup: true - if: github.event_name == 'pull_request' @@ -93,7 +93,7 @@ jobs: echo "# Json Validator Benchmark Results" >> $GITHUB_STEP_SUMMARY cat docs/_includes/JsonValidateBenchmark.md >> $GITHUB_STEP_SUMMARY - name: Upload Implementations - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: validateBenchmark path: docs/_includes/* @@ -103,12 +103,12 @@ jobs: steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up JDK - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 + uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2 with: java-version: '17' distribution: 'adopt' - name: Setup Gradle - uses: gradle/gradle-build-action@3b1b3b9a2104c2b47fbae53f3938079c00c9bb87 # v3.0.0 + uses: gradle/gradle-build-action@ac2d340dc04d9e1113182899e983b5400c17cda1 # v3.5.0 with: gradle-home-cache-cleanup: true - if: github.event_name == 'pull_request' @@ -122,7 +122,7 @@ jobs: echo "# Json Serde Benchmark Results" >> $GITHUB_STEP_SUMMARY cat docs/_includes/JsonSerdeBenchmark.md >> $GITHUB_STEP_SUMMARY - name: Upload Implementations - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: serdeBenchmark path: docs/_includes/* @@ -138,7 +138,7 @@ jobs: with: fetch-depth: 0 # need full history to get page last modified times - name: Setup Ruby - uses: ruby/setup-ruby@1d0e911f615a112e322369596f10ee0b95b010ae # v1.183.0 + uses: ruby/setup-ruby@c04af2bb7258bb6a03df1d3c1865998ac9390972 # v1.194.0 with: ruby-version: '3.1' bundler-cache: true # runs 'bundle install' and caches installed gems automatically @@ -147,22 +147,22 @@ jobs: id: pages uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0 - name: Download implementations - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: implementations path: docs/_includes - name: Download functional results - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: functional path: docs/_includes - name: Download validate benchmark results - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: validateBenchmark path: docs/_includes - name: Download serde benchmark results - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: serdeBenchmark path: docs/_includes diff --git a/build.gradle.kts b/build.gradle.kts index b813495..5588a35 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -32,12 +32,12 @@ repositories { } val creekVersion = "0.4.2-SNAPSHOT" -val junitVersion = "5.10.3" +val junitVersion = "5.11.1" val junitPioneerVersion = "2.2.0" -val mockitoVersion = "5.12.0" +val mockitoVersion = "5.14.1" val jmhVersion = "1.37" -val confluentVersion = "7.6.1" -val vertxVersion = "4.5.8" +val confluentVersion = "7.7.1" +val vertxVersion = "4.5.10" dependencies { implementation("org.openjdk.jmh:jmh-core:$jmhVersion") @@ -53,7 +53,7 @@ dependencies { implementation("com.github.erosb:everit-json-schema:1.14.4") - implementation("com.github.erosb:json-sKema:0.15.0") + implementation("com.github.erosb:json-sKema:0.18.0") implementation("io.confluent:kafka-streams-json-schema-serde:$confluentVersion") implementation("io.confluent:kafka-schema-registry-client:$confluentVersion") @@ -63,17 +63,17 @@ dependencies { implementation("net.jimblackler.jsonschemafriend:core:0.12.4") - implementation("com.networknt:json-schema-validator:1.4.3") + implementation("com.networknt:json-schema-validator:1.5.2") implementation("com.qindesign:snowy-json:0.16.0") runtimeOnly("org.glassfish:jakarta.json:2.0.0:module") implementation("org.leadpony.justify:justify:3.1.0") - implementation("dev.harrel:json-schema:1.6.1") + implementation("dev.harrel:json-schema:1.7.1") implementation("com.sanctionco.jmail:jmail:1.6.3") // dev.harrel format validation - runtimeOnly("org.slf4j:slf4j-nop:2.0.13") + runtimeOnly("org.slf4j:slf4j-nop:2.0.16") testImplementation("org.creekservice:creek-test-hamcrest:$creekVersion") testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion") diff --git a/src/main/java/org/creekservice/kafka/test/perf/implementations/DevHarrelImplementation.java b/src/main/java/org/creekservice/kafka/test/perf/implementations/DevHarrelImplementation.java index db8a764..fb0c2fa 100644 --- a/src/main/java/org/creekservice/kafka/test/perf/implementations/DevHarrelImplementation.java +++ b/src/main/java/org/creekservice/kafka/test/perf/implementations/DevHarrelImplementation.java @@ -16,17 +16,18 @@ package org.creekservice.kafka.test.perf.implementations; +import static org.creekservice.kafka.test.perf.testsuite.SchemaSpec.DRAFT_07; import static org.creekservice.kafka.test.perf.testsuite.SchemaSpec.DRAFT_2019_09; import static org.creekservice.kafka.test.perf.testsuite.SchemaSpec.DRAFT_2020_12; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.json.JsonMapper; +import dev.harrel.jsonschema.Dialect; import dev.harrel.jsonschema.Dialects; import dev.harrel.jsonschema.FormatEvaluatorFactory; import dev.harrel.jsonschema.JsonNode; import dev.harrel.jsonschema.SchemaResolver; -import dev.harrel.jsonschema.SpecificationVersion; import dev.harrel.jsonschema.Validator; import dev.harrel.jsonschema.ValidatorFactory; import dev.harrel.jsonschema.providers.JacksonNode; @@ -34,7 +35,6 @@ import java.io.IOException; import java.net.URI; import java.util.Map; -import java.util.Set; import java.util.stream.Collectors; import org.creekservice.kafka.test.perf.model.TestModel; import org.creekservice.kafka.test.perf.testsuite.AdditionalSchemas; @@ -42,6 +42,11 @@ @SuppressWarnings("FieldMayBeFinal") // not final to avoid folding. public class DevHarrelImplementation implements Implementation { + private static final Map SUPPORTED = + Map.of( + DRAFT_07, new Dialects.Draft7Dialect(), + DRAFT_2019_09, new Dialects.Draft2019Dialect(), + DRAFT_2020_12, new Dialects.Draft2020Dialect()); private static final MetaData METADATA = new MetaData( @@ -49,7 +54,7 @@ public class DevHarrelImplementation implements Implementation { "DevHarrel", Language.Java, Licence.MIT, - Set.of(DRAFT_2020_12, DRAFT_2019_09), + SUPPORTED.keySet(), "https://github.com/harrel56/json-schema", new Color(22, 99, 0), dev.harrel.jsonschema.ValidatorFactory.class, @@ -133,37 +138,21 @@ private Validator validator( } return SchemaResolver.Result.empty(); }; - switch (spec) { - case DRAFT_2020_12: - final ValidatorFactory validatorFactory2020 = - new ValidatorFactory() - .withDisabledSchemaValidation(true) - .withDialect(new Dialects.Draft2020Dialect()) - .withJsonNodeFactory(nodeFactory) - .withSchemaResolver(resolver); - if (enableFormatAssertions) { - validatorFactory2020.withEvaluatorFactory(new FormatEvaluatorFactory()); - } - final Validator validator2020 = validatorFactory2020.createValidator(); - /* Validate against meta-schema in order to parse it eagerly */ - validator2020.validate(URI.create(SpecificationVersion.DRAFT2020_12.getId()), "{}"); - return validator2020; - case DRAFT_2019_09: - final ValidatorFactory validatorFactory2019 = - new ValidatorFactory() - .withDisabledSchemaValidation(true) - .withDialect(new Dialects.Draft2019Dialect()) - .withJsonNodeFactory(nodeFactory) - .withSchemaResolver(resolver); - if (enableFormatAssertions) { - validatorFactory2019.withEvaluatorFactory(new FormatEvaluatorFactory()); - } - final Validator validator2019 = validatorFactory2019.createValidator(); - /* Validate against meta-schema in order to parse it eagerly */ - validator2019.validate(URI.create(SpecificationVersion.DRAFT2019_09.getId()), "{}"); - return validator2019; - default: - throw new RuntimeException("Unsupported Spec:" + spec); + final Dialect dialect = SUPPORTED.get(spec); + if (dialect == null) { + throw new RuntimeException("Unsupported Spec:" + spec); + } + final ValidatorFactory validatorFactory = + new ValidatorFactory() + .withDefaultDialect(dialect) + .withJsonNodeFactory(nodeFactory) + .withSchemaResolver(resolver); + if (enableFormatAssertions) { + validatorFactory.withEvaluatorFactory(new FormatEvaluatorFactory()); } + final Validator validator = validatorFactory.createValidator(); + /* Validate against meta-schema in order to parse it eagerly */ + validator.validate(spec.uri(), "{}"); + return validator; } } diff --git a/src/main/java/org/creekservice/kafka/test/perf/performance/JsonSerdeBenchmark.java b/src/main/java/org/creekservice/kafka/test/perf/performance/JsonSerdeBenchmark.java index 846dc91..4401dba 100644 --- a/src/main/java/org/creekservice/kafka/test/perf/performance/JsonSerdeBenchmark.java +++ b/src/main/java/org/creekservice/kafka/test/perf/performance/JsonSerdeBenchmark.java @@ -200,6 +200,11 @@ public DevHarrelState() { } } + @Benchmark + public TestModel measureDraft_07_DevHarrel(final DevHarrelState impl, final ModelState model) { + return impl.roundTrip(model, SchemaSpec.DRAFT_07); + } + @Benchmark public TestModel measureDraft_2020_12_DevHarrel( final DevHarrelState impl, final ModelState model) { diff --git a/src/main/java/org/creekservice/kafka/test/perf/performance/JsonValidateBenchmark.java b/src/main/java/org/creekservice/kafka/test/perf/performance/JsonValidateBenchmark.java index c12700c..7deb9d1 100644 --- a/src/main/java/org/creekservice/kafka/test/perf/performance/JsonValidateBenchmark.java +++ b/src/main/java/org/creekservice/kafka/test/perf/performance/JsonValidateBenchmark.java @@ -274,6 +274,11 @@ public DevHarrelValidator() { } } + @Benchmark + public Result measureDraft_07_DevHarrel(final DevHarrelValidator validator) { + return validator.validate(SchemaSpec.DRAFT_07); + } + @Benchmark public Result measureDraft_2019_09_DevHarrel(final DevHarrelValidator validator) { return validator.validate(SchemaSpec.DRAFT_2019_09);