Skip to content

Commit

Permalink
Merge branch 'main' into OmarAlJarrah/enable-service-virtualization-f…
Browse files Browse the repository at this point in the history
…or-contract-tests
  • Loading branch information
OmarAlJarrah authored Aug 19, 2024
2 parents aa35dca + b34fa56 commit 635694e
Show file tree
Hide file tree
Showing 12 changed files with 259 additions and 50 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/generator-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ on:
description: 'SDK Name'
required: true
version:
description: 'SDK Version'
description: |
SDK Version
⚠️ For a snapshot version, append `-SNAPSHOT` to the version number, in the format `1.0.0-SNAPSHOT`,
in addition to not selecting the `Release to production` option below.
required: true
endpoint_prefix:
description: 'Endpoint to prepend specs paths with'
Expand All @@ -17,7 +21,11 @@ on:
required: true
type: string
production_release:
description: 'Release to production'
description: |
Release to production
⚠️ Please ensure that the version number includes the `-SNAPSHOT` suffix if this option is not selected,
otherwise the SDK will be published to Maven Central (production).
required: true
type: boolean
default: false
Expand Down
128 changes: 128 additions & 0 deletions .github/workflows/selfserve-full-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: Generate and Publish SDK (Full Workflow)

on:
workflow_call:
inputs:
name:
description: 'SDK Name'
required: true
type: string
version:
description: |
SDK Version.
E.g., 1.0.0, 1.0.1, 1.0.0-SNAPSHOT, etc.
required: true
type: string
templates:
description: |
Path to the templates directory.
Use the default path if you are using the default templates.
Use `sdk-repo` to refer to the `expediagroup-sdk` repo root path if needed.
type: string
default: 'sdk-repo/generator/openapi/src/main/resources/templates/expediagroup-sdk'
repository:
description: |
Repository to generate the SDK in.
Leave empty to use the current repository.
type: string
default: ''
ref:
description: |
Branch or tag to checkout.
Leave empty to use the default branch.
type: string
default: ''
specs_key:
description: |
Key to the OpenAPI specs artifact and name
(without extension, e.g. specs, the file is expected to have the extension .yaml).
The artifact is expected to be in the root of the repository, unless you specify a different path
using the specs_path input.
type: string
default: 'specs'
specs_path:
description: 'Path to the specs file in the provided repository'
type: string
default: 'specs.yaml'
transformed_specs_key:
description: |
Key to the transformed specs artifact and name.
(without extension, e.g. transformedSpecs, the file is expected to have the extension .yaml).
This artifact will be generated by the transformation job and used to generate the SDK.
This artifact will be published with this name into the provided sources_path directory.
type: string
default: 'transformedSpecs'
transformations:
description: 'Spec Transformer CLI Configurations'
type: string
default: '--headers --operationIdsToTags'
sources_path:
description: 'Path to publish the source code to. This should be a path of a directory where the source code will be published to'
type: string
default: 'code'
sdk_key:
description: |
Key to the generated SDK artifact.
This artifact will be generated by the generation job and used to publish the SDK.
type: string
default: 'sdk'


jobs:
show-inputs:
runs-on: ubuntu-latest
steps:
- name: Show inputs
run: |
echo "SDK Name: ${{ inputs.name }}"
echo "SDK Version: ${{ inputs.version }}"
echo "Templates: ${{ inputs.templates }}"
echo "Repository: ${{ inputs.repository }}"
echo "Ref: ${{ inputs.ref }}"
echo "Specs Key: ${{ inputs.specs_key }}"
echo "Specs Path: ${{ inputs.specs_path }}"
echo "Transformed Specs Key: ${{ inputs.transformed_specs_key }}"
echo "Transformations: ${{ inputs.transformations }}"
echo "Sources Path: ${{ inputs.sources_path }}"
echo "SDK Key: ${{ inputs.sdk_key }}"
upload-specs:
uses: ./.github/workflows/selfserve-upload-specs.yaml
with:
specs_key: ${{ inputs.specs_key }}
specs_path: ${{ inputs.specs_path }}
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}

transform-specs:
uses: ./.github/workflows/selfserve-transform-specs.yaml
needs: [ upload-specs ]
with:
specs_key: ${{ inputs.specs_key }}
transformations: ${{ inputs.transformations }}
transformed_specs_key: ${{ inputs.transformed_specs_key }}

generate-sdk:
uses: ./.github/workflows/selfserve-generate.yaml
needs: [ transform-specs ]
with:
name: ${{ inputs.name }}
version: ${{ inputs.version }}
templates: ${{ inputs.templates }}
specs_key: ${{ inputs.transformed_specs_key }}
sdk_key: ${{ inputs.sdk_key }}

publish-sources:
uses: ./.github/workflows/selfserve-publish-sources.yaml
needs: [ generate-sdk ]
with:
version: ${{ inputs.version }}
path: ${{ inputs.sources_path }}
sdk_key: ${{ inputs.sdk_key }}
specs_key: ${{ inputs.transformed_specs_key }}

release:
uses: ./.github/workflows/selfserve-release.yaml
needs: [ generate-sdk, publish-sources ]
with:
sdk_key: ${{ inputs.sdk_key }}
4 changes: 3 additions & 1 deletion .github/workflows/selfserve-generate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ on:
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)'
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: 'transformedSpecs'
type: string
sdk_key:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/selfserve-publish-sources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
type: string
path:
description: 'Path to publish the source code to. This should be a path of a directory where the source code will be published to'
required: true
default: 'code'
type: string
sdk_key:
description: 'Key to the generated SDK artifact'
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/selfserve-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Release an SDK to Maven Central

on:
workflow_call:
inputs:
sdk_key:
description: 'Key to the generated SDK artifact'
default: 'sdk'
type: string

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
server-id: oss-sonatype
server-username: SONATYPE_USERNAME
server-password: SONATYPE_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE
settings-path: ${{ github.workspace }}

- name: Download SDK Artifact
uses: actions/download-artifact@v4
with:
name: ${{ inputs.sdk_key }}
path: sdk

- name: Release SDK
working-directory: sdk
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PRIVATE_KEY_PASSPHRASE }}
run: |
echo "Starting SDK Release - version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)"
mvn deploy --settings $GITHUB_WORKSPACE/settings.xml -B -U -P release -DskipTests=true
echo "SDK Released"
41 changes: 41 additions & 0 deletions .github/workflows/selfserve-upload-specs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Upload Specs (from Repo)

on:
workflow_call:
inputs:
repository:
description: |
Repository to download the specs from.
Leave empty to use the current repository.
type: string
default: ''
ref:
description: |
Branch or tag to checkout.
Leave empty to use the default branch.
type: string
default: ''
specs_key:
description: 'Key to the specs artifact'
type: string
default: 'specs'
specs_path:
description: 'Path to the specs file'
type: string
default: 'specs.yaml'

jobs:
upload-specs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}

- name: Upload specs
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.specs_key }}
path: ${{ inputs.specs_path }}
2 changes: 1 addition & 1 deletion .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.8/apache-maven-3.9.8-bin.zip
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
2 changes: 1 addition & 1 deletion generator/openapi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<openapi-generator.version>6.6.0</openapi-generator.version>

<!-- Plugin Versions -->
<exec-maven-plugin.version>3.3.0</exec-maven-plugin.version>
<exec-maven-plugin.version>3.4.1</exec-maven-plugin.version>
<ktlint-plugin.version>3.2.0</ktlint-plugin.version>
<maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
<maven-jar-plugin.version>3.4.2</maven-jar-plugin.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@
<ktor.version>2.3.12</ktor.version>
<kotlin-atomic.version>0.25.0</kotlin-atomic.version>
<slf4j.version>2.0.13</slf4j.version>
<maven.nexus-staging.plugin.version>1.7.0</maven.nexus-staging.plugin.version>
<maven.gpg.plugin.version>3.2.5</maven.gpg.plugin.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -393,12 +395,6 @@
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>${maven-resources-plugin.version}</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down Expand Up @@ -678,6 +674,11 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
Expand Down
Loading

0 comments on commit 635694e

Please sign in to comment.