-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dtayeh/PAA-499-update-dispatcher-config
- Loading branch information
Showing
15 changed files
with
772 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,4 @@ jobs: | |
with: | ||
name: raw-specs | ||
path: raw-specs.yaml | ||
overwrite: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: Generate Test SDK | ||
on: | ||
workflow_call: | ||
inputs: | ||
version: | ||
description: 'SDK version to generate test jar for' | ||
required: true | ||
type: string | ||
namespace: | ||
description: 'SDK to generate test jar for' | ||
required: true | ||
type: string | ||
endpoint_prefix: | ||
description: 'Endpoint to prepend specs paths with' | ||
required: true | ||
type: string | ||
specs_url: | ||
description: 'Run tests based on specs' | ||
required: true | ||
type: string | ||
outputs: | ||
artifactId: | ||
value: ${{ jobs.sdk-metadata.outputs.artifactId }} | ||
groupId: | ||
value: ${{ jobs.sdk-metadata.outputs.groupId }} | ||
version: | ||
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/generator-transform-specs.yaml | ||
with: | ||
configurations: -th -te ${{ inputs.endpoint_prefix }} --operationIdsToTags | ||
generate-sdk: | ||
needs: [ transform-specs ] | ||
uses: ./.github/workflows/generator-generate.yaml | ||
with: | ||
name: ${{ inputs.namespace }} | ||
version: ${{ inputs.version }} | ||
sdk-metadata: | ||
runs-on: ubuntu-latest | ||
needs: [ generate-sdk ] | ||
outputs: | ||
artifactId: ${{ steps.parse-metadata.outputs.artifactId }} | ||
groupId: ${{ steps.parse-metadata.outputs.groupId }} | ||
version: ${{ steps.parse-metadata.outputs.version }} | ||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: jar | ||
path: jar | ||
- id: parse-metadata | ||
working-directory: jar/maven-archiver | ||
shell: python -u {0} | ||
run: | | ||
import os | ||
metadata: dict = dict() | ||
with open("pom.properties") as properties: | ||
metadata = dict(line.strip().split('=') for line in filter(bool, properties.readlines())) | ||
with open(os.getenv("GITHUB_OUTPUT"), "a") as GITHUB_OUTPUT: | ||
for key, value in metadata.items(): | ||
print(f"{key}={value}", file=GITHUB_OUTPUT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,4 @@ jobs: | |
with: | ||
name: specs | ||
path: specs.yaml | ||
overwrite: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: PR Check Tests Run | ||
on: push | ||
|
||
jobs: | ||
run-rapid-tests: | ||
strategy: | ||
matrix: | ||
jdk: [8, 11, 17, 21] | ||
fail-fast: true | ||
max-parallel: 1 | ||
uses: ./.github/workflows/run-tests.yaml | ||
with: | ||
source: 'specs' | ||
specs_url: 'https://ewe-assets.s3.amazonaws.com/developer-tools/api/rapid/v3/specs.yaml' | ||
sdk_version: 1.0.${{ github.run_id }} | ||
sdk_namespace: 'rapid' | ||
jdk: ${{ matrix.jdk }} | ||
endpoint_prefix: '/v3' | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
name: Run Tests | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
source: | ||
description: 'Source of tests' | ||
required: true | ||
type: choice | ||
options: | ||
- 'specs' | ||
- 'sdk' | ||
default: 'sdk' | ||
specs_url: | ||
description: 'Run tests based on specs' | ||
required: false | ||
type: string | ||
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' | ||
endpoint_prefix: | ||
description: 'Endpoint to prepend specs paths with' | ||
required: true | ||
type: string | ||
jdk: | ||
description: 'JDK version to use' | ||
required: true | ||
type: choice | ||
options: | ||
- '21' | ||
- '17' | ||
- '11' | ||
- '8' | ||
default: '21' | ||
workflow_call: | ||
inputs: | ||
source: | ||
description: 'Source of tests' | ||
required: true | ||
type: string | ||
default: 'sdk' | ||
specs_url: | ||
description: 'Run tests based on specs' | ||
required: false | ||
type: string | ||
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' | ||
jdk: | ||
description: 'JDK version to use' | ||
required: true | ||
type: string | ||
default: '21' | ||
endpoint_prefix: | ||
description: 'Endpoint to prepend specs paths with' | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
inputs-validation: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- shell: python -u {0} | ||
run: | | ||
if 'specs' in '${{ inputs.source }}' and not('${{ inputs.specs_url }}'): | ||
print('::error::Invalid specs URL: ${{ inputs.specs_url }}') | ||
exit(1) | ||
if 'sdk' in '${{ inputs.source }}' and not('${{ inputs.sdk_version }}'): | ||
print('::error::Invalid SDK version: ${{ inputs.sdk_version }}') | ||
exit(1) | ||
generate-test-sdk: | ||
if: inputs.source == 'specs' | ||
needs: [ inputs-validation ] | ||
uses: ./.github/workflows/generator-test-sdk.yaml | ||
with: | ||
version: ${{ inputs.sdk_version }} | ||
namespace: ${{ inputs.sdk_namespace }} | ||
endpoint_prefix: ${{ inputs.endpoint_prefix }} | ||
specs_url: ${{ inputs.specs_url }} | ||
secrets: inherit | ||
run-rapid-examples: | ||
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" | ||
with: | ||
sdk_version: ${{ needs.generate-test-sdk.outputs.version }} | ||
jdk: ${{ inputs.jdk }} | ||
sdk_generation_workflow_run_id: ${{ github.run_id }} | ||
secrets: | ||
KEY: ${{ secrets.RAPID_KEY }} | ||
SECRET: ${{ secrets.RAPID_SECRET }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Generate SDK | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
name: | ||
description: 'SDK Name' | ||
required: true | ||
type: string | ||
version: | ||
description: 'SDK Version' | ||
required: true | ||
type: string | ||
templates: | ||
description: 'Path to the templates directory' | ||
required: true | ||
type: string | ||
specs_key: | ||
description: 'Key to the transformed and ready to use specs artifact and name (without extension, e.g. specs, the file is expected to have the extension .yaml)' | ||
default: 'specs' | ||
type: string | ||
sdk_key: | ||
description: 'Key to the generated SDK artifact' | ||
default: 'sdk' | ||
type: string | ||
|
||
jobs: | ||
generate: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout EG SDK Repository | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: 'ExpediaGroup/expediagroup-java-sdk' | ||
path: sdk-repo | ||
|
||
- name: Download Specs | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ inputs.specs_key }} | ||
path: sdk-repo/generator/openapi | ||
|
||
- name: Set up JDK 21 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '21' | ||
distribution: 'temurin' | ||
|
||
- name: Generate Product SDK | ||
working-directory: sdk-repo/generator/openapi | ||
run: | | ||
mvn clean install exec:java "-Dnamespace=${{ inputs.name }}" -DsdkVersion=${{ inputs.version }} "-Dspec=./${{ inputs.specs_key }}.yaml" -DtemplatesDir="${{ inputs.templates }}" | ||
- name: Install SDK | ||
working-directory: sdk-repo/generator/openapi/target/sdk | ||
run: | | ||
mvn clean install | ||
- name: Persist SDK Artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ inputs.sdk_key }} | ||
path: | | ||
sdk-repo/generator/openapi/target/sdk | ||
!sdk-repo/generator/openapi/target/sdk/target | ||
overwrite: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
generator/openapi/src/main/kotlin/com/expediagroup/sdk/generators/openapi/Extensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (C) 2022 Expedia, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.expediagroup.sdk.generators.openapi | ||
|
||
/** | ||
* This extension function converts a string to PascalCase. | ||
* PascalCase is a type of identifier that consists of compound words or phrases such that each word or abbreviation begins with a capital letter. | ||
* Non-alphabetic characters are ignored, and the next alphabetic character after them is capitalized. | ||
* | ||
* @receiver String The string to be converted to PascalCase. | ||
* @return String The string converted to PascalCase. | ||
*/ | ||
fun String.pascalCase(): String { | ||
var capitalizeNext = true | ||
val builder = StringBuilder() | ||
forEach { char -> | ||
when { | ||
char.isLetterOrDigit().and(capitalizeNext) -> builder.append(char.uppercaseChar()) | ||
char.isLetterOrDigit() -> builder.append(char) | ||
} | ||
capitalizeNext = char.isLetter().not().or(builder.isEmpty()) | ||
} | ||
return builder.toString() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.