Workflow improvement #159
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This workflow will install R, Rsirius dependencies and test the Rsirius package using testthat | |
| # For more information see: https://github.com/r-lib/actions | |
| name: RTest | |
| 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: | |
| build: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| 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: 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} |