Skip to content

Commit

Permalink
Merge branch 'main' into OmarAlJarrah/add-contract-tests-executors
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarAlJarrah authored Aug 11, 2024
2 parents 034d584 + 31edd82 commit bb1090b
Show file tree
Hide file tree
Showing 15 changed files with 582 additions and 121 deletions.
1 change: 1 addition & 0 deletions .github/workflows/core-upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ jobs:
with:
name: branch-name
path: branch_name.txt
overwrite: true

- name: Publish Updated Version PR
uses: peter-evans/create-pull-request@v6
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/generator-download-specs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ jobs:
with:
name: raw-specs
path: raw-specs.yaml
overwrite: true
3 changes: 3 additions & 0 deletions .github/workflows/generator-generate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,16 @@ jobs:
path: |
generator/openapi/target/sdk
!generator/openapi/target/sdk/target
overwrite: true
- uses: actions/upload-artifact@v4
with:
name: jar
path: |
generator/openapi/target/sdk/target/*.jar
generator/openapi/target/sdk/target/maven-archiver/pom.properties
overwrite: true
- uses: actions/upload-artifact@v4
with:
name: docs
path: generator/openapi/target/sdk/target/dokka
overwrite: true
4 changes: 4 additions & 0 deletions .github/workflows/generator-test-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ on:
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 }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/generator-transform-specs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ jobs:
with:
name: specs
path: specs.yaml
overwrite: true
1 change: 1 addition & 0 deletions .github/workflows/generator-verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
with:
name: sdk
path: generator/openapi/target/sdk
overwrite: true
verify-generated-sdk:
runs-on: ubuntu-latest
needs: generate-sdk
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/pr-check-tests.yaml
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
24 changes: 12 additions & 12 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Run Tests
on:
push:
workflow_dispatch:
inputs:
source:
Expand Down Expand Up @@ -66,7 +65,7 @@ on:
description: 'JDK version to use'
required: true
type: string
default: '17'
default: '21'
endpoint_prefix:
description: 'Endpoint to prepend specs paths with'
required: true
Expand All @@ -78,29 +77,30 @@ jobs:
steps:
- shell: python -u {0}
run: |
if 'specs' in '${{ github.event.inputs.source }}' and not('${{ github.event.inputs.specs_url }}'):
print('::error::Invalid specs URL: ${{ github.event.inputs.specs_url }}')
if 'specs' in '${{ inputs.source }}' and not('${{ inputs.specs_url }}'):
print('::error::Invalid specs URL: ${{ inputs.specs_url }}')
exit(1)
if 'sdk' in '${{ github.event.inputs.source }}' and not('${{ github.event.inputs.sdk_version }}'):
print('::error::Invalid SDK version: ${{ github.event.inputs.sdk_version }}')
if 'sdk' in '${{ inputs.source }}' and not('${{ inputs.sdk_version }}'):
print('::error::Invalid SDK version: ${{ inputs.sdk_version }}')
exit(1)
generate-test-sdk:
if: ${{ github.event.inputs.source == 'specs' }}
if: inputs.source == 'specs'
needs: [ inputs-validation ]
uses: ./.github/workflows/generator-test-sdk.yaml
with:
version: ${{ github.event.inputs.sdk_version }}
namespace: ${{ github.event.inputs.sdk_namespace }}
endpoint_prefix: ${{ github.event.inputs.endpoint_prefix }}
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')
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: ${{ github.event.inputs.jdk }}
jdk: ${{ inputs.jdk }}
sdk_generation_workflow_run_id: ${{ github.run_id }}
secrets:
KEY: ${{ secrets.RAPID_KEY }}
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/selfserve-generate.yaml
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
6 changes: 6 additions & 0 deletions generator/openapi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
<namespace>example</namespace>
<sdkVersion>0.0.1-SNAPSHOT</sdkVersion>
<language>java</language>
<templatesDir>templates/expediagroup-sdk</templatesDir>
<repoName>test-sdk</repoName>

<!-- Versions -->
<kotlin.version>2.0.0</kotlin.version>
Expand Down Expand Up @@ -397,6 +399,10 @@
<argument>${sdkVersion}</argument>
<argument>--language</argument>
<argument>${language}</argument>
<argument>-t</argument>
<argument>${templatesDir}</argument>
<argument>-r</argument>
<argumnet>${repoName}</argumnet>
</arguments>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* 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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,19 @@ class OpenApiSdkGenerator {
@Option(name = ["-l", "--language"])
lateinit var programmingLanguage: String

@Option(name = ["-t", "--templates-dir"])
lateinit var templateDir: String

@Option(name = ["-r", "--repo-name"])
lateinit var repoName: String

fun run() {
try {
val product = Product(namespace, programmingLanguage)
val product = Product(namespace, repoName, programmingLanguage)
val config =
CodegenConfigurator().apply {
setGeneratorName("kotlin")
setTemplateDir("templates/expediagroup-sdk")
setTemplateDir(templateDir)
setInputSpec(inputFile)
setOutputDir(outputDirectory)
setArtifactId(product.artifactId)
Expand Down Expand Up @@ -109,6 +115,7 @@ class OpenApiSdkGenerator {
addAdditionalProperty("namespace", product.namespace)
addAdditionalProperty("clientClassname", namespace.pascalCase())
addAdditionalProperty("language", product.programmingLanguage.id)
addAdditionalProperty("repoName", product.repoName)
addAdditionalProperty("isKotlin", ProgrammingLanguage.isKotlin(product.programmingLanguage))
addAdditionalProperty("isRapid", ProductFamily.isRapid(product.namespace))
addAdditionalProperty("isExpediaGroup", ProductFamily.isExpediaGroup(product.namespace))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ val NON_ALPHANUMERIC_REGEX = Regex("[^a-zA-Z0-9]")

class Product(
inputNamespace: String,
val repoName: String,
val programmingLanguage: ProgrammingLanguage = ProgrammingLanguage.JAVA
) {
constructor(inputNamespace: String, programmingLanguage: String = "java") : this(
constructor(inputNamespace: String, repoName: String, programmingLanguage: String = "java") : this(
inputNamespace,
repoName,
ProgrammingLanguage.from(programmingLanguage)
)

Expand Down
Loading

0 comments on commit bb1090b

Please sign in to comment.