|
| 1 | +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples |
| 2 | +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, master, devel] |
| 6 | + pull_request: |
| 7 | + |
| 8 | +name: test-coverage.yaml |
| 9 | + |
| 10 | +permissions: read-all |
| 11 | + |
| 12 | +jobs: |
| 13 | + test-coverage: |
| 14 | + runs-on: ${{ matrix.config.os }} |
| 15 | + |
| 16 | + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) |
| 17 | + |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + config: |
| 22 | + - { os: ubuntu-latest, r: "release" } |
| 23 | + # - { os: macos-latest, r: "release" } |
| 24 | + |
| 25 | + env: |
| 26 | + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} |
| 27 | + |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v4 |
| 30 | + |
| 31 | + - uses: r-lib/actions/setup-r@v2 |
| 32 | + with: |
| 33 | + r-version: ${{ matrix.config.r }} |
| 34 | + http-user-agent: ${{ matrix.config.http-user-agent }} |
| 35 | + use-public-rspm: true |
| 36 | + |
| 37 | + - uses: r-lib/actions/setup-r-dependencies@v2 |
| 38 | + with: |
| 39 | + extra-packages: any::covr, any::xml2 |
| 40 | + needs: coverage |
| 41 | + |
| 42 | + - name: Test coverage |
| 43 | + run: | |
| 44 | + cov <- covr::package_coverage( |
| 45 | + quiet = FALSE, |
| 46 | + clean = FALSE, |
| 47 | + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") |
| 48 | + ) |
| 49 | + print(cov) |
| 50 | + covr::to_cobertura(cov) |
| 51 | + shell: Rscript {0} |
| 52 | + |
| 53 | + - uses: codecov/codecov-action@v5 |
| 54 | + with: |
| 55 | + # Fail if error if not on PR, or if on PR and token is given |
| 56 | + # fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }} |
| 57 | + fail_ci_if_error: false |
| 58 | + config: codecov.yaml |
| 59 | + files: cobertura.xml |
| 60 | + plugins: noop |
| 61 | + disable_search: true |
| 62 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 63 | + |
| 64 | + - name: Show testthat output |
| 65 | + if: always() |
| 66 | + run: | |
| 67 | + ## -------------------------------------------------------------------- |
| 68 | + find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true |
| 69 | + shell: bash |
| 70 | + |
| 71 | + - name: Upload test results |
| 72 | + if: failure() |
| 73 | + uses: actions/upload-artifact@v4 |
| 74 | + with: |
| 75 | + name: coverage-test-failures |
| 76 | + path: ${{ runner.temp }}/package |
0 commit comments