Skip to content

Commit

Permalink
feat: Implement Java Executor (#224)
Browse files Browse the repository at this point in the history
PR: #224
  • Loading branch information
mohnoor94 authored Jun 19, 2023
1 parent 4fb37ed commit 99e58a5
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 26 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/generator-download-specs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Download API Specs
on:
workflow_call:
inputs:
url:
description: 'URL to download API specs from'
required: true
type: string

jobs:
download_specs:
runs-on: ubuntu-latest
steps:
- id: download_specs
run: |
curl -L ${{ inputs.url }} -o raw-specs.yaml
- uses: actions/upload-artifact@v3
with:
name: raw-specs
path: raw-specs.yaml
16 changes: 8 additions & 8 deletions .github/workflows/generator-generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ name: Generate SDK - Generate
on:
workflow_call:
inputs:
version:
description: 'generated sdk version'
required: true
type: string
name:
description: 'generated sdk name'
description: 'SDK Name'
required: true
type: string
fileAsBase64:
description: 'generated sdk file as base64 encoded'
version:
description: 'SDK Version'
required: true
type: string
jobs:
Expand All @@ -27,11 +23,15 @@ jobs:
- id: build
working-directory: generator
run: mvn clean install
- uses: actions/download-artifact@v3
with:
name: specs
path: generator/openapi
- name: generate
working-directory: generator/openapi
run: |
mvn clean install
mvn exec:java "-Dnamespace=${{ inputs.name }}" -DsdkVersion=${{ inputs.version }} "-Dspec=${{ inputs.fileAsBase64 }}"
mvn exec:java "-Dnamespace=${{ inputs.name }}" -DsdkVersion=${{ inputs.version }} "-Dspec=./specs.yaml"
- uses: actions/upload-artifact@v3
with:
name: sdk
Expand Down
41 changes: 28 additions & 13 deletions .github/workflows/generator-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,50 @@ name: Generate SDK - Main
on:
workflow_dispatch:
inputs:
name:
description: 'SDK Name'
required: true
version:
description: 'Generated SDK version'
description: 'SDK Version'
required: false
default: ''
name:
description: 'Generated SDK name'
required: true
fileAsBase64:
description: 'Generated SDK file as base64 encoded'
specs_url:
description: 'URL to download API specs from'
required: true
type: string
test:
description: 'Release snapshot?'
description: 'Release a Snapshot? (Leave blank for no, anything else for yes)'
required: false
jobs:
prepare_version:
uses: ./.github/workflows/generator-prepare-version.yml
with:
version: ${{ github.event.inputs.version }}
name: ${{ github.event.inputs.name }}
version: ${{ github.event.inputs.version }}
download_specs:
uses: ./.github/workflows/generator-download-specs.yml
with:
url: ${{ github.event.inputs.specs_url }}
transform_specs:
needs: [ download_specs ]
uses: ./.github/workflows/generator-transform-specs.yml
with:
configurations: -th -te -tt ${{ github.event.inputs.name }}
generate:
needs: [ prepare_version ]
needs: [ prepare_version, transform_specs ]
uses: ./.github/workflows/generator-generate.yml
with:
version: ${{ needs.prepare_version.outputs.version }}
name: ${{ github.event.inputs.name }}
fileAsBase64: ${{ github.event.inputs.fileAsBase64 }}
publish:
version: ${{ needs.prepare_version.outputs.version }}
publish_sources:
needs: [ generate ]
uses: ./.github/workflows/generator-publish.yml
uses: ./.github/workflows/generator-publish-sources.yml
with:
name: ${{ github.event.inputs.name }}
version: ${{ github.event.inputs.version }}
publish_artifact:
needs: [ publish_sources ]
uses: ./.github/workflows/generator-publish-artifact.yml
secrets: inherit
with:
test: ${{ github.event.inputs.test }}
4 changes: 2 additions & 2 deletions .github/workflows/generator-prepare-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Generate SDK - Prepare Version
on:
workflow_call:
inputs:
version:
name:
required: true
type: string
name:
version:
required: true
type: string
outputs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
type: string
required: false
jobs:
job:
publish:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.publish.outputs.version }}
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/generator-publish-sources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Generate and Publish Sources
on:
workflow_call:
inputs:
name:
description: 'SDK Name'
required: true
type: string
version:
description: 'SDK Version'
required: true
type: string

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: sdk
path: generator/sdk
- uses: actions/download-artifact@v3
with:
name: specs
path: generator/sdk
- name: Publish Code
working-directory: generator/sdk
run: |
git config --global user.email "[email protected]"
git config --global user.name "Expedia Group Open Source"
rm -rf ../../release/"${{github.event.inputs.name}}"
mkdir -p ../../release/"${{github.event.inputs.name}}"
cp -r ./src ../../release/"${{github.event.inputs.name}}"/
cp ./pom.xml ../../release/"${{github.event.inputs.name}}"/
cp ./README.md ../../release/"${{github.event.inputs.name}}"/
cp ./specs.yaml ../../release/"${{github.event.inputs.name}}"/specs.yaml
git checkout main
git pull
git checkout -b "${{github.event.inputs.name}}-${{github.event.inputs.version}}"
git add ../../release/\*
git commit -m "chore: Publish ${{github.event.inputs.name}} [${{github.event.inputs.version}}] SDK"
git push --set-upstream origin "${{github.event.inputs.name}}-${{github.event.inputs.version}}"
gh pr create -B main -H "${{github.event.inputs.name}}-${{github.event.inputs.version}}" --title 'chore: Publish ${{github.event.inputs.name}} [${{github.event.inputs.version}}] SDK' --fill
env:
GH_TOKEN: ${{ github.token }}
22 changes: 22 additions & 0 deletions .github/workflows/generator-transform-specs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Transform Specs
on:
workflow_call:
inputs:
configurations:
description: 'Spec Transformer CLI Configurations'
type: string
required: true

jobs:
transform-specs:
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: raw-specs
- run: |
npx --yes -p @expediagroup/spec-transformer cli ${{ inputs.configurations }} -i raw-specs.yaml -o specs.yaml
- uses: actions/upload-artifact@v3
with:
name: specs
path: specs.yaml
4 changes: 2 additions & 2 deletions .github/workflows/generator-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ jobs:
run: |
mvn clean install
mvn exec:java "-Dnamespace=exemplar" "-DsdkVersion=1.0.0" "-Dspec=./src/test/resources/exemplar.yaml"
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: sdk
path: generator/openapi/target/sdk
verify-generated-sdk:
runs-on: ubuntu-latest
needs: generate-sdk
steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: sdk
path: generator/sdk
Expand Down

0 comments on commit 99e58a5

Please sign in to comment.