28 add testthat tests #47
Workflow file for this run
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
| name: test-coverage | |
| on: | |
| push: | |
| branches: ['**'] | |
| pull_request: | |
| branches: [develop] | |
| types: [opened, reopened, synchronize, ready_for_review] | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: write | |
| checks: write | |
| statuses: read | |
| pull-requests: write | |
| jobs: | |
| test-coverage: | |
| # Skip draft PRs; run on non-PR triggers and non-draft PR events | |
| if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }} | |
| runs-on: ubuntu-latest | |
| env: | |
| GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
| EQ_API_KEY: ${{ secrets.EQ_API_KEY }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: r-lib/actions/setup-r@v2 | |
| with: | |
| use-public-rspm: true | |
| - uses: r-lib/actions/setup-r-dependencies@v2 | |
| with: | |
| extra-packages: | | |
| any::covr | |
| any::xml2 | |
| - name: Capture Environment Info | |
| run: | | |
| Rscript -e ' | |
| env_vars <- Sys.getenv() | |
| pkg_versions <- installed.packages()[, c("Package", "Version")] | |
| sys_info <- Sys.info() | |
| save(env_vars, pkg_versions, sys_info, file = "ci_env_info.RData") | |
| ' | |
| - name: Upload Environment Info | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ci_env_info | |
| path: ci_env_info.RData | |
| - name: Test coverage | |
| shell: Rscript {0} | |
| run: | | |
| cov <- covr::package_coverage( | |
| quiet = FALSE, | |
| clean = FALSE, | |
| install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") | |
| ) | |
| print(cov) | |
| covr::to_cobertura(cov, file = "cobertura.xml") | |
| - name: Show testthat output | |
| if: always() | |
| run: | | |
| find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true | |
| shell: bash | |
| - name: Upload test results | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-test-failures | |
| path: ${{ runner.temp }}/package | |
| if-no-files-found: ignore | |
| - name: Upload coverage report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: ./cobertura.xml | |
| - name: Comment coverage | |
| uses: 5monkeys/cobertura-action@master | |
| with: | |
| report_name: coverage-report | |
| path: ./cobertura.xml | |
| minimum_coverage: 10 | |
| only_changed_files: false | |
| show_missing: true | |
| link_missing_lines: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |