From 28dcd6712d162c1c69c28f252e51ae225e97c5fc Mon Sep 17 00:00:00 2001 From: m-kolomanski Date: Thu, 9 Jan 2025 09:16:28 +0100 Subject: [PATCH] chore: migrated tests to separate file --- .github/workflows/main.yml | 27 ++++--------- .github/workflows/test.yml | 79 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 468da33f..e99598ac 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,6 +32,7 @@ jobs: id: get_r_version run: echo "R_VERSION=$R_VERSION" >> $GITHUB_OUTPUT shell: bash + spellcheck: name: Spelling uses: ./.github/workflows/spellcheck.yml @@ -39,6 +40,7 @@ jobs: needs: get_r_version with: r-version: "${{ needs.get_r_version.outputs.r-version }}" + linter: name: Lint uses: ./.github/workflows/lintr.yml @@ -46,6 +48,7 @@ jobs: if: github.event_name == 'pull_request' with: r-version: "${{ needs.get_r_version.outputs.r-version }}" + man-pages: name: Man Pages uses: ./.github/workflows/man-pages.yml @@ -56,28 +59,12 @@ jobs: tests: name: Tests - runs-on: ubuntu-latest + uses: ./.github/workflows/test.yml needs: get_r_version - container: - image: "ghcr.io/pharmaverse/admiralci-${{ needs.get_r_version.outputs.r-version }}:latest" - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Install system dependencies - run: | - apt-get install -y --no-install-recommends \ - libudunits2-dev - - - name: Install dependencies - run: | - Rscript -e 'remotes::install_deps(dependencies = TRUE)' + if: github.event_name == 'pull_request' + with: + r-version: "${{ needs.get_r_version.outputs.r-version }}" - - name: Run tests - shell: Rscript {0} - run: | - devtools::load_all(".") - devtools::test() check: name: Check uses: ./.github/workflows/r-cmd-check.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..06eff2dc --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,79 @@ +name: Spelling + +on: + workflow_dispatch: + inputs: + r-version: + description: "The version of R to use" + default: "release" + required: false + type: choice + options: + - devel + - latest + workflow_call: + inputs: + r-version: + description: "The version of R to use" + default: "release" + required: false + type: string + +concurrency: + group: spelling-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + tests: + name: Tests + runs-on: ubuntu-latest + container: + image: "ghcr.io/pharmaverse/admiralci-${{ inputs.r-version }}:latest" + steps: + - name: Get branch names + id: branch-name + uses: tj-actions/branch-names@v8 + + - name: Checkout repo (PR) 🛎 + uses: actions/checkout@v4.2.2 + if: github.event_name == 'pull_request' + with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + + - name: Checkout repository + uses: actions/checkout@v4.2.2 + if: github.event_name != 'pull_request' + with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} + + - name: Restore cache + uses: actions/cache@v4 + with: + path: | + ~/.staged.dependencies + key: staged-deps + + - name: Run Staged dependencies + uses: insightsengineering/staged-dependencies-action@v1 + with: + run-system-dependencies: true + renv-restore: false + enable-check: false + direction: upstream + git-ref: ${{ steps.branch-name.outputs.current_branch }} + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + - name: Install dependencies from DESCRIPTION + run: | + remotes::install_local(force = TRUE, dependencies = TRUE) + shell: Rscript {0} + env: + R_REMOTES_STANDALONE: "true" + + - name: Run tests + shell: Rscript {0} + run: | + devtools::load_all(".") + devtools::test() \ No newline at end of file