Skip to content

NewUpdate

NewUpdate #245

Workflow file for this run

name: NewUpdate
on:
workflow_dispatch:
inputs:
target_branch:
type: string
required: true
jobs:
UpdateClients:
# The type of runner that the job will run on
runs-on: ubuntu-latest
timeout-minutes: 90
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Runs using the runners shell
- name: checkout repo
uses: actions/checkout@v3.1.0
- name: Download latest generators
run: |
cd .updater/openapi_generator
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.6.0/openapi-generator-cli-7.6.0.jar -O openapi-generator-cli.jar
java -jar openapi-generator-cli.jar version > version
- name: Download latest Sirius Release
uses: nick-fields/retry@v2
with:
max_attempts: 5
timeout_minutes: 5
command: |
cd .updater/api
curl -s https://api.github.com/repositories/94561614/releases > ./releases.json
packageVersion=$(cat ./releases.json | grep 'name.*linux64.zip\"' | sort | tac | head -n 1 | cut -d - -f 2)
echo "Writing Version files: $packageVersion"
echo $packageVersion > ./packageVersion.txt
echo "Downloading Version: $packageVersion"
cat ./releases.json | grep 'browser_download_url.*linux64.zip\"' | sort | tac | head -n 1 | cut -d : -f 2,3 | tr -d \" | wget -i -
echo "Download Complete"
unzip *.zip
echo "Api Ready"
- name: Run Rest Api
run: |
bash .updater/api/sirius/bin/sirius REST --no-headless --api-mode=STABLE -p 8080 -s &
- name: Update api-docs.json
run: |
while ! nc -z localhost 8080; do sleep 0.1; done
cd .updater/api
wget http://localhost:8080/v3/api-docs -O api-docs.json
- name: Update Clients
run: |
# load package version from file
packageVersion=$(cat .updater/api/packageVersion.txt)
# echo "generating Java Code with packageVersion=$packageVersion"
# rm -rf client-api_java/generated/*
# java -jar .updater/openapi_generator/openapi-generator-cli.jar generate -i .updater/api/api-docs.json -c .updater/config/Java/config.json -g java -o client-api_java/generated
echo "generating Python Code with packageVersion=$packageVersion"
rm -rf client-api_python/generated/*
java -jar .updater/openapi_generator/openapi-generator-cli.jar generate -i .updater/api/api-docs.json -c .updater/config/Python/config.json -g python -o client-api_python/generated -t client-api_python/templates/python --additional-properties=packageVersion=$packageVersion
echo "temporarily move R manual folder"
mv client-api_r/generated/man/ client-api_r/
echo "generating R Code with packageVersion=$packageVersion"
rm -rf client-api_r/generated/*
java -jar .updater/openapi_generator/openapi-generator-cli.jar generate -i .updater/api/api-docs.json -c .updater/config/R/config.json -g r -o client-api_r/generated -t client-api_r/templates/r --additional-properties=packageVersion=$packageVersion
echo "recover R manual folder"
mv client-api_r/man/ client-api_r/generated/
# echo "generating Ruby Code"
# rm -rf client-api_ruby/generated/*
# java -jar .updater/openapi_generator/openapi-generator-cli.jar generate -i .updater/api/api-docs.json -c .updater/config/Ruby/config.json -g ruby -o client-api_ruby/generated
echo "generating Finished!"
- name: Format Python Package
run: |
cp client-api_python/sirius_api.py client-api_python/generated/PySirius
cp client-api_python/sirius.py client-api_python/generated/PySirius
echo "from PySirius.sirius_api import PySiriusAPI" >> client-api_python/generated/PySirius/__init__.py
echo "from PySirius.sirius import SiriusSDK" >> client-api_python/generated/PySirius/__init__.py
- name: Format R package
run: |
# rm -r client-api_r/generated/tests
cp client-api_r/SiriusSDK.R client-api_r/generated/R/SiriusSDK.R
echo >> client-api_r/generated/NAMESPACE
echo "# SDK" >> client-api_r/generated/NAMESPACE
echo "export(SiriusSDK)" >> client-api_r/generated/NAMESPACE
chmod +x ./client-api_r/patches/list_syntax_fix.sh
./client-api_r/patches/list_syntax_fix.sh
- name: Remove Sirius Rest Api
run: |
cd .updater/api
rm -rf *sirius*
rm -rf releases.json
rm -rf packageVersion.txt
echo "Done"
- name: Remove Openapi Generator Files
run: |
rm .updater/openapi_generator/openapi-generator-cli.jar
ls ./.github/workflows
echo "Done"
- name: update file and push to remote
uses: stefanzweifel/git-auto-commit-action@v4.15.2
with:
commit_message: Auto-Updated OpenAPI Clients
- name: Run RManualGeneration
run: |
gh workflow run RManualGeneration.yml --ref ${GITHUB_REF##*/}
echo "dispatched workflow"
echo "sleeping for 30s to make sure it started"
sleep 30
list=$(gh run list --workflow RManualGeneration --branch ${GITHUB_REF##*/})
id=$(echo $list | grep -oP 'in_progress RManualGeneration RManualGeneration [^ ]* workflow_dispatch \K\d+')
echo "run ID of RManualGeneration is: $id"
gh run watch $id --exit-status --interval 3
echo "generation done!"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: update file and create pull request
id: open-pr
uses: repo-sync/pull-request@v2
with:
destination_branch: ${{ inputs.target_branch }}
github_token: ${{ secrets.GITHUB_TOKEN }}
pr_label: "Feature"
pr_title: "AutoUpdated"
pr_allow_empty: true
- name: check if request has been created
run: echo ${{steps.open-pr.outputs.pr_created}}
- name: lock pull request
continue-on-error: true
id: lockpull
uses: sudo-bot/action-pull-request-lock@v1.1.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
number: ${{steps.open-pr.outputs.pr_number}}
lock-reason: resolved
- name: Run tests if no changes occure
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# if: steps.lockpull.outcome == 'failure'
run: |
gh workflow run RunTests.yml --ref ${GITHUB_REF##*/}
echo "sleeping for 30min before temp branch removal"
sleep 1800
- name: Delete temp branches if no changes occure
if: steps.lockpull.outcome == 'failure'
uses: dawidd6/action-delete-branch@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
prefix: temp_
soft_fail: true