From 9ee9b804c785fb1f47ddfde3705cd9b2f975fea6 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Wed, 4 Sep 2024 00:08:57 +0300 Subject: [PATCH 01/62] chore: test --- .github/workflows/selfserve-service-mock.yaml | 73 +++++++++++++++++++ .github/workflows/test.yaml | 9 +++ .../sdk/test/contract/extension/File.kt | 13 +--- .../templates/expediagroup-sdk/main.mustache | 2 +- .../templates/expediagroup-sdk/pom.mustache | 9 ++- 5 files changed, 94 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/selfserve-service-mock.yaml create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/selfserve-service-mock.yaml b/.github/workflows/selfserve-service-mock.yaml new file mode 100644 index 000000000..3850c431f --- /dev/null +++ b/.github/workflows/selfserve-service-mock.yaml @@ -0,0 +1,73 @@ +name: PR Check Tests Run +on: + workflow_call: + inputs: + repository: + description: 'Repository to checkout' + type: string + required: true + ref: + description: 'Branch or tag to checkout' + type: string + required: true + specs_path: + description: 'Path of the artifact to persist to' + type: string + default: '' + +jobs: + upload-specs: + uses: ./.github/workflows/selfserve-checkout-and-upload.yaml + with: + repository: ${{ inputs.repository }} + ref: "${{ github.head_ref || github.ref_name }}" + artifact_key: 'specs' + artifact_path: ${{ inputs.specs_path }} + mock: + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v4 + with: + name: specs + path: specs + - name: Download Latest Specmatic Executable + working-directory: specs + run: | + curl -s https://api.github.com/repos/znsio/specmatic/releases/latest \ + | grep "browser_download_url.*specmatic.jar" \ + | cut -d : -f 2,3 \ + | tr -d \" \ + | xargs curl -L -o specmatic.jar + - uses: actions/setup-node@v4 + with: + node-version: 18.18.2 + - uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'corretto' + - name: Parse Specs + working-directory: specs + run: | + spec=$(find . -maxdepth 1 -type f \( -name "*.yaml" -o -name "*.yml" \) | head -n 1) + + if [ ! -f $spec ]; then + echo "Specs not found!" + fi + + echo "spec=$spec" >> $GITHUB_ENV + - name: Transform Specs + working-directory: specs + run: npx --yes -p @expediagroup/spec-transformer cli -i ${{ env.spec }} -o ${{ env.spec }} -to + - name: Run Mock Server + working-directory: specs + run: java -jar specmatic.jar stub ${{ env.spec }} --port 8080 & disown + - name: Wait for Mock Server to Start + run: sleep 10 + - name: Verify Server is Running + run: | + status=$(curl --write-out '%{http_code}' --silent --output /dev/null http://localhost:8080/$(uuidgen)) + if [ $status -e 000 ]; then + echo "Server not running!" + exit 1 + fi + diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 000000000..b9daf8f42 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,9 @@ +on: push +jobs: + main: + uses: ./.github/workflows/selfserve-service-mock.yaml + with: + repository: ${{ github.repository }} + ref: "${{ github.head_ref || github.ref_name }}" + specs_path: 'release/rapid/src/specs.yaml' + diff --git a/sdk-test/src/main/kotlin/com/expediagroup/sdk/test/contract/extension/File.kt b/sdk-test/src/main/kotlin/com/expediagroup/sdk/test/contract/extension/File.kt index 41332b001..fee15a151 100644 --- a/sdk-test/src/main/kotlin/com/expediagroup/sdk/test/contract/extension/File.kt +++ b/sdk-test/src/main/kotlin/com/expediagroup/sdk/test/contract/extension/File.kt @@ -15,14 +15,8 @@ */ package com.expediagroup.sdk.test.contract.extension -import io.specmatic.conversions.EnvironmentAndPropertiesConfiguration import io.specmatic.conversions.OpenApiSpecification -import io.specmatic.core.Feature -import io.specmatic.core.Hook -import io.specmatic.core.OPENAPI_FILE_EXTENSIONS -import io.specmatic.core.PassThroughHook -import io.specmatic.core.SecurityConfiguration -import io.specmatic.core.unsupportedFileExtensionContractException +import io.specmatic.core.* import java.io.File /** @@ -34,7 +28,6 @@ import java.io.File * @param sourceRepositoryBranch optional branch of source repository. * @param specificationPath optional path to the specification file. * @param securityConfiguration optional security configuration. - * @param environmentAndPropertiesConfiguration configuration for environment and properties, default is EnvironmentAndPropertiesConfiguration. * @throws unsupportedFileExtensionContractException if the file extension is not supported. * @return converted Feature object. */ @@ -45,7 +38,7 @@ fun File.toSpecmaticFeature( sourceRepositoryBranch: String? = null, specificationPath: String? = null, securityConfiguration: SecurityConfiguration? = null, - environmentAndPropertiesConfiguration: EnvironmentAndPropertiesConfiguration = EnvironmentAndPropertiesConfiguration() + specmaticConfig: SpecmaticConfig = SpecmaticConfig() ): Feature = when (extension) { in OPENAPI_FILE_EXTENSIONS -> @@ -57,7 +50,7 @@ fun File.toSpecmaticFeature( sourceRepositoryBranch = sourceRepositoryBranch, specificationPath = specificationPath, securityConfiguration = securityConfiguration, - environmentAndPropertiesConfiguration = environmentAndPropertiesConfiguration + specmaticConfig = specmaticConfig ).toFeature() else -> throw unsupportedFileExtensionContractException(path, extension) diff --git a/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache b/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache index c8520bd6a..98f7216c3 100644 --- a/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache +++ b/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache @@ -27,4 +27,4 @@ class Main { } } } -} +} \ No newline at end of file diff --git a/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache b/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache index 6bec061b9..fa53e7dbc 100644 --- a/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache +++ b/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache @@ -7,6 +7,12 @@ Rapid Java SDK Tests Expedia Group Rapid Java SDK Tests + + org.springframework.boot + spring-boot-starter-parent + 3.3.3 + + 1.8 1.8 @@ -104,7 +110,8 @@ maven-compiler-plugin 3.8.1 - 1.8 + + 1.8 1.8 From 2b8aa78f27b1626fe8ebb7d3eb103d46630bb08e Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Wed, 4 Sep 2024 00:10:32 +0300 Subject: [PATCH 02/62] chore: test --- .github/workflows/selfserve-service-mock.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/selfserve-service-mock.yaml b/.github/workflows/selfserve-service-mock.yaml index 3850c431f..a189060c1 100644 --- a/.github/workflows/selfserve-service-mock.yaml +++ b/.github/workflows/selfserve-service-mock.yaml @@ -24,6 +24,7 @@ jobs: artifact_key: 'specs' artifact_path: ${{ inputs.specs_path }} mock: + needs: [ upload-specs ] runs-on: ubuntu-latest steps: - uses: actions/download-artifact@v4 From 68ff4a7c27142ee2c05f4d82654fa664638df53e Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Wed, 4 Sep 2024 00:15:31 +0300 Subject: [PATCH 03/62] chore: test --- .github/workflows/selfserve-service-mock.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/selfserve-service-mock.yaml b/.github/workflows/selfserve-service-mock.yaml index a189060c1..16a547f49 100644 --- a/.github/workflows/selfserve-service-mock.yaml +++ b/.github/workflows/selfserve-service-mock.yaml @@ -67,7 +67,7 @@ jobs: - name: Verify Server is Running run: | status=$(curl --write-out '%{http_code}' --silent --output /dev/null http://localhost:8080/$(uuidgen)) - if [ $status -e 000 ]; then + if [ $status -ne 400 ]; then echo "Server not running!" exit 1 fi From ec318f283f7c3cfe60a9c96e207356ae5f8b9290 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Wed, 4 Sep 2024 00:16:59 +0300 Subject: [PATCH 04/62] chore: test --- .github/workflows/selfserve-service-mock.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/selfserve-service-mock.yaml b/.github/workflows/selfserve-service-mock.yaml index 16a547f49..2da58f9dc 100644 --- a/.github/workflows/selfserve-service-mock.yaml +++ b/.github/workflows/selfserve-service-mock.yaml @@ -67,6 +67,7 @@ jobs: - name: Verify Server is Running run: | status=$(curl --write-out '%{http_code}' --silent --output /dev/null http://localhost:8080/$(uuidgen)) + echo "Server status: $status" if [ $status -ne 400 ]; then echo "Server not running!" exit 1 From 0d312c0e3708dc3f70f0c2b1d0163c752dd9b440 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Wed, 4 Sep 2024 00:19:08 +0300 Subject: [PATCH 05/62] chore: test --- .github/workflows/selfserve-service-mock.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/selfserve-service-mock.yaml b/.github/workflows/selfserve-service-mock.yaml index 2da58f9dc..a918d13d9 100644 --- a/.github/workflows/selfserve-service-mock.yaml +++ b/.github/workflows/selfserve-service-mock.yaml @@ -61,7 +61,7 @@ jobs: run: npx --yes -p @expediagroup/spec-transformer cli -i ${{ env.spec }} -o ${{ env.spec }} -to - name: Run Mock Server working-directory: specs - run: java -jar specmatic.jar stub ${{ env.spec }} --port 8080 & disown + run: java -jar specmatic.jar stub ${{ env.spec }} --port 8090 & disown - name: Wait for Mock Server to Start run: sleep 10 - name: Verify Server is Running From 19d6bf6e6ffaab7f3997be8f36f975ba1188cdb5 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Wed, 4 Sep 2024 00:24:18 +0300 Subject: [PATCH 06/62] chore: test --- .github/workflows/selfserve-service-mock.yaml | 2 +- .../sdk/test/contract/extension/File.kt | 13 ++++++++++--- .../templates/expediagroup-sdk/main.mustache | 2 +- .../templates/expediagroup-sdk/pom.mustache | 11 ++--------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/selfserve-service-mock.yaml b/.github/workflows/selfserve-service-mock.yaml index a918d13d9..2da58f9dc 100644 --- a/.github/workflows/selfserve-service-mock.yaml +++ b/.github/workflows/selfserve-service-mock.yaml @@ -61,7 +61,7 @@ jobs: run: npx --yes -p @expediagroup/spec-transformer cli -i ${{ env.spec }} -o ${{ env.spec }} -to - name: Run Mock Server working-directory: specs - run: java -jar specmatic.jar stub ${{ env.spec }} --port 8090 & disown + run: java -jar specmatic.jar stub ${{ env.spec }} --port 8080 & disown - name: Wait for Mock Server to Start run: sleep 10 - name: Verify Server is Running diff --git a/sdk-test/src/main/kotlin/com/expediagroup/sdk/test/contract/extension/File.kt b/sdk-test/src/main/kotlin/com/expediagroup/sdk/test/contract/extension/File.kt index fee15a151..41332b001 100644 --- a/sdk-test/src/main/kotlin/com/expediagroup/sdk/test/contract/extension/File.kt +++ b/sdk-test/src/main/kotlin/com/expediagroup/sdk/test/contract/extension/File.kt @@ -15,8 +15,14 @@ */ package com.expediagroup.sdk.test.contract.extension +import io.specmatic.conversions.EnvironmentAndPropertiesConfiguration import io.specmatic.conversions.OpenApiSpecification -import io.specmatic.core.* +import io.specmatic.core.Feature +import io.specmatic.core.Hook +import io.specmatic.core.OPENAPI_FILE_EXTENSIONS +import io.specmatic.core.PassThroughHook +import io.specmatic.core.SecurityConfiguration +import io.specmatic.core.unsupportedFileExtensionContractException import java.io.File /** @@ -28,6 +34,7 @@ import java.io.File * @param sourceRepositoryBranch optional branch of source repository. * @param specificationPath optional path to the specification file. * @param securityConfiguration optional security configuration. + * @param environmentAndPropertiesConfiguration configuration for environment and properties, default is EnvironmentAndPropertiesConfiguration. * @throws unsupportedFileExtensionContractException if the file extension is not supported. * @return converted Feature object. */ @@ -38,7 +45,7 @@ fun File.toSpecmaticFeature( sourceRepositoryBranch: String? = null, specificationPath: String? = null, securityConfiguration: SecurityConfiguration? = null, - specmaticConfig: SpecmaticConfig = SpecmaticConfig() + environmentAndPropertiesConfiguration: EnvironmentAndPropertiesConfiguration = EnvironmentAndPropertiesConfiguration() ): Feature = when (extension) { in OPENAPI_FILE_EXTENSIONS -> @@ -50,7 +57,7 @@ fun File.toSpecmaticFeature( sourceRepositoryBranch = sourceRepositoryBranch, specificationPath = specificationPath, securityConfiguration = securityConfiguration, - specmaticConfig = specmaticConfig + environmentAndPropertiesConfiguration = environmentAndPropertiesConfiguration ).toFeature() else -> throw unsupportedFileExtensionContractException(path, extension) diff --git a/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache b/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache index 98f7216c3..c8520bd6a 100644 --- a/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache +++ b/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache @@ -27,4 +27,4 @@ class Main { } } } -} \ No newline at end of file +} diff --git a/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache b/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache index fa53e7dbc..886a97100 100644 --- a/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache +++ b/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache @@ -7,12 +7,6 @@ Rapid Java SDK Tests Expedia Group Rapid Java SDK Tests - - org.springframework.boot - spring-boot-starter-parent - 3.3.3 - - 1.8 1.8 @@ -110,8 +104,7 @@ maven-compiler-plugin 3.8.1 - - 1.8 + 1.8 1.8 @@ -146,4 +139,4 @@ - + \ No newline at end of file From 58e7fb49386fdcaa3f645797815771f801a3167c Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Wed, 4 Sep 2024 00:24:47 +0300 Subject: [PATCH 07/62] chore: test --- .../src/main/resources/templates/expediagroup-sdk/pom.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache b/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache index 886a97100..6bec061b9 100644 --- a/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache +++ b/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache @@ -139,4 +139,4 @@ - \ No newline at end of file + From 1c151a6ebbdd301fe1ceef9717b8dc53e2632d34 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Wed, 4 Sep 2024 00:25:16 +0300 Subject: [PATCH 08/62] chore: test --- .github/workflows/test.yaml | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml deleted file mode 100644 index b9daf8f42..000000000 --- a/.github/workflows/test.yaml +++ /dev/null @@ -1,9 +0,0 @@ -on: push -jobs: - main: - uses: ./.github/workflows/selfserve-service-mock.yaml - with: - repository: ${{ github.repository }} - ref: "${{ github.head_ref || github.ref_name }}" - specs_path: 'release/rapid/src/specs.yaml' - From 459cff5629580893ed7757dc264d99513f032b38 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Sun, 29 Sep 2024 12:52:26 +0300 Subject: [PATCH 09/62] chore: add workflow to generate and upload contract test sources This new workflow defines steps to download required artifacts, generate test sources using Maven, and upload the generated sources. Inputs for artifact keys, product namespace, and generation options are configurable, ensuring flexibility in different scenarios. --- ...fserve-generate-contract-test-sources.yaml | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/selfserve-generate-contract-test-sources.yaml diff --git a/.github/workflows/selfserve-generate-contract-test-sources.yaml b/.github/workflows/selfserve-generate-contract-test-sources.yaml new file mode 100644 index 000000000..3a5853d4e --- /dev/null +++ b/.github/workflows/selfserve-generate-contract-test-sources.yaml @@ -0,0 +1,59 @@ +name: Generate & Upload Tests Sources + +on: + workflow_call: + inputs: + artifact_key: + description: 'Generated output artifact key' + type: string + required: true + repo_key: + description: 'SDK repository artifact key' + type: string + templates_key: + description: 'Templates artifact key' + type: string + required: true + specs_key: + description: 'Specs artifact key' + type: string + required: true + namespace: + description: 'Namespace of the product' + type: string + required: true + generation_options: + description: 'Options to pass to the generator. Includes `--version` and `--max-test-combinations`' + type: string + required: true + +jobs: + generate-and-upload: + runs-on: ubuntu-latest + steps: + - name: Download Repository + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.repo_key }} + path: sdk-repo + + - name: Download Templates + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.templates_key }} + path: templates + + - name: Download Specs + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.specs_key }} + path: specs.yaml + + - name: Generate Test Sources + run: mvn -f sdk-repo/sdk-test clean install exec:java -Dexec.args="--input-spec specs.yaml --templates-dir templates --namespace ${{ inputs.namespace }} ${{ inputs.generation_options }}" + + - name: Upload Generated Sources + uses: actions/upload-artifact@v4 + with: + path: sdk-repo/sdk-test/target/sdk/*-sdk-test/ + name: ${{ inputs.artifact_key }} From c4a2f73d7fccea10fb6fef795870040ed26ee51b Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Sun, 29 Sep 2024 14:02:29 +0300 Subject: [PATCH 10/62] chore: remove old workflow and add updated mock tests workflow Deleted `selfserve-service-mock.yaml` workflow file and replaced it with a more detailed `selfserve-run-mocked-service-tests.yaml` workflow for running mocked service tests. Updated artifact and SDK configurations in run-tests and template files for consistency. --- .github/workflows/run-tests.yaml | 2 +- .../selfserve-run-mocked-service-tests.yaml | 76 +++++++++++++++++++ .github/workflows/selfserve-service-mock.yaml | 75 ------------------ .../templates/expediagroup-sdk/pom.mustache | 7 +- 4 files changed, 81 insertions(+), 79 deletions(-) create mode 100644 .github/workflows/selfserve-run-mocked-service-tests.yaml delete mode 100644 .github/workflows/selfserve-service-mock.yaml diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index 7633198c4..5965d910e 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -42,7 +42,7 @@ on: workflow_call: inputs: source: - description: 'Source of tests' + description: 'Source of tests. Can be `sdk` or `specs`' required: true type: string default: 'sdk' diff --git a/.github/workflows/selfserve-run-mocked-service-tests.yaml b/.github/workflows/selfserve-run-mocked-service-tests.yaml new file mode 100644 index 000000000..13f98c8d8 --- /dev/null +++ b/.github/workflows/selfserve-run-mocked-service-tests.yaml @@ -0,0 +1,76 @@ +name: SelfServe Run Service Mocked Tests +on: + workflow_call: + inputs: + specs_key: + description: 'Specs artifact key. Defaults to `specs`' + type: string + default: 'specs' + required: true + test_sources_key: + description: 'Test sources artifact key. Defaults to `sdk-test`' + type: string + default: 'sdk-test' + required: true + sdk_artifact_id: + description: 'SDK artifactId' + type: string + required: true + sdk_version: + description: 'SDK version' + type: string + required: true + sdk_key: + description: 'SDK artifact key to download' + type: string + required: false + default: '' + jdk: + description: 'JDK version to use' + type: string + default: '21' + +jobs: + main: + runs-on: ubuntu-latest + steps: + - uses: actions/setup-java@v4 + with: + java-version: ${{ inputs.jdk }} + distribution: 'corretto' + - name: Download Specs + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.specs_key }} + path: specs/specs.yaml + - name: Download Test Sources Artifact + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.test_sources_key }} + path: test + - name: Download SDK Artifact + if: inputs.sdk_artifact_key != '' + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.sdk_artifact_id }} + path: sdk + - name: Install SDK into Local Repository + if: inputs.sdk_artifact_key != '' + working-directory: sdk + run: mvn clean install + - name: Download Latest Specmatic Executable + working-directory: specs/specs.yaml + run: | + curl -s https://api.github.com/repos/znsio/specmatic/releases/latest \ + | grep "browser_download_url.*specmatic.jar" \ + | cut -d : -f 2,3 \ + | tr -d \" \ + | xargs curl -L -o specmatic.jar + - name: Run Mock Server + working-directory: specs + run: java -jar specmatic.jar stub specs.yaml --port 8080 & disown + - name: Wait for Mock Server to Start + run: sleep 10 + - name: Run Tests + working-directory: test + run: mvn clean install -Dsdk.artifactId="${{ inputs.sdk_artifact_id }}" -Dsdk.version="${{ inputs.sdk_version }}" exec:java diff --git a/.github/workflows/selfserve-service-mock.yaml b/.github/workflows/selfserve-service-mock.yaml deleted file mode 100644 index 2da58f9dc..000000000 --- a/.github/workflows/selfserve-service-mock.yaml +++ /dev/null @@ -1,75 +0,0 @@ -name: PR Check Tests Run -on: - workflow_call: - inputs: - repository: - description: 'Repository to checkout' - type: string - required: true - ref: - description: 'Branch or tag to checkout' - type: string - required: true - specs_path: - description: 'Path of the artifact to persist to' - type: string - default: '' - -jobs: - upload-specs: - uses: ./.github/workflows/selfserve-checkout-and-upload.yaml - with: - repository: ${{ inputs.repository }} - ref: "${{ github.head_ref || github.ref_name }}" - artifact_key: 'specs' - artifact_path: ${{ inputs.specs_path }} - mock: - needs: [ upload-specs ] - runs-on: ubuntu-latest - steps: - - uses: actions/download-artifact@v4 - with: - name: specs - path: specs - - name: Download Latest Specmatic Executable - working-directory: specs - run: | - curl -s https://api.github.com/repos/znsio/specmatic/releases/latest \ - | grep "browser_download_url.*specmatic.jar" \ - | cut -d : -f 2,3 \ - | tr -d \" \ - | xargs curl -L -o specmatic.jar - - uses: actions/setup-node@v4 - with: - node-version: 18.18.2 - - uses: actions/setup-java@v4 - with: - java-version: '21' - distribution: 'corretto' - - name: Parse Specs - working-directory: specs - run: | - spec=$(find . -maxdepth 1 -type f \( -name "*.yaml" -o -name "*.yml" \) | head -n 1) - - if [ ! -f $spec ]; then - echo "Specs not found!" - fi - - echo "spec=$spec" >> $GITHUB_ENV - - name: Transform Specs - working-directory: specs - run: npx --yes -p @expediagroup/spec-transformer cli -i ${{ env.spec }} -o ${{ env.spec }} -to - - name: Run Mock Server - working-directory: specs - run: java -jar specmatic.jar stub ${{ env.spec }} --port 8080 & disown - - name: Wait for Mock Server to Start - run: sleep 10 - - name: Verify Server is Running - run: | - status=$(curl --write-out '%{http_code}' --silent --output /dev/null http://localhost:8080/$(uuidgen)) - echo "Server status: $status" - if [ $status -ne 400 ]; then - echo "Server not running!" - exit 1 - fi - diff --git a/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache b/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache index 6bec061b9..619117a85 100644 --- a/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache +++ b/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache @@ -11,7 +11,8 @@ 1.8 1.8 1.8 - 4.3.0 + rapid-java + LATEST 2.17.2 3.2.0 @@ -48,8 +49,8 @@ com.expediagroup - rapid-sdk - ${rapid-java-sdk.sdk.version} + ${sdk.artifactId} + ${sdk.version} From e9744d1df886e82d9b2188b67067332258c56b92 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Sun, 29 Sep 2024 15:32:27 +0300 Subject: [PATCH 11/62] chore: refactor workflows to consolidate spec handling and SDK generation This commit consolidates various steps for downloading, transforming, and uploading specs into more streamlined workflows. New steps for generating contract tests and running example tests have been added, targeting the 'rapid' namespace. Additionally, template files have been updated to use consistent property keys for SDK configurations. --- .github/workflows/generator-test-sdk.yaml | 29 -------- .github/workflows/run-tests.yaml | 66 +++++++++++++++++-- ...fserve-generate-contract-test-sources.yaml | 4 +- .../selfserve-run-mocked-service-tests.yaml | 2 +- .../expediagroup-sdk/executor.mustache | 8 +-- .../templates/expediagroup-sdk/pom.mustache | 2 + 6 files changed, 71 insertions(+), 40 deletions(-) diff --git a/.github/workflows/generator-test-sdk.yaml b/.github/workflows/generator-test-sdk.yaml index e332c22a0..4551457c3 100644 --- a/.github/workflows/generator-test-sdk.yaml +++ b/.github/workflows/generator-test-sdk.yaml @@ -27,36 +27,7 @@ on: value: ${{ jobs.sdk-metadata.outputs.version }} jobs: - download-specs: - uses: ./.github/workflows/generator-download-specs.yaml - with: - url: ${{ inputs.specs_url }} - - transform-specs: - needs: [ download-specs ] - uses: ./.github/workflows/selfserve-transform-specs.yaml - with: - specs_key: 'raw-specs' - transformations: -th -te ${{ inputs.endpoint_prefix }} --operationIdsToTags - - upload-templates: - uses: ./.github/workflows/selfserve-checkout-and-upload.yaml - with: - artifact_key: 'templates' - artifact_path: 'generator/openapi/src/main/resources/templates/expediagroup-sdk' - repository: 'ExpediaGroup/expediagroup-java-sdk' - ref: "${{ github.head_ref || github.ref_name }}" - - upload-repo: - uses: ./.github/workflows/selfserve-checkout-and-upload.yaml - with: - artifact_key: 'sdk-repo' - artifact_path: '' - repository: 'ExpediaGroup/expediagroup-java-sdk' - ref: "${{ github.head_ref || github.ref_name }}" - generate-sdk: - needs: [ transform-specs, upload-repo ] uses: ./.github/workflows/selfserve-generate-sdk.yaml with: name: ${{ inputs.namespace }} diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index 5965d910e..b67a68e1f 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -80,9 +80,37 @@ jobs: print('::error::Invalid SDK version: ${{ inputs.sdk_version }}') exit(1) + download-specs: + uses: ./.github/workflows/generator-download-specs.yaml + with: + url: ${{ inputs.specs_url }} + + transform-and-upload-specs: + needs: [ download-specs ] + uses: ./.github/workflows/selfserve-transform-specs.yaml + with: + specs_key: 'raw-specs' + transformations: -th -te ${{ inputs.endpoint_prefix }} --operationIdsToTags + + upload-templates: + uses: ./.github/workflows/selfserve-checkout-and-upload.yaml + with: + artifact_key: 'templates' + artifact_path: 'generator/openapi/src/main/resources/templates/expediagroup-sdk' + repository: 'ExpediaGroup/expediagroup-java-sdk' + ref: "${{ github.head_ref || github.ref_name }}" + + upload-repo: + uses: ./.github/workflows/selfserve-checkout-and-upload.yaml + with: + artifact_key: 'sdk-repo' + artifact_path: '' + repository: 'ExpediaGroup/expediagroup-java-sdk' + ref: "${{ github.head_ref || github.ref_name }}" + generate-test-sdk: if: inputs.source == 'specs' - needs: [ inputs-validation ] + needs: [ inputs-validation, transform-and-upload-specs, upload-templates, upload-repo ] uses: ./.github/workflows/generator-test-sdk.yaml with: version: ${{ inputs.sdk_version }} @@ -90,10 +118,19 @@ jobs: endpoint_prefix: ${{ inputs.endpoint_prefix }} specs_url: ${{ inputs.specs_url }} secrets: inherit + + generate-contract-tests: + needs: [ inputs-validation, transform-and-upload-specs, upload-templates, upload-repo ] + uses: ./.github/workflows/selfserve-generate-contract-test-sources.yaml + with: + artifact_key: 'sdk-test' + repo_key: 'sdk-repo' + templates_key: 'templates' + specs_key: 'transformedSpecs' + namespace: ${{ inputs.sdk_namespace }} + generation_options: '--version 0.0.1' + run-rapid-examples: - strategy: - matrix: - jdk: [8, 11, 17, 21] if: always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && inputs.sdk_namespace == 'rapid' needs: [ generate-test-sdk ] uses: "ExpediaGroup/rapid-java-sdk/.github/workflows/run-examples.yaml@main" @@ -103,3 +140,24 @@ jobs: secrets: KEY: ${{ secrets.RAPID_KEY }} SECRET: ${{ secrets.RAPID_SECRET }} + strategy: + matrix: + jdk: [ 8, 11, 17, 21 ] + + run-rapid-contract-tests: + if: always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && inputs.sdk_namespace == 'rapid' + needs: [ generate-contract-tests ] + uses: ./.github/workflows/selfserve-run-mocked-service-tests.yaml + with: + specs_key: 'transformedSpecs' + test_sources_key: 'sdk-test' + sdk_artifact_id: 'rapid' + sdk_version: ${{ inputs.sdk_version }} + sdk_key: 'sdk' + jdk: ${{ matrix.jdk }} + secrets: + KEY: ${{ secrets.RAPID_KEY }} + SECRET: ${{ secrets.RAPID_SECRET }} + strategy: + matrix: + jdk: [ 8, 11, 17, 21 ] diff --git a/.github/workflows/selfserve-generate-contract-test-sources.yaml b/.github/workflows/selfserve-generate-contract-test-sources.yaml index 3a5853d4e..90e2e97f0 100644 --- a/.github/workflows/selfserve-generate-contract-test-sources.yaml +++ b/.github/workflows/selfserve-generate-contract-test-sources.yaml @@ -4,9 +4,9 @@ on: workflow_call: inputs: artifact_key: - description: 'Generated output artifact key' + description: 'Generated output artifact key. Defaults to `sdk-test`' type: string - required: true + default: 'sdk-test' repo_key: description: 'SDK repository artifact key' type: string diff --git a/.github/workflows/selfserve-run-mocked-service-tests.yaml b/.github/workflows/selfserve-run-mocked-service-tests.yaml index 13f98c8d8..14c8a7751 100644 --- a/.github/workflows/selfserve-run-mocked-service-tests.yaml +++ b/.github/workflows/selfserve-run-mocked-service-tests.yaml @@ -5,7 +5,7 @@ on: specs_key: description: 'Specs artifact key. Defaults to `specs`' type: string - default: 'specs' + default: 'transformedSpecs' required: true test_sources_key: description: 'Test sources artifact key. Defaults to `sdk-test`' diff --git a/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache b/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache index e2ca9a5a0..1e5136ce9 100644 --- a/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache +++ b/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache @@ -3,8 +3,8 @@ package com.expediagroup.sdk.{{{namespace}}}.test; import com.expediagroup.sdk.core.model.Operation import com.expediagroup.sdk.core.model.Response import com.expediagroup.sdk.core.model.exception.service.ExpediaGroupServiceException -import com.expediagroup.sdk.rapid.client.RapidClient -import com.expediagroup.sdk.rapid.operations.* +import com.expediagroup.sdk.{{{namespace}}}.client.* +import com.expediagroup.sdk.{{{namespace}}}.operations.* import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.ObjectNode import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper @@ -15,8 +15,8 @@ class {{{clientClassname}}}Executor { } private val client = {{{clientClassname}}}Client.builder() - .key(System.getProperty("com.expediagroup.sdk.apikey", "API_KEY")) - .secret(System.getProperty("com.expediagroup.sdk.apisecret", "API_SECRET")) + .key(System.getProperty("sdk.key", "API_KEY")) + .secret(System.getProperty("sdk.secret", "API_SECRET")) .endpoint("localhost:8080") .requestTimeout(10000) .build() diff --git a/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache b/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache index 619117a85..77a524aae 100644 --- a/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache +++ b/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache @@ -13,6 +13,8 @@ 1.8 rapid-java LATEST + key + secret 2.17.2 3.2.0 From aaff1badabbf470732351454c001ba69e833387e Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Sun, 29 Sep 2024 15:33:39 +0300 Subject: [PATCH 12/62] chore: add secrets configuration to workflow This commit introduces two required secrets, KEY and SECRET, to the GitHub Actions workflow. These secrets are necessary for securely accessing API keys during the execution of mocked service tests. This enhances the workflow's security and ensures proper authentication. --- .github/workflows/selfserve-run-mocked-service-tests.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/selfserve-run-mocked-service-tests.yaml b/.github/workflows/selfserve-run-mocked-service-tests.yaml index 14c8a7751..38b54462a 100644 --- a/.github/workflows/selfserve-run-mocked-service-tests.yaml +++ b/.github/workflows/selfserve-run-mocked-service-tests.yaml @@ -29,6 +29,13 @@ on: description: 'JDK version to use' type: string default: '21' + secrets: + KEY: + description: 'API Key' + required: true + SECRET: + description: 'API Key' + required: true jobs: main: From c8e740a83b56ee8088b54766ca3470c1b4ced5af Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Sun, 29 Sep 2024 15:35:49 +0300 Subject: [PATCH 13/62] chore: update dependencies for generate-contract-tests workflow Correct dependencies to reflect accurate prerequisite steps for generating contract tests. This change ensures the workflow uses the outputs from 'generate-test-sdk' instead of 'transform-and-upload-specs', 'upload-templates', and 'upload-repo'. --- .github/workflows/run-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index b67a68e1f..8e670ba44 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -120,7 +120,7 @@ jobs: secrets: inherit generate-contract-tests: - needs: [ inputs-validation, transform-and-upload-specs, upload-templates, upload-repo ] + needs: [ inputs-validation, generate-test-sdk ] uses: ./.github/workflows/selfserve-generate-contract-test-sources.yaml with: artifact_key: 'sdk-test' From d2f3ff2c80eaf82a75d43fe224a2e9cb9ebd5d10 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Sun, 29 Sep 2024 15:45:34 +0300 Subject: [PATCH 14/62] chore: add SDK generator module installation step Add a new step to install the SDK Generator Module in the workflow. This ensures that the generator dependencies are available before generating test sources. --- .../workflows/selfserve-generate-contract-test-sources.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/selfserve-generate-contract-test-sources.yaml b/.github/workflows/selfserve-generate-contract-test-sources.yaml index 90e2e97f0..aa9435fe2 100644 --- a/.github/workflows/selfserve-generate-contract-test-sources.yaml +++ b/.github/workflows/selfserve-generate-contract-test-sources.yaml @@ -49,6 +49,11 @@ jobs: name: ${{ inputs.specs_key }} path: specs.yaml + - name: Install SDK Generator Module + working-directory: sdk-repo/generator/openapi + run: mvn clean install + continue-on-error: true + - name: Generate Test Sources run: mvn -f sdk-repo/sdk-test clean install exec:java -Dexec.args="--input-spec specs.yaml --templates-dir templates --namespace ${{ inputs.namespace }} ${{ inputs.generation_options }}" From 571a6b573e54bbb110b9d8e1c78dcd63451c2205 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Sun, 29 Sep 2024 21:00:04 +0300 Subject: [PATCH 15/62] chore: add Java 21 setup to workflow Add setup-java action to configure Java 21 with Corretto distribution. This ensures the correct Java version is available during the workflow execution. --- .../workflows/selfserve-generate-contract-test-sources.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/selfserve-generate-contract-test-sources.yaml b/.github/workflows/selfserve-generate-contract-test-sources.yaml index aa9435fe2..752ebd772 100644 --- a/.github/workflows/selfserve-generate-contract-test-sources.yaml +++ b/.github/workflows/selfserve-generate-contract-test-sources.yaml @@ -31,6 +31,11 @@ jobs: generate-and-upload: runs-on: ubuntu-latest steps: + - uses: actions/setup-java@v4 + with: + java-version: 21 + distribution: 'corretto' + - name: Download Repository uses: actions/download-artifact@v4 with: From e8ec99edc3288de3a43841117ed273b4da3e6664 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Sun, 29 Sep 2024 21:07:52 +0300 Subject: [PATCH 16/62] chore: update path for specs.yaml file in workflow Updated the path for the specs.yaml file in the GitHub Actions workflow to ensure the correct file is used. This change helps in locating the specification file correctly for generating test sources. --- .../workflows/selfserve-generate-contract-test-sources.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/selfserve-generate-contract-test-sources.yaml b/.github/workflows/selfserve-generate-contract-test-sources.yaml index 752ebd772..f894f7d74 100644 --- a/.github/workflows/selfserve-generate-contract-test-sources.yaml +++ b/.github/workflows/selfserve-generate-contract-test-sources.yaml @@ -52,7 +52,7 @@ jobs: uses: actions/download-artifact@v4 with: name: ${{ inputs.specs_key }} - path: specs.yaml + path: specs/specs.yaml - name: Install SDK Generator Module working-directory: sdk-repo/generator/openapi @@ -60,7 +60,7 @@ jobs: continue-on-error: true - name: Generate Test Sources - run: mvn -f sdk-repo/sdk-test clean install exec:java -Dexec.args="--input-spec specs.yaml --templates-dir templates --namespace ${{ inputs.namespace }} ${{ inputs.generation_options }}" + run: mvn -f sdk-repo/sdk-test clean install exec:java -Dexec.args="--input-spec specs/specs.yaml --templates-dir templates --namespace ${{ inputs.namespace }} ${{ inputs.generation_options }}" - name: Upload Generated Sources uses: actions/upload-artifact@v4 From 6cfcc53c8f1be27191cb211591e193d48d02356b Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Sun, 29 Sep 2024 21:10:32 +0300 Subject: [PATCH 17/62] chore: update path for specs.yaml file in workflow Updated the path for the specs.yaml file in the GitHub Actions workflow to ensure the correct file is used. This change helps in locating the specification file correctly for generating test sources. --- .github/workflows/run-tests.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index 8e670ba44..1e0b1575d 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -135,6 +135,7 @@ jobs: needs: [ generate-test-sdk ] uses: "ExpediaGroup/rapid-java-sdk/.github/workflows/run-examples.yaml@main" with: + source: 'specs' sdk_version: ${{ needs.generate-test-sdk.outputs.version }} jdk: ${{ matrix.jdk }} secrets: From a54dc6e886fcbcf1f70d49f1eb931450f9f74bf0 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Sun, 29 Sep 2024 21:24:16 +0300 Subject: [PATCH 18/62] chore: update paths in GitHub Actions workflows Updated artifacts' download paths and job names to use dynamic inputs. This ensures the workflow can handle various specs_keys correctly and improves naming clarity. --- .../selfserve-generate-contract-test-sources.yaml | 6 +++--- .github/workflows/selfserve-run-mocked-service-tests.yaml | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/selfserve-generate-contract-test-sources.yaml b/.github/workflows/selfserve-generate-contract-test-sources.yaml index f894f7d74..66dd05843 100644 --- a/.github/workflows/selfserve-generate-contract-test-sources.yaml +++ b/.github/workflows/selfserve-generate-contract-test-sources.yaml @@ -28,7 +28,7 @@ on: required: true jobs: - generate-and-upload: + generate-and-upload-contract-tests: runs-on: ubuntu-latest steps: - uses: actions/setup-java@v4 @@ -52,7 +52,7 @@ jobs: uses: actions/download-artifact@v4 with: name: ${{ inputs.specs_key }} - path: specs/specs.yaml + path: ${{ inputs.specs_key }}.yaml - name: Install SDK Generator Module working-directory: sdk-repo/generator/openapi @@ -60,7 +60,7 @@ jobs: continue-on-error: true - name: Generate Test Sources - run: mvn -f sdk-repo/sdk-test clean install exec:java -Dexec.args="--input-spec specs/specs.yaml --templates-dir templates --namespace ${{ inputs.namespace }} ${{ inputs.generation_options }}" + run: mvn -f sdk-repo/sdk-test clean install exec:java -Dexec.args="--input-spec ${{ inputs.specs_key }}.yaml --templates-dir templates --namespace ${{ inputs.namespace }} ${{ inputs.generation_options }}" - name: Upload Generated Sources uses: actions/upload-artifact@v4 diff --git a/.github/workflows/selfserve-run-mocked-service-tests.yaml b/.github/workflows/selfserve-run-mocked-service-tests.yaml index 38b54462a..2b958e7ba 100644 --- a/.github/workflows/selfserve-run-mocked-service-tests.yaml +++ b/.github/workflows/selfserve-run-mocked-service-tests.yaml @@ -49,7 +49,7 @@ jobs: uses: actions/download-artifact@v4 with: name: ${{ inputs.specs_key }} - path: specs/specs.yaml + path: specs/${{ inputs.specs_key }}.yaml - name: Download Test Sources Artifact uses: actions/download-artifact@v4 with: @@ -65,17 +65,19 @@ jobs: if: inputs.sdk_artifact_key != '' working-directory: sdk run: mvn clean install + - name: Download Latest Specmatic Executable - working-directory: specs/specs.yaml + working-directory: specs run: | curl -s https://api.github.com/repos/znsio/specmatic/releases/latest \ | grep "browser_download_url.*specmatic.jar" \ | cut -d : -f 2,3 \ | tr -d \" \ | xargs curl -L -o specmatic.jar + - name: Run Mock Server working-directory: specs - run: java -jar specmatic.jar stub specs.yaml --port 8080 & disown + run: java -jar specmatic.jar stub ${{ inputs.specs_key }}.yaml --port 8080 & disown - name: Wait for Mock Server to Start run: sleep 10 - name: Run Tests From e1ec168a6bfeba2a3b4fe58ac7dcd59b4fe372e9 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Sun, 29 Sep 2024 21:31:50 +0300 Subject: [PATCH 19/62] chore: update paths in GitHub workflow Adjusted artifact download and input spec paths in the GitHub workflow for generating contract test sources. This ensures consistency in file handling and correct execution of the Maven command. --- .../workflows/selfserve-generate-contract-test-sources.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/selfserve-generate-contract-test-sources.yaml b/.github/workflows/selfserve-generate-contract-test-sources.yaml index 66dd05843..8376e20c4 100644 --- a/.github/workflows/selfserve-generate-contract-test-sources.yaml +++ b/.github/workflows/selfserve-generate-contract-test-sources.yaml @@ -52,7 +52,7 @@ jobs: uses: actions/download-artifact@v4 with: name: ${{ inputs.specs_key }} - path: ${{ inputs.specs_key }}.yaml + path: specs - name: Install SDK Generator Module working-directory: sdk-repo/generator/openapi @@ -60,7 +60,7 @@ jobs: continue-on-error: true - name: Generate Test Sources - run: mvn -f sdk-repo/sdk-test clean install exec:java -Dexec.args="--input-spec ${{ inputs.specs_key }}.yaml --templates-dir templates --namespace ${{ inputs.namespace }} ${{ inputs.generation_options }}" + run: mvn -f sdk-repo/sdk-test clean install exec:java -Dexec.args="--input-spec specs/${{ inputs.specs_key }}.yaml --templates-dir templates --namespace ${{ inputs.namespace }} ${{ inputs.generation_options }}" - name: Upload Generated Sources uses: actions/upload-artifact@v4 From c6bc86d3255603b6df52a8e1469ba5f1840d3f38 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Sun, 29 Sep 2024 22:14:21 +0300 Subject: [PATCH 20/62] chore: update CLI and workflow for target artifact metadata Add ArtifactMetadata class and integrate it into CLI and SdkTestGenerator. Update GitHub workflow to support new target artifact parameters and modify templates to use dynamic target SDK data. --- .github/workflows/run-tests.yaml | 8 +++++--- .../main/kotlin/com/expediagroup/sdk/test/CLI.kt | 16 ++++++++++++++++ .../sdk/test/openapi/ArtifactMetadata.kt | 7 +++++++ .../sdk/test/openapi/SdkTestGenerator.kt | 5 +++++ .../templates/expediagroup-sdk/pom.mustache | 14 ++++++-------- 5 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 sdk-test/src/main/kotlin/com/expediagroup/sdk/test/openapi/ArtifactMetadata.kt diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index 1e0b1575d..8ddfc44fb 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -17,14 +17,16 @@ on: default: '' sdk_version: description: 'Run tests based on SDK' - required: false type: string default: 'LATEST' sdk_namespace: description: 'SDK to test' - required: true type: string default: 'rapid' + sdk_artifact_id: + description: 'SDK artifactId' + type: string + default: 'rapid-sdk' endpoint_prefix: description: 'Endpoint to prepend specs paths with' required: true @@ -128,7 +130,7 @@ jobs: templates_key: 'templates' specs_key: 'transformedSpecs' namespace: ${{ inputs.sdk_namespace }} - generation_options: '--version 0.0.1' + generation_options: '--version 0.0.1 --target-group com.expediagroup --target-artifact ${{ inputs.sdk_artifact_id }} --target-version ${{ inputs.sdk_version }} -m 5' # TODO: remove -m param run-rapid-examples: if: always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && inputs.sdk_namespace == 'rapid' diff --git a/sdk-test/src/main/kotlin/com/expediagroup/sdk/test/CLI.kt b/sdk-test/src/main/kotlin/com/expediagroup/sdk/test/CLI.kt index 7b0b55729..0aa418499 100644 --- a/sdk-test/src/main/kotlin/com/expediagroup/sdk/test/CLI.kt +++ b/sdk-test/src/main/kotlin/com/expediagroup/sdk/test/CLI.kt @@ -27,6 +27,7 @@ package com.expediagroup.sdk.test import com.expediagroup.sdk.test.contract.ContractTestsGenerator import com.expediagroup.sdk.test.contract.MAX_TEST_REQUEST_PER_SCENARIO +import com.expediagroup.sdk.test.openapi.ArtifactMetadata import com.expediagroup.sdk.test.openapi.SdkTestGenerator import com.expediagroup.sdk.test.openapi.ProductTest import com.github.rvesse.airline.SingleCommand @@ -54,6 +55,15 @@ class CLI { @Option(name = ["-t", "--templates-dir"]) private var templatesDir: File = File("src/main/resources/templates/expediagroup-sdk") + @Option(name=["-tg", "--target-group"]) + private lateinit var targetGroup: String + + @Option(name = ["-ta", "--target-artifact"]) + private lateinit var targetArtifact: String + + @Option(name = ["-tv", "--target-version"]) + private lateinit var targetVersion: String + private lateinit var sdkTestGenerator: SdkTestGenerator private lateinit var contractTestsGenerator: ContractTestsGenerator @@ -81,6 +91,11 @@ class CLI { val sdkTestsOutputDirectory = File(outputDir, productTest.artifactId) val contractTestsOutputDirectory = File("target/sdk/${productTest.artifactId}/src/main/", "resources/contract-tests/").also { it.mkdirs() } + val artifact = ArtifactMetadata( + artifactId = targetArtifact, + version = targetVersion, + groupId = targetGroup, + ) contractTestsGenerator = ContractTestsGenerator( spec = spec, @@ -96,6 +111,7 @@ class CLI { productTest = productTest, templatesDir = templatesDir, outputDir = sdkTestsOutputDirectory, + targetArtifact = artifact, ).also { it.generate() } } } diff --git a/sdk-test/src/main/kotlin/com/expediagroup/sdk/test/openapi/ArtifactMetadata.kt b/sdk-test/src/main/kotlin/com/expediagroup/sdk/test/openapi/ArtifactMetadata.kt new file mode 100644 index 000000000..26592820c --- /dev/null +++ b/sdk-test/src/main/kotlin/com/expediagroup/sdk/test/openapi/ArtifactMetadata.kt @@ -0,0 +1,7 @@ +package com.expediagroup.sdk.test.openapi + +data class ArtifactMetadata( + val artifactId: String, + val groupId: String, + val version: String, +) diff --git a/sdk-test/src/main/kotlin/com/expediagroup/sdk/test/openapi/SdkTestGenerator.kt b/sdk-test/src/main/kotlin/com/expediagroup/sdk/test/openapi/SdkTestGenerator.kt index 21766e4e3..29c1d966b 100644 --- a/sdk-test/src/main/kotlin/com/expediagroup/sdk/test/openapi/SdkTestGenerator.kt +++ b/sdk-test/src/main/kotlin/com/expediagroup/sdk/test/openapi/SdkTestGenerator.kt @@ -45,6 +45,7 @@ import java.io.File class SdkTestGenerator( private val productTest: ProductTest, private val spec: File, + private val targetArtifact: ArtifactMetadata, private val version: String = "1.0.0", private val templatesDir: File = File("src/main/resources/templates/expediagroup-sdk"), private val outputDir: File = File("target/sdk") @@ -86,6 +87,10 @@ class SdkTestGenerator( addAdditionalProperty("namespace", productTest.namespace) addAdditionalProperty("clientClassname", productTest.namespace.pascalCase()) + addAdditionalProperty("targetSdkArtifactId", targetArtifact.artifactId) + addAdditionalProperty("targetSdkGroupId", targetArtifact.groupId) + addAdditionalProperty("targetSdkVersion", targetArtifact.version) + // Mustache Helpers mustacheHelpers.forEach { (name, func) -> addAdditionalProperty(name, func) diff --git a/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache b/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache index 77a524aae..54f712051 100644 --- a/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache +++ b/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache @@ -11,8 +11,6 @@ 1.8 1.8 1.8 - rapid-java - LATEST key secret 2.17.2 @@ -33,6 +31,12 @@ + + {{{targetSdkGroupId}}} + {{{targetSdkArtifactId}}} + {{{targetSdkVersion}}} + + com.fasterxml.jackson.module jackson-module-kotlin @@ -49,12 +53,6 @@ ${jackson.version} - - com.expediagroup - ${sdk.artifactId} - ${sdk.version} - - org.apache.logging.log4j log4j-api From cc7e29ae303f0b445d4b94bbb651e8ecb0def365 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Sun, 29 Sep 2024 22:24:24 +0300 Subject: [PATCH 21/62] chore: update run-tests workflow to include sdk_artifact_id Add sdk_artifact_id as a new input parameter in run-tests.yaml workflow. This ensures the artifactId is configurable and defaults to 'rapid-sdk'. --- .github/workflows/run-tests.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index 8ddfc44fb..1e07185c4 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -60,9 +60,12 @@ on: default: 'LATEST' sdk_namespace: description: 'SDK to test' - required: true type: string default: 'rapid' + sdk_artifact_id: + description: 'SDK artifactId' + type: string + default: 'rapid-sdk' endpoint_prefix: description: 'Endpoint to prepend specs paths with' required: true From 0f6deaad8bf4b67a4c0e15a0d1f87c0d858e56fa Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Sun, 29 Sep 2024 22:32:13 +0300 Subject: [PATCH 22/62] chore: add temporary test step for debugging Added a test step in the selfserve-generate-contract-test-sources.yaml workflow to list directory contents. This is intended for debugging purposes and includes a TODO comment to remove it later. --- .../workflows/selfserve-generate-contract-test-sources.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/selfserve-generate-contract-test-sources.yaml b/.github/workflows/selfserve-generate-contract-test-sources.yaml index 8376e20c4..c9cfd8da8 100644 --- a/.github/workflows/selfserve-generate-contract-test-sources.yaml +++ b/.github/workflows/selfserve-generate-contract-test-sources.yaml @@ -48,6 +48,10 @@ jobs: name: ${{ inputs.templates_key }} path: templates + - name: test step # TODO: Remove + working-directory: templates + run: ls -R -l -a + - name: Download Specs uses: actions/download-artifact@v4 with: From 3bbb1f1b24cb6170428a2c7bf7a133e09069ad76 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Sun, 29 Sep 2024 22:39:58 +0300 Subject: [PATCH 23/62] chore: update test artifact upload key in CI workflow Updated the GitHub workflow to include an upload step for test templates. Changed the key for templates in the upload-repo step to ensure correct artifact management. --- .github/workflows/run-tests.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index 1e07185c4..2d6ae2d8f 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -105,6 +105,14 @@ jobs: repository: 'ExpediaGroup/expediagroup-java-sdk' ref: "${{ github.head_ref || github.ref_name }}" + upload-test-templates: + uses: ./.github/workflows/selfserve-checkout-and-upload.yaml + with: + artifact_key: 'test-templates' + artifact_path: 'sdk-test/src/main/resources/templates/expediagroup-sdk' + repository: 'ExpediaGroup/expediagroup-java-sdk' + ref: "${{ github.head_ref || github.ref_name }}" + upload-repo: uses: ./.github/workflows/selfserve-checkout-and-upload.yaml with: @@ -130,7 +138,7 @@ jobs: with: artifact_key: 'sdk-test' repo_key: 'sdk-repo' - templates_key: 'templates' + templates_key: 'test-templates' specs_key: 'transformedSpecs' namespace: ${{ inputs.sdk_namespace }} generation_options: '--version 0.0.1 --target-group com.expediagroup --target-artifact ${{ inputs.sdk_artifact_id }} --target-version ${{ inputs.sdk_version }} -m 5' # TODO: remove -m param From ca1be62bad375b02cbf0a70225ec584fbafd40eb Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Sun, 29 Sep 2024 22:46:59 +0300 Subject: [PATCH 24/62] chore: update artifact name in GitHub Action Changed the artifact name from a dynamic input to a static 'sdk-test' for clarity and consistency. This ensures that the uploaded artifact is always named 'sdk-test' regardless of the input provided. --- .github/workflows/selfserve-generate-contract-test-sources.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/selfserve-generate-contract-test-sources.yaml b/.github/workflows/selfserve-generate-contract-test-sources.yaml index c9cfd8da8..bd3d246dc 100644 --- a/.github/workflows/selfserve-generate-contract-test-sources.yaml +++ b/.github/workflows/selfserve-generate-contract-test-sources.yaml @@ -70,4 +70,4 @@ jobs: uses: actions/upload-artifact@v4 with: path: sdk-repo/sdk-test/target/sdk/*-sdk-test/ - name: ${{ inputs.artifact_key }} + name: 'sdk-test' From 822a90c910631f6071dcb3d93da12db5fc4b00ea Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Sun, 29 Sep 2024 22:47:57 +0300 Subject: [PATCH 25/62] chore: rename job in GitHub Actions workflow Renamed the `main` job to `run-tests-with-mocked-service` in the GitHub Actions workflow. This change improves the clarity of the job's purpose. --- .github/workflows/selfserve-run-mocked-service-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/selfserve-run-mocked-service-tests.yaml b/.github/workflows/selfserve-run-mocked-service-tests.yaml index 2b958e7ba..6c2816086 100644 --- a/.github/workflows/selfserve-run-mocked-service-tests.yaml +++ b/.github/workflows/selfserve-run-mocked-service-tests.yaml @@ -38,7 +38,7 @@ on: required: true jobs: - main: + run-tests-with-mocked-service: runs-on: ubuntu-latest steps: - uses: actions/setup-java@v4 From 512857108461a4102e16249963dcb7b4a283e780 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Sun, 29 Sep 2024 22:55:05 +0300 Subject: [PATCH 26/62] chore: Add file listing for debugging in GitHub workflow Temporarily add a step to list files in the target directory to help with debugging the contract test source generation process. This step is intended to be removed once debugging is complete. --- .../workflows/selfserve-generate-contract-test-sources.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/selfserve-generate-contract-test-sources.yaml b/.github/workflows/selfserve-generate-contract-test-sources.yaml index bd3d246dc..d3f56b3a5 100644 --- a/.github/workflows/selfserve-generate-contract-test-sources.yaml +++ b/.github/workflows/selfserve-generate-contract-test-sources.yaml @@ -66,6 +66,10 @@ jobs: - name: Generate Test Sources run: mvn -f sdk-repo/sdk-test clean install exec:java -Dexec.args="--input-spec specs/${{ inputs.specs_key }}.yaml --templates-dir templates --namespace ${{ inputs.namespace }} ${{ inputs.generation_options }}" + - name: list files # TODO: Remove after finishing debugging + working-directory: sdk-repo/sdk-test/target + run: ls -R -a -l + - name: Upload Generated Sources uses: actions/upload-artifact@v4 with: From 6feb1511cf00849ec9ca387d56638b2985c21340 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Sun, 29 Sep 2024 23:06:17 +0300 Subject: [PATCH 27/62] chore: update test source generation command Refactor the Maven command to run from the correct working directory. Adjusted file paths to ensure proper resolution during test source generation. --- .../workflows/selfserve-generate-contract-test-sources.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/selfserve-generate-contract-test-sources.yaml b/.github/workflows/selfserve-generate-contract-test-sources.yaml index d3f56b3a5..8174fe738 100644 --- a/.github/workflows/selfserve-generate-contract-test-sources.yaml +++ b/.github/workflows/selfserve-generate-contract-test-sources.yaml @@ -64,7 +64,8 @@ jobs: continue-on-error: true - name: Generate Test Sources - run: mvn -f sdk-repo/sdk-test clean install exec:java -Dexec.args="--input-spec specs/${{ inputs.specs_key }}.yaml --templates-dir templates --namespace ${{ inputs.namespace }} ${{ inputs.generation_options }}" + working-directory: sdk-repo/sdk-test + run: mvn clean install exec:java -Dexec.args="--input-spec ../../specs/${{ inputs.specs_key }}.yaml --templates-dir ../../templates --namespace ${{ inputs.namespace }} ${{ inputs.generation_options }}" - name: list files # TODO: Remove after finishing debugging working-directory: sdk-repo/sdk-test/target From 0978535ee75c563d580ea9ab11c699486f0d6c41 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Sun, 29 Sep 2024 23:08:04 +0300 Subject: [PATCH 28/62] chore: streamline test source generation step Refactored the command to a single line invocation to improve readability and maintainability. Removed unnecessary directory specifications and the redundant debug step. This change ensures a cleaner GitHub Actions workflow for generating test sources. --- .../selfserve-generate-contract-test-sources.yaml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/selfserve-generate-contract-test-sources.yaml b/.github/workflows/selfserve-generate-contract-test-sources.yaml index 8174fe738..7fb62224d 100644 --- a/.github/workflows/selfserve-generate-contract-test-sources.yaml +++ b/.github/workflows/selfserve-generate-contract-test-sources.yaml @@ -64,15 +64,10 @@ jobs: continue-on-error: true - name: Generate Test Sources - working-directory: sdk-repo/sdk-test - run: mvn clean install exec:java -Dexec.args="--input-spec ../../specs/${{ inputs.specs_key }}.yaml --templates-dir ../../templates --namespace ${{ inputs.namespace }} ${{ inputs.generation_options }}" - - - name: list files # TODO: Remove after finishing debugging - working-directory: sdk-repo/sdk-test/target - run: ls -R -a -l + run: mvn -f sdk-repo/sdk-test clean install exec:java -Dexec.args="--input-spec specs/${{ inputs.specs_key }}.yaml --templates-dir templates --namespace ${{ inputs.namespace }} ${{ inputs.generation_options }}" - name: Upload Generated Sources uses: actions/upload-artifact@v4 with: - path: sdk-repo/sdk-test/target/sdk/*-sdk-test/ + path: target/sdk/*-sdk-test/ name: 'sdk-test' From fa59e2f200ad4bc3e8adb46b24b88d42e9523222 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Sun, 29 Sep 2024 23:16:10 +0300 Subject: [PATCH 29/62] chore: fix path in GitHub Actions upload artifact step Corrected the path in the 'Upload Generated Sources' step to ensure proper upload of the SDK test artifacts. This change prevents potential issues with artifact availability for subsequent workflow steps. --- .github/workflows/selfserve-generate-contract-test-sources.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/selfserve-generate-contract-test-sources.yaml b/.github/workflows/selfserve-generate-contract-test-sources.yaml index 7fb62224d..581f40179 100644 --- a/.github/workflows/selfserve-generate-contract-test-sources.yaml +++ b/.github/workflows/selfserve-generate-contract-test-sources.yaml @@ -69,5 +69,5 @@ jobs: - name: Upload Generated Sources uses: actions/upload-artifact@v4 with: - path: target/sdk/*-sdk-test/ + path: target/sdk/*-sdk-test/* name: 'sdk-test' From 37c865bef8477c1904e10165860d2c1cc4efd55e Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Mon, 30 Sep 2024 12:57:55 +0300 Subject: [PATCH 30/62] chore: update workflow artifact input handling Replace 'sdk_artifact_key' with 'sdk_key' in the selfserve-run-mocked-service-tests workflow for consistency. Remove an unnecessary test step from selfserve-generate-contract-test-sources workflow. --- .../workflows/selfserve-generate-contract-test-sources.yaml | 4 ---- .github/workflows/selfserve-run-mocked-service-tests.yaml | 6 +++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/selfserve-generate-contract-test-sources.yaml b/.github/workflows/selfserve-generate-contract-test-sources.yaml index 581f40179..5616ffb2c 100644 --- a/.github/workflows/selfserve-generate-contract-test-sources.yaml +++ b/.github/workflows/selfserve-generate-contract-test-sources.yaml @@ -48,10 +48,6 @@ jobs: name: ${{ inputs.templates_key }} path: templates - - name: test step # TODO: Remove - working-directory: templates - run: ls -R -l -a - - name: Download Specs uses: actions/download-artifact@v4 with: diff --git a/.github/workflows/selfserve-run-mocked-service-tests.yaml b/.github/workflows/selfserve-run-mocked-service-tests.yaml index 6c2816086..dd53f2796 100644 --- a/.github/workflows/selfserve-run-mocked-service-tests.yaml +++ b/.github/workflows/selfserve-run-mocked-service-tests.yaml @@ -56,13 +56,13 @@ jobs: name: ${{ inputs.test_sources_key }} path: test - name: Download SDK Artifact - if: inputs.sdk_artifact_key != '' + if: inputs.sdk_key != '' uses: actions/download-artifact@v4 with: - name: ${{ inputs.sdk_artifact_id }} + name: ${{ inputs.sdk_key }} path: sdk - name: Install SDK into Local Repository - if: inputs.sdk_artifact_key != '' + if: inputs.sdk_key != '' working-directory: sdk run: mvn clean install From d974f1a47befb7eb5dca400b3bf7b9d06499c2e7 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Mon, 30 Sep 2024 13:14:09 +0300 Subject: [PATCH 31/62] chore: enhance workflow debug and artifact naming Add directory listing before running tests to aid in debugging. Also modify artifact naming to use input variable for flexibility. --- .github/workflows/selfserve-generate-contract-test-sources.yaml | 2 +- .github/workflows/selfserve-run-mocked-service-tests.yaml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/selfserve-generate-contract-test-sources.yaml b/.github/workflows/selfserve-generate-contract-test-sources.yaml index 5616ffb2c..a6e0d3dc0 100644 --- a/.github/workflows/selfserve-generate-contract-test-sources.yaml +++ b/.github/workflows/selfserve-generate-contract-test-sources.yaml @@ -66,4 +66,4 @@ jobs: uses: actions/upload-artifact@v4 with: path: target/sdk/*-sdk-test/* - name: 'sdk-test' + name: ${{ inputs.artifact_key }} diff --git a/.github/workflows/selfserve-run-mocked-service-tests.yaml b/.github/workflows/selfserve-run-mocked-service-tests.yaml index dd53f2796..a45fd0478 100644 --- a/.github/workflows/selfserve-run-mocked-service-tests.yaml +++ b/.github/workflows/selfserve-run-mocked-service-tests.yaml @@ -80,6 +80,8 @@ jobs: run: java -jar specmatic.jar stub ${{ inputs.specs_key }}.yaml --port 8080 & disown - name: Wait for Mock Server to Start run: sleep 10 + - working-directory: test + run: ls -R -a -l - name: Run Tests working-directory: test run: mvn clean install -Dsdk.artifactId="${{ inputs.sdk_artifact_id }}" -Dsdk.version="${{ inputs.sdk_version }}" exec:java From fdfe8cd787c8ab5762be56f7d58ea82a4d569c8a Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Mon, 30 Sep 2024 13:26:31 +0300 Subject: [PATCH 32/62] chore: update artifact upload path in CI workflow Adjust the upload path to include all nested directories and files. This change ensures that all generated sources are correctly uploaded without omission. --- .github/workflows/selfserve-generate-contract-test-sources.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/selfserve-generate-contract-test-sources.yaml b/.github/workflows/selfserve-generate-contract-test-sources.yaml index a6e0d3dc0..69f1ead63 100644 --- a/.github/workflows/selfserve-generate-contract-test-sources.yaml +++ b/.github/workflows/selfserve-generate-contract-test-sources.yaml @@ -65,5 +65,5 @@ jobs: - name: Upload Generated Sources uses: actions/upload-artifact@v4 with: - path: target/sdk/*-sdk-test/* + path: target/sdk/*-sdk-test/**/* name: ${{ inputs.artifact_key }} From 669467d8b30f9d07ea4e1d352f459e769e22c020 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Mon, 30 Sep 2024 13:29:33 +0300 Subject: [PATCH 33/62] chore: update test command to include secrets Update the test command in the workflow to pass SDK key and secret from GitHub secrets. This ensures secure handling of sensitive information during the test execution. --- .github/workflows/selfserve-run-mocked-service-tests.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/selfserve-run-mocked-service-tests.yaml b/.github/workflows/selfserve-run-mocked-service-tests.yaml index a45fd0478..11c21f57c 100644 --- a/.github/workflows/selfserve-run-mocked-service-tests.yaml +++ b/.github/workflows/selfserve-run-mocked-service-tests.yaml @@ -84,4 +84,6 @@ jobs: run: ls -R -a -l - name: Run Tests working-directory: test - run: mvn clean install -Dsdk.artifactId="${{ inputs.sdk_artifact_id }}" -Dsdk.version="${{ inputs.sdk_version }}" exec:java + run: | + mvn clean install -Dsdk.artifactId="${{ inputs.sdk_artifact_id }}" -Dsdk.version="${{ inputs.sdk_version }}"\ + exec:java -Dsdk.key="${{ secrets.KEY }}" -Dsdk.secret="${{ secrets.SECRET }}" From a174a93266816bdf4f989c7d93b23773448cce05 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Mon, 30 Sep 2024 18:54:37 +0300 Subject: [PATCH 34/62] chore: update artifact path in GitHub Actions workflow Modify the "Upload Generated Sources" step to use 'find' command for specifying the artifact path. This change ensures that all relevant files are included correctly. --- .github/workflows/selfserve-generate-contract-test-sources.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/selfserve-generate-contract-test-sources.yaml b/.github/workflows/selfserve-generate-contract-test-sources.yaml index 69f1ead63..49331ddfd 100644 --- a/.github/workflows/selfserve-generate-contract-test-sources.yaml +++ b/.github/workflows/selfserve-generate-contract-test-sources.yaml @@ -65,5 +65,5 @@ jobs: - name: Upload Generated Sources uses: actions/upload-artifact@v4 with: - path: target/sdk/*-sdk-test/**/* + path: $(find ./target/sdk/*-sdk-test/*) name: ${{ inputs.artifact_key }} From 95c59dbf079610b27c58de02e1079e44c1fe8947 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Mon, 30 Sep 2024 19:14:12 +0300 Subject: [PATCH 35/62] chore: update artifact upload path in GitHub workflow Modified the upload path in the selfserve-generate-contract-test-sources workflow to use a more inclusive glob pattern. This change improves the accuracy of the file selection for artifact uploading. --- .github/workflows/selfserve-generate-contract-test-sources.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/selfserve-generate-contract-test-sources.yaml b/.github/workflows/selfserve-generate-contract-test-sources.yaml index 49331ddfd..5ef16b139 100644 --- a/.github/workflows/selfserve-generate-contract-test-sources.yaml +++ b/.github/workflows/selfserve-generate-contract-test-sources.yaml @@ -65,5 +65,5 @@ jobs: - name: Upload Generated Sources uses: actions/upload-artifact@v4 with: - path: $(find ./target/sdk/*-sdk-test/*) + path: target/sdk/*-sdk-test/** name: ${{ inputs.artifact_key }} From a11424a0b67b276da57fc3a8b16ecc0160c80f35 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Mon, 30 Sep 2024 19:22:59 +0300 Subject: [PATCH 36/62] chore: update test workflow directory path Change the working directory for running tests to a specific pattern. This ensures tests are executed in the correct subdirectory. --- .github/workflows/selfserve-run-mocked-service-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/selfserve-run-mocked-service-tests.yaml b/.github/workflows/selfserve-run-mocked-service-tests.yaml index 11c21f57c..c87f4bfaf 100644 --- a/.github/workflows/selfserve-run-mocked-service-tests.yaml +++ b/.github/workflows/selfserve-run-mocked-service-tests.yaml @@ -83,7 +83,7 @@ jobs: - working-directory: test run: ls -R -a -l - name: Run Tests - working-directory: test + working-directory: test/*-sdk-test run: | mvn clean install -Dsdk.artifactId="${{ inputs.sdk_artifact_id }}" -Dsdk.version="${{ inputs.sdk_version }}"\ exec:java -Dsdk.key="${{ secrets.KEY }}" -Dsdk.secret="${{ secrets.SECRET }}" From 84b5360911cf52590aa6776d1e8afc4059f7f2a3 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Mon, 30 Sep 2024 19:33:06 +0300 Subject: [PATCH 37/62] chore: update test run steps in GitHub workflow Adjusted the workflow to change the working directory and include a directory change command before running tests. This ensures the proper context is set for the Maven commands to execute correctly. --- .github/workflows/selfserve-run-mocked-service-tests.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/selfserve-run-mocked-service-tests.yaml b/.github/workflows/selfserve-run-mocked-service-tests.yaml index c87f4bfaf..f7f4ad4e7 100644 --- a/.github/workflows/selfserve-run-mocked-service-tests.yaml +++ b/.github/workflows/selfserve-run-mocked-service-tests.yaml @@ -83,7 +83,8 @@ jobs: - working-directory: test run: ls -R -a -l - name: Run Tests - working-directory: test/*-sdk-test + working-directory: test run: | + cd "*-sdk-test" mvn clean install -Dsdk.artifactId="${{ inputs.sdk_artifact_id }}" -Dsdk.version="${{ inputs.sdk_version }}"\ exec:java -Dsdk.key="${{ secrets.KEY }}" -Dsdk.secret="${{ secrets.SECRET }}" From 216387d5c09af657f75f1a9c66fa695baf5310d1 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Mon, 30 Sep 2024 20:42:38 +0300 Subject: [PATCH 38/62] chore: add directory listing before running tests Add an 'ls' command before the test execution in the GitHub workflow. This helps debug the workflow by listing directory contents, ensuring the correct path for subsequent commands. --- .github/workflows/selfserve-run-mocked-service-tests.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/selfserve-run-mocked-service-tests.yaml b/.github/workflows/selfserve-run-mocked-service-tests.yaml index f7f4ad4e7..f78941148 100644 --- a/.github/workflows/selfserve-run-mocked-service-tests.yaml +++ b/.github/workflows/selfserve-run-mocked-service-tests.yaml @@ -85,6 +85,7 @@ jobs: - name: Run Tests working-directory: test run: | + ls cd "*-sdk-test" mvn clean install -Dsdk.artifactId="${{ inputs.sdk_artifact_id }}" -Dsdk.version="${{ inputs.sdk_version }}"\ exec:java -Dsdk.key="${{ secrets.KEY }}" -Dsdk.secret="${{ secrets.SECRET }}" From 2d7d12e5a336df871e533608907d099ba27b1967 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Mon, 30 Sep 2024 20:59:32 +0300 Subject: [PATCH 39/62] chore: update test directory path in CI workflow Change the working directory path to dynamically locate the "*-sdk-test" folder. This ensures that the CI pipeline runs correctly even if the test folder name changes. Simplifies the workflow script by removing redundant commands. --- .github/workflows/selfserve-run-mocked-service-tests.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/selfserve-run-mocked-service-tests.yaml b/.github/workflows/selfserve-run-mocked-service-tests.yaml index f78941148..78c40c984 100644 --- a/.github/workflows/selfserve-run-mocked-service-tests.yaml +++ b/.github/workflows/selfserve-run-mocked-service-tests.yaml @@ -83,9 +83,7 @@ jobs: - working-directory: test run: ls -R -a -l - name: Run Tests - working-directory: test + working-directory: test/$(find . -type d -name "*-sdk-test" -print -quit) run: | - ls - cd "*-sdk-test" mvn clean install -Dsdk.artifactId="${{ inputs.sdk_artifact_id }}" -Dsdk.version="${{ inputs.sdk_version }}"\ exec:java -Dsdk.key="${{ secrets.KEY }}" -Dsdk.secret="${{ secrets.SECRET }}" From dfc28bb821d2da7f1a7e7281d7d98ba96a9315a9 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Mon, 30 Sep 2024 21:25:49 +0300 Subject: [PATCH 40/62] chore: update test directory path in CI workflow Change the working directory path to dynamically locate the "*-sdk-test" folder. This ensures that the CI pipeline runs correctly even if the test folder name changes. Simplifies the workflow script by removing redundant commands. --- .github/workflows/selfserve-run-mocked-service-tests.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/selfserve-run-mocked-service-tests.yaml b/.github/workflows/selfserve-run-mocked-service-tests.yaml index 78c40c984..f2a3d7e6f 100644 --- a/.github/workflows/selfserve-run-mocked-service-tests.yaml +++ b/.github/workflows/selfserve-run-mocked-service-tests.yaml @@ -83,7 +83,8 @@ jobs: - working-directory: test run: ls -R -a -l - name: Run Tests - working-directory: test/$(find . -type d -name "*-sdk-test" -print -quit) + working-directory: test run: | + cd $(find . -type d -name "*-sdk-test" -print -quit) mvn clean install -Dsdk.artifactId="${{ inputs.sdk_artifact_id }}" -Dsdk.version="${{ inputs.sdk_version }}"\ exec:java -Dsdk.key="${{ secrets.KEY }}" -Dsdk.secret="${{ secrets.SECRET }}" From c3605a28aa95b40f5f422599663a087dd59ebf36 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Tue, 1 Oct 2024 01:27:28 +0300 Subject: [PATCH 41/62] chore: add Guava dependency and update file resource path Added com.google.guava dependency to pom.mustache file. Updated file resource path in main.mustache to use Guava's Resources utility for better resource handling. --- .../main/resources/templates/expediagroup-sdk/main.mustache | 3 ++- .../main/resources/templates/expediagroup-sdk/pom.mustache | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache b/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache index 23d4fd40f..5866dd34f 100644 --- a/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache +++ b/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache @@ -2,6 +2,7 @@ package com.expediagroup.sdk.{{{namespace}}}.test; import com.fasterxml.jackson.module.kotlin.* import com.fasterxml.jackson.databind.node.ObjectNode +import com.google.common.io.Resources import java.io.File; import com.github.rvesse.airline.annotations.Command; @@ -18,7 +19,7 @@ class Main { } fun run() { - File("src/main/resources/contract-tests").listFiles().forEach { file -> + File(Resources.getResource("contract-tests")!!.file).listFiles()!!.forEach { file -> mapper.readTree(file).let { test -> val request = test["request"] as ObjectNode val response = test["response"] as ObjectNode diff --git a/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache b/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache index 54f712051..54a085f6b 100644 --- a/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache +++ b/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache @@ -37,6 +37,12 @@ {{{targetSdkVersion}}} + + com.google.guava + guava + 33.3.1-jre + + com.fasterxml.jackson.module jackson-module-kotlin From be1ff12500ffc653e61dad2c651c67d733f8e2a4 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Tue, 1 Oct 2024 01:41:06 +0300 Subject: [PATCH 42/62] chore: simplify GitHub workflow configurations Remove unnecessary SDK artifact and version inputs from GitHub workflows. This streamlines the YAML files, reducing complexity and potential errors. --- .github/workflows/run-tests.yaml | 2 -- .../selfserve-run-mocked-service-tests.yaml | 18 ++++++++---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index 2d6ae2d8f..e276d6f16 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -165,8 +165,6 @@ jobs: with: specs_key: 'transformedSpecs' test_sources_key: 'sdk-test' - sdk_artifact_id: 'rapid' - sdk_version: ${{ inputs.sdk_version }} sdk_key: 'sdk' jdk: ${{ matrix.jdk }} secrets: diff --git a/.github/workflows/selfserve-run-mocked-service-tests.yaml b/.github/workflows/selfserve-run-mocked-service-tests.yaml index f2a3d7e6f..6d16eda5b 100644 --- a/.github/workflows/selfserve-run-mocked-service-tests.yaml +++ b/.github/workflows/selfserve-run-mocked-service-tests.yaml @@ -12,14 +12,6 @@ on: type: string default: 'sdk-test' required: true - sdk_artifact_id: - description: 'SDK artifactId' - type: string - required: true - sdk_version: - description: 'SDK version' - type: string - required: true sdk_key: description: 'SDK artifact key to download' type: string @@ -45,22 +37,26 @@ jobs: with: java-version: ${{ inputs.jdk }} distribution: 'corretto' + - name: Download Specs uses: actions/download-artifact@v4 with: name: ${{ inputs.specs_key }} path: specs/${{ inputs.specs_key }}.yaml + - name: Download Test Sources Artifact uses: actions/download-artifact@v4 with: name: ${{ inputs.test_sources_key }} path: test + - name: Download SDK Artifact if: inputs.sdk_key != '' uses: actions/download-artifact@v4 with: name: ${{ inputs.sdk_key }} path: sdk + - name: Install SDK into Local Repository if: inputs.sdk_key != '' working-directory: sdk @@ -78,13 +74,15 @@ jobs: - name: Run Mock Server working-directory: specs run: java -jar specmatic.jar stub ${{ inputs.specs_key }}.yaml --port 8080 & disown + - name: Wait for Mock Server to Start run: sleep 10 + - working-directory: test run: ls -R -a -l + - name: Run Tests working-directory: test run: | cd $(find . -type d -name "*-sdk-test" -print -quit) - mvn clean install -Dsdk.artifactId="${{ inputs.sdk_artifact_id }}" -Dsdk.version="${{ inputs.sdk_version }}"\ - exec:java -Dsdk.key="${{ secrets.KEY }}" -Dsdk.secret="${{ secrets.SECRET }}" + mvn clean install exec:java -Dsdk.key="${{ secrets.KEY }}" -Dsdk.secret="${{ secrets.SECRET }}" From e9ca5e9d3515534022bd2128e00914942e31f7c9 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Tue, 1 Oct 2024 01:50:54 +0300 Subject: [PATCH 43/62] chore: update JSON deserialization method in executor template Change the method from `asText()` to `toPrettyString()` for reading JSON value. This ensures better formatting and readability when processing the request. --- .../main/resources/templates/expediagroup-sdk/executor.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache b/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache index 1e5136ce9..d8511deb2 100644 --- a/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache +++ b/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache @@ -26,7 +26,7 @@ class {{{clientClassname}}}Executor { val requestType: Class<*> = metadata[key]!!.requestType - val operation = mapper.readValue(request.asText(), requestType) as Operation<*> + val operation = mapper.readValue(request.toPrettyString(), requestType) as Operation<*> if (expectedResponse["status"].asInt() in 200..299) { val actual = mapper.convertValue(execute(operation), JsonNode::class.java) From cadf74e6be80e4747d5399bb7d858bdddc7bebe7 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Tue, 1 Oct 2024 02:08:51 +0300 Subject: [PATCH 44/62] chore: remove debug command and add JSON deserialization annotation Remove unnecessary ls command from workflow file to clean up actions. Add `@JsonDeserialize` annotation to data class template for better JSON processing. --- .github/workflows/selfserve-run-mocked-service-tests.yaml | 3 --- .../resources/templates/expediagroup-sdk/data_class.mustache | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/selfserve-run-mocked-service-tests.yaml b/.github/workflows/selfserve-run-mocked-service-tests.yaml index 6d16eda5b..0519ea6ee 100644 --- a/.github/workflows/selfserve-run-mocked-service-tests.yaml +++ b/.github/workflows/selfserve-run-mocked-service-tests.yaml @@ -78,9 +78,6 @@ jobs: - name: Wait for Mock Server to Start run: sleep 10 - - working-directory: test - run: ls -R -a -l - - name: Run Tests working-directory: test run: | diff --git a/generator/openapi/src/main/resources/templates/expediagroup-sdk/data_class.mustache b/generator/openapi/src/main/resources/templates/expediagroup-sdk/data_class.mustache index b0554bb81..f4f1af40b 100644 --- a/generator/openapi/src/main/resources/templates/expediagroup-sdk/data_class.mustache +++ b/generator/openapi/src/main/resources/templates/expediagroup-sdk/data_class.mustache @@ -27,7 +27,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo {{/discriminator.mappedModels}} ) {{/discriminator}} -{{#nonPublicApi}}internal {{/nonPublicApi}}{{#discriminator}}interface {{/discriminator}}{{^discriminator}}data class {{/discriminator}}{{classname}}{{^discriminator}}( +{{#nonPublicApi}}internal {{/nonPublicApi}}{{#discriminator}}interface {{/discriminator}}{{^discriminator}}@JsonDeserialize(builder = {{{classname}}}.Builder::class) data class {{/discriminator}}{{classname}}{{^discriminator}}( {{#allVars}} {{#eliminateDiscriminators}} {{#required}}{{>data_class_req_var}}{{/required}}{{^required}}{{>data_class_opt_var}}{{/required}}{{^-last}},{{/-last}} From 72e57701b2401fb5c9e7fcbf4716f2752069fe41 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Tue, 1 Oct 2024 02:14:13 +0300 Subject: [PATCH 45/62] chore: add Jackson deserialization annotation to data class template Include JsonDeserialize from com.fasterxml.jackson.databind.annotation in data_class.mustache template. This change ensures proper deserialization handling of the generated data classes. --- .../resources/templates/expediagroup-sdk/data_class.mustache | 1 + 1 file changed, 1 insertion(+) diff --git a/generator/openapi/src/main/resources/templates/expediagroup-sdk/data_class.mustache b/generator/openapi/src/main/resources/templates/expediagroup-sdk/data_class.mustache index f4f1af40b..08a83d279 100644 --- a/generator/openapi/src/main/resources/templates/expediagroup-sdk/data_class.mustache +++ b/generator/openapi/src/main/resources/templates/expediagroup-sdk/data_class.mustache @@ -5,6 +5,7 @@ import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; import javax.validation.Valid; import org.hibernate.validator.constraints.Length; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize {{#discriminator}} import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonSubTypes From b17bd65f7ad7ee8f921abd72b1ecb87d786135ea Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Tue, 1 Oct 2024 02:45:05 +0300 Subject: [PATCH 46/62] chore: remove JsonDeserialize annotation from data class template This commit eliminates the `@JsonDeserialize` annotation in the `data_class.mustache` template file. The change simplifies data class generation and removes unnecessary dependencies on Jackson's `JsonDeserialize` functionality. --- .../resources/templates/expediagroup-sdk/data_class.mustache | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/generator/openapi/src/main/resources/templates/expediagroup-sdk/data_class.mustache b/generator/openapi/src/main/resources/templates/expediagroup-sdk/data_class.mustache index 08a83d279..b0554bb81 100644 --- a/generator/openapi/src/main/resources/templates/expediagroup-sdk/data_class.mustache +++ b/generator/openapi/src/main/resources/templates/expediagroup-sdk/data_class.mustache @@ -5,7 +5,6 @@ import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; import javax.validation.Valid; import org.hibernate.validator.constraints.Length; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize {{#discriminator}} import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonSubTypes @@ -28,7 +27,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo {{/discriminator.mappedModels}} ) {{/discriminator}} -{{#nonPublicApi}}internal {{/nonPublicApi}}{{#discriminator}}interface {{/discriminator}}{{^discriminator}}@JsonDeserialize(builder = {{{classname}}}.Builder::class) data class {{/discriminator}}{{classname}}{{^discriminator}}( +{{#nonPublicApi}}internal {{/nonPublicApi}}{{#discriminator}}interface {{/discriminator}}{{^discriminator}}data class {{/discriminator}}{{classname}}{{^discriminator}}( {{#allVars}} {{#eliminateDiscriminators}} {{#required}}{{>data_class_req_var}}{{/required}}{{^required}}{{>data_class_opt_var}}{{/required}}{{^-last}},{{/-last}} From 294f8cc12c7cef8f9dcff8224204a614b62c3c09 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Tue, 1 Oct 2024 03:34:34 +0300 Subject: [PATCH 47/62] chore: configure Jackson deserialization in templates Refactor jacksonObjectMapper configuration in executor and main templates. This consolidates deserialization feature settings to ensure consistent handling of nullable and missing properties across both files. --- .../expediagroup-sdk/executor.mustache | 20 +++++++++++++++++-- .../templates/expediagroup-sdk/main.mustache | 11 +++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache b/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache index d8511deb2..aa7526cf1 100644 --- a/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache +++ b/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache @@ -11,7 +11,16 @@ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper class {{{clientClassname}}}Executor { companion object { - val mapper = jacksonObjectMapper() + val mapper = val mapper = jacksonObjectMapper { + disable(KotlinFeature.StrictNullChecks) + }.apply { + disable(DeserializationFeature.FAIL_ON_MISSING_CREATOR_PROPERTIES) + disable(DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY) + disable(DeserializationFeature.FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY) + disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES) + disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + disable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES) + } } private val client = {{{clientClassname}}}Client.builder() @@ -26,7 +35,14 @@ class {{{clientClassname}}}Executor { val requestType: Class<*> = metadata[key]!!.requestType - val operation = mapper.readValue(request.toPrettyString(), requestType) as Operation<*> + val operation: Operation<*> = try { + mapper.readValue(request.toPrettyString(), requestType) as Operation<*> + } catch (e: Exception) { + if (expectedResponse["status"].asInt() !in 200..299) { + return + } + throw e + } if (expectedResponse["status"].asInt() in 200..299) { val actual = mapper.convertValue(execute(operation), JsonNode::class.java) diff --git a/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache b/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache index 5866dd34f..ce4efb4c5 100644 --- a/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache +++ b/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache @@ -9,7 +9,16 @@ import com.github.rvesse.airline.annotations.Command; @Command(name = "cli", description = "Command Line Interface for SDK Test") class Main { companion object { - val mapper = jacksonObjectMapper() + val mapper = jacksonObjectMapper { + disable(KotlinFeature.StrictNullChecks) + }.apply { + disable(DeserializationFeature.FAIL_ON_MISSING_CREATOR_PROPERTIES) + disable(DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY) + disable(DeserializationFeature.FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY) + disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES) + disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + disable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES) + } val executor = {{{clientClassname}}}Executor() @JvmStatic From 1ae116240f49df11a11e0dbbc9590cfb5995d29e Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Tue, 1 Oct 2024 03:47:30 +0300 Subject: [PATCH 48/62] chore: add imports for Jackson Kotlin features Introduced DeserializationFeature and KotlinFeature imports to support enhanced JSON processing. These imports will facilitate more robust data deserialization within the template. --- .../main/resources/templates/expediagroup-sdk/executor.mustache | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache b/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache index aa7526cf1..7ffa7a0dd 100644 --- a/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache +++ b/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache @@ -5,6 +5,8 @@ import com.expediagroup.sdk.core.model.Response import com.expediagroup.sdk.core.model.exception.service.ExpediaGroupServiceException import com.expediagroup.sdk.{{{namespace}}}.client.* import com.expediagroup.sdk.{{{namespace}}}.operations.* +import com.fasterxml.jackson.databind.DeserializationFeature +import com.fasterxml.jackson.module.kotlin.KotlinFeature import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.ObjectNode import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper From fa9c8d93fc64cdd3d51cf81091557786ea4947b4 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Tue, 1 Oct 2024 03:59:38 +0300 Subject: [PATCH 49/62] chore: add imports for Jackson Kotlin features Introduced DeserializationFeature and KotlinFeature imports to support enhanced JSON processing. These imports will facilitate more robust data deserialization within the template. --- .../src/main/resources/templates/expediagroup-sdk/main.mustache | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache b/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache index ce4efb4c5..95363556e 100644 --- a/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache +++ b/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache @@ -3,6 +3,8 @@ package com.expediagroup.sdk.{{{namespace}}}.test; import com.fasterxml.jackson.module.kotlin.* import com.fasterxml.jackson.databind.node.ObjectNode import com.google.common.io.Resources +import com.fasterxml.jackson.databind.DeserializationFeature +import com.fasterxml.jackson.module.kotlin.KotlinFeature import java.io.File; import com.github.rvesse.airline.annotations.Command; From dba239c013559ef71d18904467d20227de4b85c7 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Tue, 1 Oct 2024 04:09:19 +0300 Subject: [PATCH 50/62] chore: simplify jacksonObjectMapper initialization Removed multiple disable calls on jacksonObjectMapper configuration. This change streamlines the code and relies on default settings instead. --- .../templates/expediagroup-sdk/main.mustache | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache b/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache index 95363556e..5866dd34f 100644 --- a/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache +++ b/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache @@ -3,24 +3,13 @@ package com.expediagroup.sdk.{{{namespace}}}.test; import com.fasterxml.jackson.module.kotlin.* import com.fasterxml.jackson.databind.node.ObjectNode import com.google.common.io.Resources -import com.fasterxml.jackson.databind.DeserializationFeature -import com.fasterxml.jackson.module.kotlin.KotlinFeature import java.io.File; import com.github.rvesse.airline.annotations.Command; @Command(name = "cli", description = "Command Line Interface for SDK Test") class Main { companion object { - val mapper = jacksonObjectMapper { - disable(KotlinFeature.StrictNullChecks) - }.apply { - disable(DeserializationFeature.FAIL_ON_MISSING_CREATOR_PROPERTIES) - disable(DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY) - disable(DeserializationFeature.FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY) - disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES) - disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) - disable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES) - } + val mapper = jacksonObjectMapper() val executor = {{{clientClassname}}}Executor() @JvmStatic From 566931a83d864d9482b53e9387118efe92ee5b52 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Tue, 1 Oct 2024 04:24:48 +0300 Subject: [PATCH 51/62] chore: Add @JvmStatic annotations to singleton objects Added @JvmStatic annotations to singleton objects in executor.mustache and main.mustache templates. This ensures proper static access from Java, enhancing compatibility and performance. It also improves interoperation between Kotlin and Java codebases. --- .../resources/templates/expediagroup-sdk/executor.mustache | 3 ++- .../main/resources/templates/expediagroup-sdk/main.mustache | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache b/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache index 7ffa7a0dd..c1eac60b5 100644 --- a/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache +++ b/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache @@ -13,7 +13,8 @@ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper class {{{clientClassname}}}Executor { companion object { - val mapper = val mapper = jacksonObjectMapper { + @JvmStatic + val mapper = jacksonObjectMapper { disable(KotlinFeature.StrictNullChecks) }.apply { disable(DeserializationFeature.FAIL_ON_MISSING_CREATOR_PROPERTIES) diff --git a/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache b/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache index 5866dd34f..ec95935a8 100644 --- a/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache +++ b/sdk-test/src/main/resources/templates/expediagroup-sdk/main.mustache @@ -9,7 +9,10 @@ import com.github.rvesse.airline.annotations.Command; @Command(name = "cli", description = "Command Line Interface for SDK Test") class Main { companion object { + @JvmStatic val mapper = jacksonObjectMapper() + + @JvmStatic val executor = {{{clientClassname}}}Executor() @JvmStatic From e6769afa40d1c130d247a288db52c34e58d66898 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Tue, 1 Oct 2024 05:08:56 +0300 Subject: [PATCH 52/62] chore: enhance request deserialization logic Updated request deserialization to handle multiple node types (body, pathParams, queryParams, headers, params) for better flexibility. Improved error handling maintains original response status codes for non-200 responses. --- .../templates/expediagroup-sdk/executor.mustache | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache b/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache index c1eac60b5..c3441f13a 100644 --- a/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache +++ b/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache @@ -39,7 +39,17 @@ class {{{clientClassname}}}Executor { val requestType: Class<*> = metadata[key]!!.requestType val operation: Operation<*> = try { - mapper.readValue(request.toPrettyString(), requestType) as Operation<*> + mapper.createObjectNode().apply { + listOf("body", "pathParams", "queryParams", "headers", "params").forEach { + request.get(it)?.let { node -> + node.fields()?.forEachRemaining { (key, value) -> + set(key, value) + } + } + } + }.let { + return@let mapper.readValue(it.toPrettyString(), requestType) as Operation<*> + } } catch (e: Exception) { if (expectedResponse["status"].asInt() !in 200..299) { return From faeb164b2ce22ecb5eebd3c51f767d2fd68023ee Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Tue, 1 Oct 2024 05:18:39 +0300 Subject: [PATCH 53/62] chore: update endpoint URL scheme in executor.mustache Changed endpoint from "localhost:8080" to "http://localhost:8080". This ensures the URL is fully qualified and adheres to standard formatting conventions. --- .../main/resources/templates/expediagroup-sdk/executor.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache b/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache index c3441f13a..0ca8d3961 100644 --- a/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache +++ b/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache @@ -29,7 +29,7 @@ class {{{clientClassname}}}Executor { private val client = {{{clientClassname}}}Client.builder() .key(System.getProperty("sdk.key", "API_KEY")) .secret(System.getProperty("sdk.secret", "API_SECRET")) - .endpoint("localhost:8080") + .endpoint("http://localhost:8080") .requestTimeout(10000) .build() From 46dc2a6b64c6086a483c041bbef4cb8d8747143a Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Tue, 1 Oct 2024 05:34:45 +0300 Subject: [PATCH 54/62] chore: update Java version in workflow and add missing setup Updated the Java version to 21 and added a missing setup step in the workflow. This ensures compatibility and proper environment configuration for running mocked service tests. --- .github/workflows/selfserve-run-mocked-service-tests.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/selfserve-run-mocked-service-tests.yaml b/.github/workflows/selfserve-run-mocked-service-tests.yaml index 0519ea6ee..266b883cd 100644 --- a/.github/workflows/selfserve-run-mocked-service-tests.yaml +++ b/.github/workflows/selfserve-run-mocked-service-tests.yaml @@ -35,7 +35,7 @@ jobs: steps: - uses: actions/setup-java@v4 with: - java-version: ${{ inputs.jdk }} + java-version: 21 distribution: 'corretto' - name: Download Specs @@ -75,6 +75,11 @@ jobs: working-directory: specs run: java -jar specmatic.jar stub ${{ inputs.specs_key }}.yaml --port 8080 & disown + - uses: actions/setup-java@v4 + with: + java-version: ${{ inputs.jdk }} + distribution: 'corretto' + - name: Wait for Mock Server to Start run: sleep 10 From d7f0609c8d349b937d806529954bd091a56a8f4c Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Tue, 1 Oct 2024 15:29:25 +0300 Subject: [PATCH 55/62] chore: add spec transformation step and remove mapdb dependency Added a step to transform specs using the @expediagroup/spec-transformer in the GitHub workflow. Also removed the mapdb dependency from the pom.mustache template to clean up unused dependencies. --- .github/workflows/selfserve-run-mocked-service-tests.yaml | 4 ++++ .../main/resources/templates/expediagroup-sdk/pom.mustache | 7 ------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/selfserve-run-mocked-service-tests.yaml b/.github/workflows/selfserve-run-mocked-service-tests.yaml index 266b883cd..8e5ed8c8e 100644 --- a/.github/workflows/selfserve-run-mocked-service-tests.yaml +++ b/.github/workflows/selfserve-run-mocked-service-tests.yaml @@ -44,6 +44,10 @@ jobs: name: ${{ inputs.specs_key }} path: specs/${{ inputs.specs_key }}.yaml + - name: Transform Specs + working-directory: specs + run: npx --yes -p @expediagroup/spec-transformer cli -i ${{ inputs.specs_key }}.yaml -o ${{ inputs.specs_key }}.yaml -to + - name: Download Test Sources Artifact uses: actions/download-artifact@v4 with: diff --git a/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache b/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache index 54a085f6b..4d4359da9 100644 --- a/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache +++ b/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache @@ -65,13 +65,6 @@ 2.23.1 - - - org.mapdb - mapdb - 3.1.0 - - org.apache.logging.log4j log4j-slf4j2-impl From e8aaf8160935ee3846f026c16af0c7c2747fef70 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Tue, 1 Oct 2024 16:47:26 +0300 Subject: [PATCH 56/62] chore: add Node.js setup in GitHub workflow Added a step to setup Node.js 18.18.2 in the selfserve run mocked service tests GitHub workflow. This ensures that the required Node.js environment is correctly configured for the tests. --- .github/workflows/selfserve-run-mocked-service-tests.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/selfserve-run-mocked-service-tests.yaml b/.github/workflows/selfserve-run-mocked-service-tests.yaml index 8e5ed8c8e..f6a438129 100644 --- a/.github/workflows/selfserve-run-mocked-service-tests.yaml +++ b/.github/workflows/selfserve-run-mocked-service-tests.yaml @@ -38,6 +38,11 @@ jobs: java-version: 21 distribution: 'corretto' + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 18.18.2 + - name: Download Specs uses: actions/download-artifact@v4 with: From 588fea9fac1c1734242fcf398497121c10074788 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Tue, 1 Oct 2024 16:57:10 +0300 Subject: [PATCH 57/62] chore: update download path in GitHub workflow Modified the path for downloading specs in the selfserve-run-mocked-service-tests workflow. This change removes the filename specification, simplifying the target directory to just "specs". --- .github/workflows/selfserve-run-mocked-service-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/selfserve-run-mocked-service-tests.yaml b/.github/workflows/selfserve-run-mocked-service-tests.yaml index f6a438129..57fb72e7f 100644 --- a/.github/workflows/selfserve-run-mocked-service-tests.yaml +++ b/.github/workflows/selfserve-run-mocked-service-tests.yaml @@ -47,7 +47,7 @@ jobs: uses: actions/download-artifact@v4 with: name: ${{ inputs.specs_key }} - path: specs/${{ inputs.specs_key }}.yaml + path: specs - name: Transform Specs working-directory: specs From 33885cbcaa155d9df1556a2f11a93469e64a1db5 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Wed, 2 Oct 2024 14:53:16 +0300 Subject: [PATCH 58/62] chore: add JavaTimeModule registration in executor Added jackson-datatype-jsr310 dependency to support Java time module. Updated executor.mustache to register JavaTimeModule, ensuring proper deserialization of Java 8 Date/Time API objects. --- .../expediagroup-sdk/executor.mustache | 35 +++++++++++++++---- .../templates/expediagroup-sdk/pom.mustache | 5 +++ 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache b/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache index 0ca8d3961..54cc6bdeb 100644 --- a/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache +++ b/sdk-test/src/main/resources/templates/expediagroup-sdk/executor.mustache @@ -10,6 +10,7 @@ import com.fasterxml.jackson.module.kotlin.KotlinFeature import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.ObjectNode import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule class {{{clientClassname}}}Executor { companion object { @@ -23,6 +24,7 @@ class {{{clientClassname}}}Executor { disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES) disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) disable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES) + registerModule(JavaTimeModule()) } } @@ -39,17 +41,38 @@ class {{{clientClassname}}}Executor { val requestType: Class<*> = metadata[key]!!.requestType val operation: Operation<*> = try { - mapper.createObjectNode().apply { - listOf("body", "pathParams", "queryParams", "headers", "params").forEach { - request.get(it)?.let { node -> + val params = + mapper.createObjectNode().apply { + listOf("pathParams", "queryParams", "headers", "params").forEach { + request.get(it)?.let { node -> + node.fields()?.forEachRemaining { (key, value) -> + set(key, value) + } + } + } + } + + val body = + mapper.createObjectNode().apply { + request.get("body")?.let { node -> node.fields()?.forEachRemaining { (key, value) -> set(key, value) } } } - }.let { - return@let mapper.readValue(it.toPrettyString(), requestType) as Operation<*> - } + + val operationNode = + mapper.createObjectNode().apply { + takeIf { params.fields().hasNext() }?.let { + set("params", params) + } + + takeIf { body.fields().hasNext() }?.let { + set("body", body) + } + } + + mapper.readValue(operationNode.toPrettyString(), requestType) as Operation<*> } catch (e: Exception) { if (expectedResponse["status"].asInt() !in 200..299) { return diff --git a/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache b/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache index 4d4359da9..c2837b11f 100644 --- a/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache +++ b/sdk-test/src/main/resources/templates/expediagroup-sdk/pom.mustache @@ -58,6 +58,11 @@ jackson-databind ${jackson.version} + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + ${jackson.version} + org.apache.logging.log4j From f9000b427a833ca36adb6fef5703ecc86d4d16e8 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Wed, 2 Oct 2024 15:13:42 +0300 Subject: [PATCH 59/62] chore: add @JsonProperty annotation to enum variables Added @JsonProperty annotation to ensure correct JSON serialization for enum variables. This change improves code readability and aligns with JSON processing standards. --- .../templates/expediagroup-sdk/operation_params.mustache | 1 + 1 file changed, 1 insertion(+) diff --git a/generator/openapi/src/main/resources/templates/expediagroup-sdk/operation_params.mustache b/generator/openapi/src/main/resources/templates/expediagroup-sdk/operation_params.mustache index 5b69282f8..dd8097a3b 100644 --- a/generator/openapi/src/main/resources/templates/expediagroup-sdk/operation_params.mustache +++ b/generator/openapi/src/main/resources/templates/expediagroup-sdk/operation_params.mustache @@ -93,6 +93,7 @@ ) { {{#allowableValues}} {{#enumVars}} + @JsonProperty({{{value}}}) {{name}}({{{value}}}) {{^-last}},{{/-last}} {{/enumVars}} From b2ff0bae5055067432f655496ebb14dc31c8ddd6 Mon Sep 17 00:00:00 2001 From: oaljarrah Date: Thu, 3 Oct 2024 19:24:50 +0300 Subject: [PATCH 60/62] chore: add file to inputStream type mapping Added a type mapping from java.io.File to java.io.InputStream in the OpenApiSdkGenerator. This change enhances type compatibility and improves the handling of file streams in the generated SDK. --- .../expediagroup/sdk/generators/openapi/OpenApiSdkGenerator.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/generator/openapi/src/main/kotlin/com/expediagroup/sdk/generators/openapi/OpenApiSdkGenerator.kt b/generator/openapi/src/main/kotlin/com/expediagroup/sdk/generators/openapi/OpenApiSdkGenerator.kt index fd6e1b217..ea4239d21 100644 --- a/generator/openapi/src/main/kotlin/com/expediagroup/sdk/generators/openapi/OpenApiSdkGenerator.kt +++ b/generator/openapi/src/main/kotlin/com/expediagroup/sdk/generators/openapi/OpenApiSdkGenerator.kt @@ -126,6 +126,8 @@ class OpenApiSdkGenerator { if (ProductFamily.isRapid(product.namespace)) { rapidHelpers.forEach { (name, function) -> addAdditionalProperty(name, function()) } } + + addTypeMapping("java.io.File", "java.io.InputStream") } val generatorInput = From fa64c0c546e2a85889cc28569810ae3ba64eb33c Mon Sep 17 00:00:00 2001 From: OmarAlJarrah Date: Wed, 30 Oct 2024 08:43:15 +0300 Subject: [PATCH 61/62] chore: re-add generate-contract-test job --- .github/workflows/run-tests.yaml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index b781b51ba..bf9dd77b0 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -37,16 +37,23 @@ jobs: needs: [ generate-test-sdk ] uses: "ExpediaGroup/rapid-java-sdk/.github/workflows/run-examples.yaml@main" with: - source: 'specs' sdk_version: ${{ needs.generate-test-sdk.outputs.version }} jdk: ${{ matrix.jdk }} source: 'specs' secrets: KEY: ${{ secrets.RAPID_KEY }} SECRET: ${{ secrets.RAPID_SECRET }} - strategy: - matrix: - jdk: [ 8, 11, 17, 21 ] + + generate-contract-tests: + needs: [ generate-test-sdk ] + uses: ./.github/workflows/selfserve-generate-contract-test-sources.yaml + with: + artifact_key: 'sdk-test' + repo_key: 'sdk-repo' + templates_key: 'test-templates' + specs_key: 'transformedSpecs' + namespace: ${{ inputs.sdk_namespace }} + generation_options: '--version 0.0.1 --target-group com.expediagroup --target-artifact ${{ inputs.sdk_artifact_id }} --target-version ${{ inputs.sdk_version }} -m 5' # TODO: remove -m param run-rapid-contract-tests: if: always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && inputs.sdk_namespace == 'rapid' From a39a0053266e967c31e271b73dceef99854cd6c3 Mon Sep 17 00:00:00 2001 From: OmarAlJarrah Date: Wed, 30 Oct 2024 08:52:11 +0300 Subject: [PATCH 62/62] chore: test --- .github/workflows/run-tests.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index bf9dd77b0..487fc15ca 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -40,6 +40,7 @@ jobs: sdk_version: ${{ needs.generate-test-sdk.outputs.version }} jdk: ${{ matrix.jdk }} source: 'specs' + secrets: KEY: ${{ secrets.RAPID_KEY }} SECRET: ${{ secrets.RAPID_SECRET }}