diff --git a/.github/workflows/NewUpdate.yml b/.github/workflows/NewUpdate.yml index 2a082fc8..ed6eb63b 100644 --- a/.github/workflows/NewUpdate.yml +++ b/.github/workflows/NewUpdate.yml @@ -6,163 +6,179 @@ on: target_branch: type: string required: true - + description: "Target branch to put update commits on." + sirius_version: + description: "Optional SIRIUS version to download (e.g. 6.3.3). Leave blank for latest." + type: string + required: false + 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 -nv https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.10.0/openapi-generator-cli-7.10.0.jar -O openapi-generator-cli-7.10.jar - wget -nv https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.16.0/openapi-generator-cli-7.16.0.jar -O openapi-generator-cli-7.16.jar - - name: Download latest Sirius Release - uses: nick-fields/retry@v2 - with: - max_attempts: 5 - timeout_minutes: 5 - command: | + - name: checkout repo + uses: actions/checkout@v3.1.0 + - name: Download latest generators + run: | + mkdir .updater/openapi_generator + cd .updater/openapi_generator + wget -nv https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.10.0/openapi-generator-cli-7.10.0.jar -O openapi-generator-cli-7.10.jar + wget -nv https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.16.0/openapi-generator-cli-7.16.0.jar -O openapi-generator-cli-7.16.jar + - name: Download 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.*linux-x64.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.*linux-x64.zip\"' | sort | tac | head -n 1 | cut -d : -f 2,3 | tr -d \" | wget -nv -i - - echo "Download Complete" - unzip *.zip - echo "Api Ready" - - name: Run Rest Api with strings - run: | - bash .updater/api/sirius/bin/sirius REST --headless --api-mode=STABLE -p 8080 -s & - - name: Update api-docs-strings.json - run: | - while ! nc -z localhost 8080; do sleep 0.1; done - cd .updater/api - wget -nv http://localhost:8080/v3/api-docs -O api-docs-strings.json - - name: Shutdown SIRIUS - run: curl -X POST http://localhost:8080/actuator/shutdown - - name: Run Rest Api with enums - run: | - bash .updater/api/sirius/bin/sirius REST --headless --api-mode=STABLE --enums-as-ref -p 8080 -s & - - name: Update api-docs-enums.json - run: | - while ! nc -z localhost 8080; do sleep 0.1; done - cd .updater/api - wget -nv http://localhost:8080/v3/api-docs -O api-docs-enums.json - - name: Shutdown SIRIUS - run: curl -X POST http://localhost:8080/actuator/shutdown - - name: Update Clients - run: | - # load package version from file - packageVersion=$(cat .updater/api/packageVersion.txt) - - echo "generating Python Code with packageVersion=$packageVersion" - rm -rf client-api_python/generated/docs - rm -rf client-api_python/generated/PySirius - - java -jar .updater/openapi_generator/openapi-generator-cli-7.16.jar generate -i .updater/api/api-docs-enums.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/docs - rm -rf client-api_r/generated/R - - java -jar .updater/openapi_generator/openapi-generator-cli-7.10.jar generate -i .updater/api/api-docs-strings.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 Finished!" - - name: Format Python Package - run: | - cp client-api_python/pysirius_api.py client-api_python/generated/PySirius - cp client-api_python/pysirius_sdk.py client-api_python/generated/PySirius - cp client-api_python/pysirius_helper.py client-api_python/generated/PySirius - - chmod +x ./client-api_python/formatting/format_init.sh - ./client-api_python/formatting/format_init.sh - - name: Format R package - run: | - cp client-api_r/rsirius_sdk.R client-api_r/generated/R/rsirius_sdk.R - cp client-api_r/rsirius_helper.R client-api_r/generated/R/rsirius_helper.R - echo >> client-api_r/generated/NAMESPACE - echo "# SDK" >> client-api_r/generated/NAMESPACE - echo "export(SiriusSDK)" >> client-api_r/generated/NAMESPACE - echo "export(Helper)" >> client-api_r/generated/NAMESPACE - - chmod +x ./client-api_r/patches/list_syntax_fix.sh - ./client-api_r/patches/list_syntax_fix.sh - - chmod +x ./client-api_r/patches/insert_wait_for_job_completion_in_rsirius_api.sh - ./client-api_r/patches/insert_wait_for_job_completion_in_rsirius_api.sh - - name: Remove Sirius Rest Api - run: | - cd .updater/api - rm -rf *sirius* - rm -rf releases.json - echo "Done" - - name: Remove Openapi Generator Files - run: | - rm .updater/openapi_generator/*.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: + + if [ -n "${{ github.event.inputs.sirius_version }}" ]; then + # Manual version provided + version="${{ github.event.inputs.sirius_version }}" + echo "Using manually provided SIRIUS version: $version" + else + # Fallback to automatic latest detection + echo "No version provided — fetching latest release..." + version=$(curl -s https://api.github.com/repos/sirius-ms/sirius/releases/latest | jq -r '.tag_name' | sed 's/^v//') + echo "Latest version: $version" + fi + + echo "$version" > ./packageVersion.txt + url="https://github.com/sirius-ms/sirius/releases/download/v${version}/sirius-${version}-linux-x64.zip" + echo "Downloading from: $url" + wget -nv "$url" -O sirius-${version}-linux-x64.zip + + echo "Unzipping..." + unzip -q sirius-*-linux-x64.zip + echo "API Ready" + - name: Run Rest Api with strings + run: | + bash .updater/api/sirius/bin/sirius REST --headless --api-mode=STABLE -p 8080 -s & + - name: Update api-docs-strings.json + run: | + while ! nc -z localhost 8080; do sleep 0.1; done + cd .updater/api + wget -nv http://localhost:8080/v3/api-docs -O api-docs-strings.json + - name: Shutdown SIRIUS + run: curl -X POST http://localhost:8080/actuator/shutdown + - name: Run Rest Api with enums + run: | + bash .updater/api/sirius/bin/sirius REST --headless --api-mode=STABLE --enums-as-ref -p 8080 -s & + - name: Update api-docs-enums.json + run: | + while ! nc -z localhost 8080; do sleep 0.1; done + cd .updater/api + wget -nv http://localhost:8080/v3/api-docs -O api-docs-enums.json + - name: Shutdown SIRIUS + run: curl -X POST http://localhost:8080/actuator/shutdown + - name: Update Clients + run: | + # load package version from file + packageVersion=$(cat .updater/api/packageVersion.txt) + + echo "generating Python Code with packageVersion=$packageVersion" + rm -rf client-api_python/generated/docs + rm -rf client-api_python/generated/PySirius + + java -jar .updater/openapi_generator/openapi-generator-cli-7.16.jar generate -i .updater/api/api-docs-enums.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/docs + rm -rf client-api_r/generated/R + + java -jar .updater/openapi_generator/openapi-generator-cli-7.10.jar generate -i .updater/api/api-docs-strings.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 Finished!" + - name: Format Python Package + run: | + cp client-api_python/pysirius_api.py client-api_python/generated/PySirius + cp client-api_python/pysirius_sdk.py client-api_python/generated/PySirius + cp client-api_python/pysirius_helper.py client-api_python/generated/PySirius + + chmod +x ./client-api_python/formatting/format_init.sh + ./client-api_python/formatting/format_init.sh + - name: Format R package + run: | + cp client-api_r/rsirius_sdk.R client-api_r/generated/R/rsirius_sdk.R + cp client-api_r/rsirius_helper.R client-api_r/generated/R/rsirius_helper.R + echo >> client-api_r/generated/NAMESPACE + echo "# SDK" >> client-api_r/generated/NAMESPACE + echo "export(SiriusSDK)" >> client-api_r/generated/NAMESPACE + echo "export(Helper)" >> client-api_r/generated/NAMESPACE + + chmod +x ./client-api_r/patches/list_syntax_fix.sh + ./client-api_r/patches/list_syntax_fix.sh + + chmod +x ./client-api_r/patches/insert_wait_for_job_completion_in_rsirius_api.sh + ./client-api_r/patches/insert_wait_for_job_completion_in_rsirius_api.sh + - name: Remove Sirius Rest Api + run: | + cd .updater/api + rm -rf *sirius* + rm -rf releases.json + echo "Done" + - name: Remove Openapi Generator Files + run: | + rm -rf .updater/openapi_generator + 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 + - 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 }} + run: | + version=$(cat .updater/api/packageVersion.txt) + echo "Running RunTests workflow with SIRIUS version: $version" + gh workflow run RunTests.yml --ref ${GITHUB_REF##*/} -f sirius_version="$version" + echo "sleeping for 30min before temp branch removal" + sleep 1800 + # if: steps.lockpull.outcome == 'failure' + - 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 diff --git a/.github/workflows/PythonTest.yml b/.github/workflows/PythonTest.yml index d37b5e2d..185eb03a 100644 --- a/.github/workflows/PythonTest.yml +++ b/.github/workflows/PythonTest.yml @@ -4,11 +4,20 @@ name: PythonTest -on: +on: workflow_dispatch: + inputs: + sirius_version: + description: "SIRIUS version to use for testing" + required: false + type: string workflow_call: + inputs: + sirius_version: + required: false + type: string pull_request: - + jobs: @@ -18,107 +27,124 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ] env: SIRIUS_USER: ${{ secrets.SIRIUS_USER }} SIRIUS_PW: ${{ secrets.SIRIUS_PW }} steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - id: pysirius_install - run: | - python -m pip install --upgrade pip - python -m pip install flake8 - pip install ./client-api_python/generated - echo "Finished Installing" - - name: Cache Sirius Release - id: cache-sirius - uses: actions/cache@v3 - with: - path: .updater/api/sirius - key: sirius - fail-on-cache-miss: true - - name: Change HOME to working directory of runner - run: echo "HOME=/home/runner/work/sirius-client-openAPI" >> $GITHUB_ENV - - name: Download tomato_small project space - run: | - wget -nv ${{ secrets.TOMATO_SMALL_DOWNLOAD_LINK }} -O $HOME/tomato_small.sirius - chmod 666 $HOME/tomato_small.sirius - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 ./client-api_python --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 ./client-api_python --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Unset DISPLAY - run: echo "JAVA_TOOL_OPTIONS=-Djava.awt.headless=true" >> $GITHUB_ENV - - name: Check SIRIUS download - run: | - echo "Show content of cache download (.updater/api/)" - ls -lah .updater/api/ - echo "Show content of cache download (.updater/api/sirius)" - ls -lah .updater/api/sirius - echo "Show content of cache download (.updater/api/sirius/bin)" - ls -lah .updater/api/sirius/bin - - name: Run Rest Api - run: bash .updater/api/sirius/bin/sirius REST -p 8080 -s & - - name: Wait for Api to start - id: api_start - run: while ! nc -z localhost 8080; do sleep 0.1; done - - name: Login to SIRIUS - id: login - run: | - import os - import PySirius - accept_terms = True - account_credentials = PySirius.AccountCredentials(username=os.environ['SIRIUS_USER'], password=os.environ['SIRIUS_PW']) - api = PySirius.SiriusSDK().attach_to_sirius(sirius_port=8080) - api_instance = api.account() - api_response = api_instance.login(accept_terms, account_credentials) - if isinstance(api_response, PySirius.AccountInfo): - print('Login successful!') - exit(0) - else: - print('Login failed, aborting...') - exit(1) - shell: python - - name: Test actuator API - if: always() && steps.api_start.outcome == 'success' && steps.pysirius_install.outcome == 'success' && steps.login.outcome == 'success' - run: python test_actuator_api.py - working-directory: client-api_python/generated/test - - name: Test info API - if: always() && steps.api_start.outcome == 'success' && steps.pysirius_install.outcome == 'success' && steps.login.outcome == 'success' - run: python test_info_api.py - working-directory: client-api_python/generated/test - - name: Test login_and_account API - if: always() && steps.api_start.outcome == 'success' && steps.pysirius_install.outcome == 'success' && steps.login.outcome == 'success' - run: python test_login_and_account_api.py - working-directory: client-api_python/generated/test - - name: Test projects API - if: always() && steps.api_start.outcome == 'success' && steps.pysirius_install.outcome == 'success' && steps.login.outcome == 'success' - run: python test_projects_api.py - working-directory: client-api_python/generated/test - - name: Test compounds API - if: always() && steps.api_start.outcome == 'success' && steps.pysirius_install.outcome == 'success' && steps.login.outcome == 'success' - run: python test_compounds_api.py - working-directory: client-api_python/generated/test - - name: Test searchable_databases API - if: always() && steps.api_start.outcome == 'success' && steps.pysirius_install.outcome == 'success' && steps.login.outcome == 'success' - run: python test_searchable_databases_api.py - working-directory: client-api_python/generated/test - - name: Test features API - if: always() && steps.api_start.outcome == 'success' && steps.pysirius_install.outcome == 'success' && steps.login.outcome == 'success' - run: python test_features_api.py - working-directory: client-api_python/generated/test - - name: Test jobs API - if: always() && steps.api_start.outcome == 'success' && steps.pysirius_install.outcome == 'success' && steps.login.outcome == 'success' - run: python test_jobs_api.py - working-directory: client-api_python/generated/test - - name: Test acceptance - if: always() && steps.api_start.outcome == 'success' && steps.pysirius_install.outcome == 'success' && steps.login.outcome == 'success' - run: python test_acceptance.py - working-directory: client-api_python/generated/test \ No newline at end of file + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + id: pysirius_install + run: | + python -m pip install --upgrade pip + python -m pip install flake8 + pip install ./client-api_python/generated + echo "Finished Installing" + - name: Determine SIRIUS version + id: sirius_version + run: | + if [ -n "${{ inputs.sirius_version }}" ]; then + echo "Using version from workflow input: ${{ inputs.sirius_version }}" + echo "version=${{ inputs.sirius_version }}" >> $GITHUB_OUTPUT + elif [ -f ".updater/api/packageVersion.txt" ]; then + version=$(cat .updater/api/packageVersion.txt) + echo "Using version from packageVersion.txt: $version" + echo "version=$version" >> $GITHUB_OUTPUT + else + echo "No version found — defaulting to latest." + version=$(curl -s https://api.github.com/repos/sirius-ms/sirius/releases/latest | jq -r '.tag_name' | sed 's/^v//') + echo "version=$version" >> $GITHUB_OUTPUT + fi + - name: Download SIRIUS + run: | + version="${{ steps.sirius_version.outputs.version }}" + mkdir -p .updater/api + cd .updater/api + url="https://github.com/sirius-ms/sirius/releases/download/v${version}/sirius-${version}-linux-x64.zip" + echo "Downloading $url" + wget -nv "$url" -O sirius-${version}-linux-x64.zip + unzip -q sirius-${version}-linux-x64.zip + - name: Change HOME to working directory of runner + run: echo "HOME=/home/runner/work/sirius-client-openAPI" >> $GITHUB_ENV + - name: Download tomato_small project space + run: | + wget -nv ${{ secrets.TOMATO_SMALL_DOWNLOAD_LINK }} -O $HOME/tomato_small.sirius + chmod 666 $HOME/tomato_small.sirius + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 ./client-api_python --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 ./client-api_python --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Unset DISPLAY + run: echo "JAVA_TOOL_OPTIONS=-Djava.awt.headless=true" >> $GITHUB_ENV + - name: Check SIRIUS download + run: | + echo "Show content of cache download (.updater/api/)" + ls -lah .updater/api/ + echo "Show content of cache download (.updater/api/sirius)" + ls -lah .updater/api/sirius + echo "Show content of cache download (.updater/api/sirius/bin)" + ls -lah .updater/api/sirius/bin + - name: Run Rest Api + run: bash .updater/api/sirius/bin/sirius REST -p 8080 -s & + - name: Wait for Api to start + id: api_start + run: while ! nc -z localhost 8080; do sleep 0.1; done + - name: Login to SIRIUS + id: login + run: | + import os + import PySirius + accept_terms = True + account_credentials = PySirius.AccountCredentials(username=os.environ['SIRIUS_USER'], password=os.environ['SIRIUS_PW']) + api = PySirius.SiriusSDK().attach_to_sirius(sirius_port=8080) + api_instance = api.account() + api_response = api_instance.login(accept_terms, account_credentials) + if isinstance(api_response, PySirius.AccountInfo): + print('Login successful!') + exit(0) + else: + print('Login failed, aborting...') + exit(1) + shell: python + - name: Test actuator API + if: always() && steps.api_start.outcome == 'success' && steps.pysirius_install.outcome == 'success' && steps.login.outcome == 'success' + run: python test_actuator_api.py + working-directory: client-api_python/generated/test + - name: Test info API + if: always() && steps.api_start.outcome == 'success' && steps.pysirius_install.outcome == 'success' && steps.login.outcome == 'success' + run: python test_info_api.py + working-directory: client-api_python/generated/test + - name: Test login_and_account API + if: always() && steps.api_start.outcome == 'success' && steps.pysirius_install.outcome == 'success' && steps.login.outcome == 'success' + run: python test_login_and_account_api.py + working-directory: client-api_python/generated/test + - name: Test projects API + if: always() && steps.api_start.outcome == 'success' && steps.pysirius_install.outcome == 'success' && steps.login.outcome == 'success' + run: python test_projects_api.py + working-directory: client-api_python/generated/test + - name: Test compounds API + if: always() && steps.api_start.outcome == 'success' && steps.pysirius_install.outcome == 'success' && steps.login.outcome == 'success' + run: python test_compounds_api.py + working-directory: client-api_python/generated/test + - name: Test searchable_databases API + if: always() && steps.api_start.outcome == 'success' && steps.pysirius_install.outcome == 'success' && steps.login.outcome == 'success' + run: python test_searchable_databases_api.py + working-directory: client-api_python/generated/test + - name: Test features API + if: always() && steps.api_start.outcome == 'success' && steps.pysirius_install.outcome == 'success' && steps.login.outcome == 'success' + run: python test_features_api.py + working-directory: client-api_python/generated/test + - name: Test jobs API + if: always() && steps.api_start.outcome == 'success' && steps.pysirius_install.outcome == 'success' && steps.login.outcome == 'success' + run: python test_jobs_api.py + working-directory: client-api_python/generated/test + - name: Test acceptance + if: always() && steps.api_start.outcome == 'success' && steps.pysirius_install.outcome == 'success' && steps.login.outcome == 'success' + run: python test_acceptance.py + working-directory: client-api_python/generated/test \ No newline at end of file diff --git a/.github/workflows/RTest.yml b/.github/workflows/RTest.yml index 4383b2ff..2f5c0d1e 100644 --- a/.github/workflows/RTest.yml +++ b/.github/workflows/RTest.yml @@ -4,7 +4,20 @@ name: RTest -on: [workflow_dispatch, workflow_call, pull_request] +on: + workflow_dispatch: + inputs: + sirius_version: + description: "SIRIUS version to use for testing" + required: false + type: string + workflow_call: + inputs: + sirius_version: + required: false + type: string + pull_request: + jobs: @@ -14,136 +27,154 @@ jobs: strategy: fail-fast: false matrix: - r-version: ["4.1", "4.2", "4.3", "4.4", "4.5"] + r-version: [ "4.1", "4.2", "4.3", "4.4", "4.5" ] env: SIRIUS_USER: ${{ secrets.SIRIUS_USER }} SIRIUS_PW: ${{ secrets.SIRIUS_PW }} steps: - - uses: actions/checkout@v3 - - name: Set up R ${{ matrix.r-version }} - uses: r-lib/actions/setup-r@v2 - with: - r-version: ${{ matrix.r-version }} - - name: Install RSirius dependencies - uses: r-lib/actions/setup-r-dependencies@v2 - with: - cache: false - working-directory: ./client-api_r/generated - - name: Install RSirius - id: rsirius_install - run: | - install.packages("/home/runner/work/sirius-client-openAPI/sirius-client-openAPI/client-api_r/generated", repos = NULL, type = "source") - shell: Rscript {0} - - name: Cache Sirius Release - uses: actions/cache@v3 - with: - path: .updater/api/sirius - key: sirius - fail-on-cache-miss: true - - name: Change HOME to working directory of runner - run: echo "HOME=/home/runner/work/sirius-client-openAPI" >> $GITHUB_ENV - - name: Download tomato_small project space - run: | - wget -nv ${{ secrets.TOMATO_SMALL_DOWNLOAD_LINK }} -O $HOME/tomato_small.sirius - chmod 666 $HOME/tomato_small.sirius - - name: Check SIRIUS download - run: | - echo "Show content of cache download (.updater/api/)" - ls -lah .updater/api/ - echo "Show content of cache download (.updater/api/sirius)" - ls -lah .updater/api/sirius - echo "Show content of cache download (.updater/api/sirius/bin)" - ls -lah .updater/api/sirius/bin - - name: Run Rest Api - run: bash .updater/api/sirius/bin/sirius REST -p 8080 -s & - - name: Wait for Api to start - id: api_start - run: while ! nc -z localhost 8080; do sleep 0.1; done - - name: Login to SIRIUS - id: login - run: | - library(RSirius) - var_accept_terms <- TRUE - var_account_credentials <- AccountCredentials$new(Sys.getenv('SIRIUS_USER'), Sys.getenv('SIRIUS_PW')) - api_instance <- rsirius_api$new() - api_response <- api_instance$login_and_account_api$Login(var_accept_terms, var_account_credentials) - if (inherits(api_response, "AccountInfo")) { - print('Login successful!') - quit(status=0) - } else { - print('Login failed, aborting...') - quit(status=1) - } - shell: Rscript {0} - - name: Test Actuator API - if: always() && steps.api_start.outcome == 'success' && steps.rsirius_install.outcome == 'success' && steps.login.outcome == 'success' - run: | - library(RSirius) - library(testthat) - multi_reporter = MultiReporter$new(reporters=list(SummaryReporter$new(), FailReporter$new())) - test_file("client-api_r/generated/tests/testthat/test_actuator_api.R", reporter=multi_reporter) - shell: Rscript {0} - - name: Test Info API - if: always() && steps.api_start.outcome == 'success' && steps.rsirius_install.outcome == 'success' && steps.login.outcome == 'success' - run: | - library(RSirius) - library(testthat) - multi_reporter = MultiReporter$new(reporters=list(SummaryReporter$new(), FailReporter$new())) - test_file("client-api_r/generated/tests/testthat/test_info_api.R", reporter=multi_reporter) - shell: Rscript {0} - - name: Test Login and Account API - if: always() && steps.api_start.outcome == 'success' && steps.rsirius_install.outcome == 'success' && steps.login.outcome == 'success' - run: | - library(RSirius) - library(testthat) - multi_reporter = MultiReporter$new(reporters=list(SummaryReporter$new(), FailReporter$new())) - test_file("client-api_r/generated/tests/testthat/test_login_and_account_api.R", reporter=multi_reporter) - shell: Rscript {0} - - name: Test Projects API - if: always() && steps.api_start.outcome == 'success' && steps.rsirius_install.outcome == 'success' && steps.login.outcome == 'success' - run: | - library(RSirius) - library(testthat) - multi_reporter = MultiReporter$new(reporters=list(SummaryReporter$new(), FailReporter$new())) - test_file("client-api_r/generated/tests/testthat/test_projects_api.R", reporter=multi_reporter) - shell: Rscript {0} - - name: Test Compounds API - if: always() && steps.api_start.outcome == 'success' && steps.rsirius_install.outcome == 'success' && steps.login.outcome == 'success' - run: | - library(RSirius) - library(testthat) - multi_reporter = MultiReporter$new(reporters=list(SummaryReporter$new(), FailReporter$new())) - test_file("client-api_r/generated/tests/testthat/test_compounds_api.R", reporter=multi_reporter) - shell: Rscript {0} - - name: Test Databases API - if: always() && steps.api_start.outcome == 'success' && steps.rsirius_install.outcome == 'success' && steps.login.outcome == 'success' - run: | - library(RSirius) - library(testthat) - multi_reporter = MultiReporter$new(reporters=list(SummaryReporter$new(), FailReporter$new())) - test_file("client-api_r/generated/tests/testthat/test_searchable_databases_api.R", reporter=multi_reporter) - shell: Rscript {0} - - name: Test Features API - if: always() && steps.api_start.outcome == 'success' && steps.rsirius_install.outcome == 'success' && steps.login.outcome == 'success' - run: | - library(RSirius) - library(testthat) - multi_reporter = MultiReporter$new(reporters=list(SummaryReporter$new(), FailReporter$new())) - test_file("client-api_r/generated/tests/testthat/test_features_api.R", reporter=multi_reporter) - shell: Rscript {0} - - name: Test Jobs API - if: always() && steps.api_start.outcome == 'success' && steps.rsirius_install.outcome == 'success' && steps.login.outcome == 'success' - run: | - library(RSirius) - library(testthat) - multi_reporter = MultiReporter$new(reporters=list(SummaryReporter$new(), FailReporter$new())) - test_file("client-api_r/generated/tests/testthat/test_jobs_api.R", reporter=multi_reporter) - shell: Rscript {0} - - name: Test acceptance - if: always() && steps.api_start.outcome == 'success' && steps.rsirius_install.outcome == 'success' && steps.login.outcome == 'success' - run: | - library(RSirius) - library(testthat) - multi_reporter = MultiReporter$new(reporters=list(SummaryReporter$new(), FailReporter$new())) - test_file("client-api_r/generated/tests/testthat/test_acceptance.R", reporter=multi_reporter) - shell: Rscript {0} \ No newline at end of file + - uses: actions/checkout@v3 + - name: Set up R ${{ matrix.r-version }} + uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.r-version }} + - name: Install RSirius dependencies + uses: r-lib/actions/setup-r-dependencies@v2 + with: + cache: false + working-directory: ./client-api_r/generated + - name: Install RSirius + id: rsirius_install + run: | + install.packages("/home/runner/work/sirius-client-openAPI/sirius-client-openAPI/client-api_r/generated", repos = NULL, type = "source") + shell: Rscript {0} + - name: Determine SIRIUS version + id: sirius_version + run: | + if [ -n "${{ inputs.sirius_version }}" ]; then + echo "Using version from workflow input: ${{ inputs.sirius_version }}" + echo "version=${{ inputs.sirius_version }}" >> $GITHUB_OUTPUT + elif [ -f ".updater/api/packageVersion.txt" ]; then + version=$(cat .updater/api/packageVersion.txt) + echo "Using version from packageVersion.txt: $version" + echo "version=$version" >> $GITHUB_OUTPUT + else + echo "No version found — defaulting to latest." + version=$(curl -s https://api.github.com/repos/sirius-ms/sirius/releases/latest | jq -r '.tag_name' | sed 's/^v//') + echo "version=$version" >> $GITHUB_OUTPUT + fi + - name: Download SIRIUS + run: | + version="${{ steps.sirius_version.outputs.version }}" + mkdir -p .updater/api + cd .updater/api + url="https://github.com/sirius-ms/sirius/releases/download/v${version}/sirius-${version}-linux-x64.zip" + echo "Downloading $url" + wget -nv "$url" -O sirius-${version}-linux-x64.zip + unzip -q sirius-${version}-linux-x64.zip + - name: Change HOME to working directory of runner + run: echo "HOME=/home/runner/work/sirius-client-openAPI" >> $GITHUB_ENV + - name: Download tomato_small project space + run: | + wget -nv ${{ secrets.TOMATO_SMALL_DOWNLOAD_LINK }} -O $HOME/tomato_small.sirius + chmod 666 $HOME/tomato_small.sirius + - name: Check SIRIUS download + run: | + echo "Show content of cache download (.updater/api/)" + ls -lah .updater/api/ + echo "Show content of cache download (.updater/api/sirius)" + ls -lah .updater/api/sirius + echo "Show content of cache download (.updater/api/sirius/bin)" + ls -lah .updater/api/sirius/bin + - name: Run Rest Api + run: bash .updater/api/sirius/bin/sirius REST -p 8080 -s & + - name: Wait for Api to start + id: api_start + run: while ! nc -z localhost 8080; do sleep 0.1; done + - name: Login to SIRIUS + id: login + run: | + library(RSirius) + var_accept_terms <- TRUE + var_account_credentials <- AccountCredentials$new(Sys.getenv('SIRIUS_USER'), Sys.getenv('SIRIUS_PW')) + api_instance <- rsirius_api$new() + api_response <- api_instance$login_and_account_api$Login(var_accept_terms, var_account_credentials) + if (inherits(api_response, "AccountInfo")) { + print('Login successful!') + quit(status=0) + } else { + print('Login failed, aborting...') + quit(status=1) + } + shell: Rscript {0} + - name: Test Actuator API + if: always() && steps.api_start.outcome == 'success' && steps.rsirius_install.outcome == 'success' && steps.login.outcome == 'success' + run: | + library(RSirius) + library(testthat) + multi_reporter = MultiReporter$new(reporters=list(SummaryReporter$new(), FailReporter$new())) + test_file("client-api_r/generated/tests/testthat/test_actuator_api.R", reporter=multi_reporter) + shell: Rscript {0} + - name: Test Info API + if: always() && steps.api_start.outcome == 'success' && steps.rsirius_install.outcome == 'success' && steps.login.outcome == 'success' + run: | + library(RSirius) + library(testthat) + multi_reporter = MultiReporter$new(reporters=list(SummaryReporter$new(), FailReporter$new())) + test_file("client-api_r/generated/tests/testthat/test_info_api.R", reporter=multi_reporter) + shell: Rscript {0} + - name: Test Login and Account API + if: always() && steps.api_start.outcome == 'success' && steps.rsirius_install.outcome == 'success' && steps.login.outcome == 'success' + run: | + library(RSirius) + library(testthat) + multi_reporter = MultiReporter$new(reporters=list(SummaryReporter$new(), FailReporter$new())) + test_file("client-api_r/generated/tests/testthat/test_login_and_account_api.R", reporter=multi_reporter) + shell: Rscript {0} + - name: Test Projects API + if: always() && steps.api_start.outcome == 'success' && steps.rsirius_install.outcome == 'success' && steps.login.outcome == 'success' + run: | + library(RSirius) + library(testthat) + multi_reporter = MultiReporter$new(reporters=list(SummaryReporter$new(), FailReporter$new())) + test_file("client-api_r/generated/tests/testthat/test_projects_api.R", reporter=multi_reporter) + shell: Rscript {0} + - name: Test Compounds API + if: always() && steps.api_start.outcome == 'success' && steps.rsirius_install.outcome == 'success' && steps.login.outcome == 'success' + run: | + library(RSirius) + library(testthat) + multi_reporter = MultiReporter$new(reporters=list(SummaryReporter$new(), FailReporter$new())) + test_file("client-api_r/generated/tests/testthat/test_compounds_api.R", reporter=multi_reporter) + shell: Rscript {0} + - name: Test Databases API + if: always() && steps.api_start.outcome == 'success' && steps.rsirius_install.outcome == 'success' && steps.login.outcome == 'success' + run: | + library(RSirius) + library(testthat) + multi_reporter = MultiReporter$new(reporters=list(SummaryReporter$new(), FailReporter$new())) + test_file("client-api_r/generated/tests/testthat/test_searchable_databases_api.R", reporter=multi_reporter) + shell: Rscript {0} + - name: Test Features API + if: always() && steps.api_start.outcome == 'success' && steps.rsirius_install.outcome == 'success' && steps.login.outcome == 'success' + run: | + library(RSirius) + library(testthat) + multi_reporter = MultiReporter$new(reporters=list(SummaryReporter$new(), FailReporter$new())) + test_file("client-api_r/generated/tests/testthat/test_features_api.R", reporter=multi_reporter) + shell: Rscript {0} + - name: Test Jobs API + if: always() && steps.api_start.outcome == 'success' && steps.rsirius_install.outcome == 'success' && steps.login.outcome == 'success' + run: | + library(RSirius) + library(testthat) + multi_reporter = MultiReporter$new(reporters=list(SummaryReporter$new(), FailReporter$new())) + test_file("client-api_r/generated/tests/testthat/test_jobs_api.R", reporter=multi_reporter) + shell: Rscript {0} + - name: Test acceptance + if: always() && steps.api_start.outcome == 'success' && steps.rsirius_install.outcome == 'success' && steps.login.outcome == 'success' + run: | + library(RSirius) + library(testthat) + multi_reporter = MultiReporter$new(reporters=list(SummaryReporter$new(), FailReporter$new())) + test_file("client-api_r/generated/tests/testthat/test_acceptance.R", reporter=multi_reporter) + shell: Rscript {0} \ No newline at end of file diff --git a/.github/workflows/RunTests.yml b/.github/workflows/RunTests.yml index 44d801da..0f378d31 100644 --- a/.github/workflows/RunTests.yml +++ b/.github/workflows/RunTests.yml @@ -1,13 +1,28 @@ -# This workflow will start all individual Tests - name: RunTests -on: [workflow_dispatch, workflow_call, pull_request] +on: + workflow_dispatch: + inputs: + sirius_version: + description: "SIRIUS version to test (passed from NewUpdate)" + required: false + type: string + workflow_call: + inputs: + sirius_version: + required: false + type: string + pull_request: jobs: RTest: uses: ./.github/workflows/RTest.yml secrets: inherit + with: + sirius_version: ${{ inputs.sirius_version }} + PythonTest: uses: ./.github/workflows/PythonTest.yml secrets: inherit + with: + sirius_version: ${{ inputs.sirius_version }} diff --git a/.github/workflows/SetupBranch.yml b/.github/workflows/SetupBranch.yml index 4c6cf3f5..cc05ccc8 100644 --- a/.github/workflows/SetupBranch.yml +++ b/.github/workflows/SetupBranch.yml @@ -1,33 +1,40 @@ - name: SetupBranch -# Controls when the action will run. Workflow runs when manually triggered using the UI -# or API. on: workflow_dispatch: inputs: target_branch: type: string required: true - - + description: "Temporary branch to create (NewUpdate will commit to that branch)." + sirius_version: + description: "Optional: specify SIRIUS version to use (e.g. 6.3.3)" + required: false + type: string + jobs: CreateTempBranch: runs-on: ubuntu-latest steps: - - name: Create Branch - uses: peterjgrainger/action-create-branch@v2.2.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - branch: ${{ inputs.target_branch }} + - name: Create Branch + uses: peterjgrainger/action-create-branch@v3.0.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + branch: ${{ inputs.target_branch }} + UpdateOnNewBranch: needs: CreateTempBranch runs-on: ubuntu-latest steps: - name: checkout repo - uses: actions/checkout@v3.1.0 - - name: Call Workflow - run: gh workflow run NewUpdate.yml --ref ${{ inputs.target_branch }} -f target_branch=${GITHUB_REF##*/} + uses: actions/checkout@v3 + - name: Call NewUpdate + run: | + if [ -n "${{ inputs.sirius_version }}" ]; then + gh workflow run NewUpdate.yml --ref ${{ inputs.target_branch }} -f target_branch=${GITHUB_REF##*/} -f sirius_version=${{ inputs.sirius_version }} + else + gh workflow run NewUpdate.yml --ref ${{ inputs.target_branch }} -f target_branch=${GITHUB_REF##*/} + fi env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/update-api.yml b/.github/workflows/update-api.yml deleted file mode 100644 index 37293bb0..00000000 --- a/.github/workflows/update-api.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: UpdateApi -on: [workflow_call, workflow_dispatch] -jobs: - build: - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - uses: actions/checkout@v3 - - name: Cache Sirius Release - id: cache-sirius - uses: actions/cache@v3 - with: - path: .updater/api/sirius - key: sirius - - name: Check if cache is Empty - if: steps.cache-sirius.outputs.cache-hit != 'true' - uses: nick-fields/retry@v2 - with: - max_attempts: 5 - timeout_minutes: 2 - command: | - cd .updater/api - curl -s https://api.github.com/repositories/94561614/releases | grep 'browser_download_url.*linux-x64.zip\"' | sort | tac | head -n 1 | cut -d : -f 2,3 | tr -d \" | wget -nv -i - echo "Download Complete" - unzip -o *.zip - echo "Api Ready" - - name: Check cached version - uses: nick-fields/retry@v2 - with: - max_attempts: 5 - timeout_minutes: 2 - command: | - cd .updater/api - currVersion=$(cat ./sirius/HashCode) - curl -s https://api.github.com/repositories/94561614/releases | grep 'browser_download_url.*linux-x64.zip\"' | sort | tac | head -n 1 | cut -d : -f 2,3 | tr -d \" | wget -nv -i - newVersion=$(cat *.sha256 | cut -d " " -f 1) - echo New Version is $newVersion - if [ "$currVersion" != "$newVersion" ]; then - sleep 1 - curl -s https://api.github.com/repositories/94561614/releases | grep 'browser_download_url.*linux-x64.zip\"' | sort | tac | head -n 1 | cut -d : -f 2,3 | tr -d \" | wget -nv -i - - unzip -o *.zip - echo $newVersion > ./sirius/HashCode - fi \ No newline at end of file diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml index e70438eb..9fc58c45 100644 --- a/.github/workflows/updater.yml +++ b/.github/workflows/updater.yml @@ -1,32 +1,32 @@ -# This is a basic workflow that is manually triggered - name: Client_Updater -# Controls when the action will run. Workflow runs when manually triggered using the UI -# or API. on: - [workflow_dispatch, repository_dispatch] - # Inputs the workflow accepts. -# inputs: - # name: - # # Friendly description to be shown in the UI instead of 'name' - # description: 'Person to greet' - # # Default value if no value is explicitly provided - ## default: 'World' - # # Input has to be provided for the workflow to run - #required: true + workflow_dispatch: + inputs: + sirius_version: + description: "Optional: specify SIRIUS version to use (e.g. 6.3.3)" + required: false + type: string + repository_dispatch: -# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - # does not run on the temp branch itself - UpdateCache: - uses: ./.github/workflows/update-api.yml UpdateOnNewBranch: runs-on: ubuntu-latest + outputs: + target_branch: ${{ steps.setup.outputs.target_branch }} steps: - name: checkout repo - uses: actions/checkout@v3.1.0 - - name: Call Workflow - run: gh workflow run SetupBranch.yml --ref ${GITHUB_REF##*/} -f target_branch=$(echo -en temp_;date +"%Y%m%d%H%M%S%N") + uses: actions/checkout@v3 + - name: Call SetupBranch + id: setup + run: | + target_branch=$(echo -en temp_;date +"%Y%m%d%H%M%S%N") + echo "target_branch=$target_branch" >> $GITHUB_OUTPUT + + if [ -n "${{ inputs.sirius_version }}" ]; then + gh workflow run SetupBranch.yml --ref ${GITHUB_REF##*/} -f target_branch=$target_branch -f sirius_version=${{ inputs.sirius_version }} + else + gh workflow run SetupBranch.yml --ref ${GITHUB_REF##*/} -f target_branch=$target_branch + fi env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/client-api_python/README.md b/client-api_python/README.md index 1ed09fb1..15404336 100644 --- a/client-api_python/README.md +++ b/client-api_python/README.md @@ -1,8 +1,9 @@ # PySirius REST API that provides the full functionality of SIRIUS and its web services as background service. It is intended as entry-point for scripting languages and software integration SDKs. -- to [fine-grained documentation](#documentation-for-api-endpoints) -- to our [example workflow](#example-usage-of-pysirius) +- To our [example workflow](#example-usage-of-pysirius) +- To the [fine-grained documentation](#documentation-for-api-endpoints) +- To the [tests](generated/test/) ## Installation & Usage diff --git a/client-api_r/README.md b/client-api_r/README.md index 89ed5c22..b285b222 100644 --- a/client-api_r/README.md +++ b/client-api_r/README.md @@ -7,8 +7,9 @@ REST API that provides the full functionality of SIRIUS and its web services as background service. It is intended as entry-point for scripting languages and software integration SDKs. -- to [fine-grained documentation](#documentation-for-api-endpoints) -- to our [example workflow](#example-usage-of-rsirius) +- To our [example workflow](#example-usage-of-rsirius) +- To the [fine-grained documentation](#documentation-for-api-endpoints) +- To the [tests](generated/tests/testthat/) ## Installation & Usage