Update test-coverage.yaml #9
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
| # R-focused test coverage workflow for GitHub Actions | |
| # Optimized for Codecov and modern R package testing | |
| name: test-coverage | |
| on: | |
| push: | |
| branches: [main, master] | |
| pull_request: | |
| branches: [main, master] | |
| permissions: | |
| contents: read | |
| jobs: | |
| test-coverage: | |
| runs-on: ubuntu-latest | |
| env: | |
| GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
| R_KEEP_PKG_SOURCE: yes | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up R | |
| uses: r-lib/actions/setup-r@v2 | |
| with: | |
| use-public-rspm: true | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get -y install \ | |
| libcurl4-gnutls-dev coinor-libsymphony-dev \ | |
| libudunits2-dev libgdal-dev libgeos-dev libproj-dev libglpk-dev \ | |
| libgmp3-dev libmpfr-dev chromium-browser | |
| - name: Install R package dependencies | |
| uses: r-lib/actions/setup-r-dependencies@v2 | |
| with: | |
| extra-packages: | | |
| any::covr | |
| any::testthat | |
| any::xml2 | |
| any::remotes | |
| any::lpsymphony | |
| pak-arguments: --upgrade | |
| - name: Check covr version | |
| run: | | |
| print(packageVersion("covr")) | |
| print(find.package("covr")) | |
| sessionInfo() | |
| shell: Rscript {0} | |
| - name: Run tests and generate coverage | |
| run: | | |
| cov <- covr::package_coverage() | |
| covr::to_lcov(cov, file = "coverage.lcov") | |
| shell: Rscript {0} | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| file: coverage.lcov | |
| fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }} | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Show testthat output | |
| if: always() | |
| run: | | |
| find . -name 'testthat.Rout*' -exec cat '{}' \; || true | |
| shell: bash | |
| - name: Upload test results (on failure) | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-test-failures | |
| path: . |