Skip to content

Commit

Permalink
feat(git): Implement Python Executor. (#149)
Browse files Browse the repository at this point in the history
PR: #149
  • Loading branch information
OmarAlJarrah authored Jul 9, 2023
1 parent c8033b3 commit c7947ff
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 89 deletions.
30 changes: 0 additions & 30 deletions .github/workflows/commit-sdk.yaml

This file was deleted.

28 changes: 23 additions & 5 deletions .github/workflows/generate-and-publish-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,40 @@ on:
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 to test?'
required: false
jobs:
download_specs:
uses: ./.github/workflows/generator-download-specs.yaml
with:
url: ${{ github.event.inputs.specs_url }}

transform_specs:
needs: [ download_specs ]
uses: ./.github/workflows/generator-transform-specs.yaml
with:
configurations: -th -te -tt ${{ github.event.inputs.name }}


generate_sdk:
needs: [ transform_specs ]
uses: ./.github/workflows/generate-sdk.yaml
with:
version: ${{ github.event.inputs.version }}
name: ${{ github.event.inputs.name }}
fileAsBase64: ${{ github.event.inputs.fileAsBase64 }}
commit_sdk:

publish_sources:
needs: [ generate_sdk ]
uses: ./.github/workflows/commit-sdk.yaml
uses: ./.github/workflows/generator-publish-sources.yaml
with:
version: ${{ github.event.inputs.version }}
name: ${{ github.event.inputs.name }}

publish_sdk:
needs: [ generate_sdk ]
uses: ./.github/workflows/publish-sdk.yaml
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/generate-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ on:
description: 'Generated SDK name'
required: true
type: string
fileAsBase64:
description: 'Generated SDK file as base64 encoded'
required: true
type: string
jobs:
generate:
runs-on: ubuntu-latest
Expand All @@ -36,11 +32,15 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- uses: actions/download-artifact@v3
with:
name: specs
path: openworld/sdk/generator
- name: generate_sdk
working-directory: openworld/sdk/generator
run: |
echo ${{ github.event.inputs.name }}
./scripts/generate-sdk.sh -n "${{ inputs.name }}" -v "${{ inputs.version }}" -i "${{ inputs.fileAsBase64 }}"
./scripts/generate-sdk.sh -n "${{ inputs.name }}" -v "${{ inputs.version }}" -i ./specs.yaml
- uses: actions/upload-artifact@v3
with:
name: sdk
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/generator-download-specs.yaml
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
45 changes: 45 additions & 0 deletions .github/workflows/generator-publish-sources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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: openworld/sdk/generator/package
- uses: actions/download-artifact@v3
with:
name: specs
path: openworld/sdk/generator/package
- name: Publish Code
working-directory: openworld/sdk/generator/package
run: |
git config --global user.email "oss@expediagroup.com"
git config --global user.name "Expedia Group Open Source"
rm -rf ../../../../release/"${{github.event.inputs.name}}"
mkdir -p ../../../../release/"${{github.event.inputs.name}}"
tar -xzf *.tar.gz
rm *.tar.gz
find ./ -name \*.py -exec cp {} ../../../../release/"${{github.event.inputs.name}}"/ \;
find ./ -name \*.yaml -exec cp {} ../../../../release/"${{github.event.inputs.name}}"/ \;
git fetch --depth=1 origin main
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.yaml
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
2 changes: 1 addition & 1 deletion .github/workflows/publish-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
required: false
type: string
jobs:
job:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
Expand Down
2 changes: 0 additions & 2 deletions openworld/sdk/generator/client/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
# 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.


from parser import OpenApiParser
from pathlib import Path
from typing import Optional
Expand Down
4 changes: 2 additions & 2 deletions openworld/sdk/generator/scripts/generate-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ while getopts ":n:v:i:" OPTION; do
esac
done; validate_arguments

cp $input_spec ./client/spec.yaml
pip3 install -r client/requirements.txt &&\
python3 scripts/prepare-spec.py -i "$input_spec" &&\
scripts/generate-client.sh -i "$(pwd)/specs/spec.yaml" -v "$sdk_version" -n "$sdk_namespace" &&\
scripts/generate-client.sh -i "spec.yaml" -v "$sdk_version" -n "$sdk_namespace" &&\
scripts/build-package.sh -n "$sdk_namespace"
44 changes: 0 additions & 44 deletions openworld/sdk/generator/scripts/prepare-spec.py

This file was deleted.

0 comments on commit c7947ff

Please sign in to comment.