Skip to content

Commit

Permalink
Merge pull request #34 from phoenixnap/release/v1.3.0
Browse files Browse the repository at this point in the history
Release/v1.3.0
  • Loading branch information
valerioponte authored Mar 9, 2023
2 parents 68abe12 + 8814e08 commit 1300004
Show file tree
Hide file tree
Showing 57 changed files with 962 additions and 788 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/_common.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: (internal) - Build, Lint, Test

on:
workflow_call:
inputs:
package-name:
required: true
type: string
test-file:
required: true
type: string

jobs:
lint:
name: Lint ${{ inputs.package-name }}
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v3
- uses: ./.github/workflows/composite/lint-sdk
with:
package-name: ${{ inputs.package-name }}
test:
name: Test ${{ inputs.package-name }}
runs-on: ubuntu-18.04
needs:
- lint
services:
mockserver:
image: mockserver/mockserver:5.13.0
ports:
- 1080:1080
strategy:
fail-fast: false
matrix:
python-version: [ '3.6', '3.11' ]
steps:
- uses: actions/checkout@v3
- uses: ./.github/workflows/composite/test-sdk
with:
package-under-test: ./${{ inputs.package-name }}
test-dir: tests
test-file: ${{ inputs.test-file }}
test-report-dir: tests/test-reports
python-version: ${{ matrix.python-version }}
23 changes: 23 additions & 0 deletions .github/workflows/_generate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: (internal) - Generate

on:
workflow_call:
inputs:
spec-link:
required: true
type: string
package-name:
required: true
type: string


jobs:
generate:
name: Generate ${{ inputs.package-name }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/workflows/composite/generate-sdk
with:
spec-link: ${{ inputs.spec-link }}
package-name: ${{ inputs.package-name }}
62 changes: 62 additions & 0 deletions .github/workflows/_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: (internal) - Publish

on:
workflow_call:
inputs:
package-name:
required: true
type: string
secrets:
PYPI_API_KEY:
required: true

jobs:
check-release:
name: Check Release
runs-on: ubuntu-18.04
outputs:
module: ${{ inputs.package-name }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- name: Determining release type
id: step1
run: |
TAG=${{ github.ref }}
IFS='/' read -r -a array <<< "${TAG#refs/*/}"
if [ "${#array[@]}" -eq "2" ]; then
PACKAGE=${array[0]}
VERSION=${array[1]}
echo Is subpackage release. Publishing $PACKAGE v$VERSION to registry.
echo "package=$PACKAGE" >> $GITHUB_OUTPUT
else
echo Is main release. Skipping.
fi
publish-python-gems:
name: Publish to Python Package Index
if: needs.check-release.outputs.module != 0
runs-on: ubuntu-18.04
needs: check-release
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- uses: ./.github/workflows/composite/setup-python
- name: "Install Dependencies for Packaging"
run: |
pip3 install twine
pip3 install wheel
pip3 install --requirement ${{ needs.check-release.outputs.package }}/requirements.txt
- name: "Build Package"
run: |
cd ${{ needs.check-release.outputs.package }}
python3 setup.py sdist bdist_wheel
- name: "Publish Package"
run: |
cd ${{ needs.check-release.outputs.package }}
twine upload dist/* -u __token__ -p ${{ secrets.PYPI_API_KEY }}
14 changes: 0 additions & 14 deletions .github/workflows/composite/generate-sdk/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,18 @@ runs:
run: |
echo "head_ref = ${{ github.head_ref }}"
echo "ref_name = ${{ github.ref_name }}"
- name: Check if Release Branch
shell: bash
if: |
startsWith(github.head_ref, 'hotfix') == false && startsWith(github.head_ref, 'release') == false && github.head_ref != 'master' &&
startsWith(github.ref_name, 'hotfix') == false && startsWith(github.ref_name, 'release') == false && github.ref_name != 'master'
id: checkReleaseBranch
run: |
echo "Ref isn't a PR from (master / release... / hotfix...) or a branch with name (master / release... / hotfix...) - Continue with generation."
echo "::set-output name=IS_FEATURE_BRANCH::true"
- name: Install node
if: ${{ steps.checkReleaseBranch.outputs.IS_FEATURE_BRANCH }}
uses: actions/setup-node@v2
- name: Install openapi-generator-cli
if: ${{ steps.checkReleaseBranch.outputs.IS_FEATURE_BRANCH }}
shell: bash
run: npm install -g @openapitools/openapi-generator-cli
- name: Download spec files
if: ${{ steps.checkReleaseBranch.outputs.IS_FEATURE_BRANCH }}
shell: bash
run: wget ${{ inputs.spec-link }} -O ./${{ inputs.package-name }}/${{ inputs.package-name }}.spec.yaml
- name: Generate API
if: ${{ steps.checkReleaseBranch.outputs.IS_FEATURE_BRANCH }}
shell: bash
run: openapi-generator-cli generate -i ${{ inputs.spec-link }} -c openapi-generator-config.yaml -o=${{ inputs.package-name }} --additional-properties packageName=${{ inputs.package-name }}
- name: Upload Artifacts
if: ${{ steps.checkReleaseBranch.outputs.IS_FEATURE_BRANCH }}
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.package-name }}
Expand Down
99 changes: 99 additions & 0 deletions .github/workflows/generate-all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: generate-all

on:
schedule:
- cron: '15 */4 * * *'
push:
branches:
- 'develop'
- 'feature/**'
- 'chore/**'
- 'bugfix/**'
- 'story/**'
workflow_dispatch:

jobs:
prerequisite:
name: Prerequisite for Generation
if: github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/heads/feature')
runs-on: ubuntu-latest
steps:
- name: Prerequisite
run: |
echo Prerequisites passed!
generate-bmcapi:
needs: prerequisite
uses: ./.github/workflows/_generate.yml
with:
spec-link: https://developers.phoenixnap.com/portals/api/sites/phoenixnap-prod-developerportal/liveportal/apis/bmc/download_spec
package-name: pnap_bmc_api
generate-ranchersolutionapi:
needs: prerequisite
uses: ./.github/workflows/_generate.yml
with:
spec-link: https://developers.phoenixnap.com/portals/api/sites/phoenixnap-prod-developerportal/liveportal/apis/rancher/download_spec
package-name: pnap_rancher_solution_api
generate-networkapi:
needs: prerequisite
uses: ./.github/workflows/_generate.yml
with:
spec-link: https://developers.phoenixnap.com/portals/api/sites/phoenixnap-prod-developerportal/liveportal/apis/networks/download_spec
package-name: pnap_network_api
generate-ipapi:
needs: prerequisite
uses: ./.github/workflows/_generate.yml
with:
spec-link: https://developers.phoenixnap.com/portals/api/sites/phoenixnap-prod-developerportal/liveportal/apis/ips/download_spec
package-name: pnap_ip_api
generate-auditapi:
needs: prerequisite
uses: ./.github/workflows/_generate.yml
with:
spec-link: https://developers.phoenixnap.com/portals/api/sites/phoenixnap-prod-developerportal/liveportal/apis/bmc-audit/download_spec
package-name: pnap_audit_api
generate-tagapi:
needs: prerequisite
uses: ./.github/workflows/_generate.yml
with:
spec-link: https://developers.phoenixnap.com/portals/api/sites/phoenixnap-prod-developerportal/liveportal/apis/tags/download_spec
package-name: pnap_tag_api
generate-networkstorageapi:
needs: prerequisite
uses: ./.github/workflows/_generate.yml
with:
spec-link: https://developers.phoenixnap.com/portals/api/sites/phoenixnap-prod-developerportal/liveportal/apis/network-storage/download_spec
package-name: pnap_network_storage_api

# Push generated code
push-changes:
name: Push Changes
runs-on: ubuntu-latest
needs:
- generate-bmcapi
- generate-ranchersolutionapi
- generate-networkapi
- generate-ipapi
- generate-auditapi
- generate-tagapi
- generate-networkstorageapi
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Download Artifacts
uses: actions/download-artifact@v3
- name: Move spec files
run: |
find . -type f -name "*.spec.yaml" -not -path "./specs/*" -print0 | xargs -0 mv -ft ./specs/
- name: Add and Commit files
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add -A
if test "$(git status --porcelain=v1 2>/dev/null | wc -l)" -gt "0" ; then git commit -m "Add changes"; else echo No changes found; fi
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
Loading

0 comments on commit 1300004

Please sign in to comment.