|
| 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 |
1 | 3 | on: |
2 | 4 | push: |
3 | | - branches: |
4 | | - - main |
5 | | - - master |
| 5 | + branches: [main, master] |
6 | 6 | pull_request: |
7 | | - branches: |
8 | | - - main |
9 | | - - master |
10 | 7 |
|
11 | | -name: test-coverage |
| 8 | +name: test-coverage.yaml |
| 9 | + |
| 10 | +permissions: read-all |
12 | 11 |
|
13 | 12 | jobs: |
14 | 13 | test-coverage: |
15 | | - runs-on: macOS-latest |
| 14 | + runs-on: ubuntu-latest |
16 | 15 | env: |
17 | 16 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} |
| 17 | + |
18 | 18 | steps: |
19 | | - - uses: actions/checkout@v2 |
| 19 | + - uses: actions/checkout@v4 |
20 | 20 |
|
21 | | - - uses: r-lib/actions/setup-r@v1 |
| 21 | + - uses: r-lib/actions/setup-r@v2 |
| 22 | + with: |
| 23 | + use-public-rspm: true |
22 | 24 |
|
23 | | - - uses: r-lib/actions/setup-pandoc@v1 |
| 25 | + - uses: r-lib/actions/setup-r-dependencies@v2 |
| 26 | + with: |
| 27 | + extra-packages: any::covr, any::xml2 |
| 28 | + needs: coverage |
24 | 29 |
|
25 | | - - name: Query dependencies |
| 30 | + - name: Test coverage |
26 | 31 | run: | |
27 | | - install.packages('remotes') |
28 | | - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) |
29 | | - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") |
| 32 | + cov <- covr::package_coverage( |
| 33 | + quiet = FALSE, |
| 34 | + clean = FALSE, |
| 35 | + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") |
| 36 | + ) |
| 37 | + print(cov) |
| 38 | + covr::to_cobertura(cov) |
30 | 39 | shell: Rscript {0} |
31 | 40 |
|
32 | | - - name: Cache R packages |
33 | | - uses: actions/cache@v2 |
| 41 | + - uses: codecov/codecov-action@v5 |
34 | 42 | with: |
35 | | - path: ${{ env.R_LIBS_USER }} |
36 | | - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} |
37 | | - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- |
38 | | - |
39 | | - - name: Install dependencies |
| 43 | + # Fail if error if not on PR, or if on PR and token is given |
| 44 | + fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }} |
| 45 | + files: ./cobertura.xml |
| 46 | + plugins: noop |
| 47 | + disable_search: true |
| 48 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 49 | + |
| 50 | + - name: Show testthat output |
| 51 | + if: always() |
40 | 52 | run: | |
41 | | - install.packages(c("remotes")) |
42 | | - remotes::install_deps(dependencies = TRUE) |
43 | | - remotes::install_cran("covr") |
44 | | - shell: Rscript {0} |
| 53 | + ## -------------------------------------------------------------------- |
| 54 | + find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true |
| 55 | + shell: bash |
45 | 56 |
|
46 | | - - name: Test coverage |
47 | | - run: covr::codecov() |
48 | | - shell: Rscript {0} |
| 57 | + - name: Upload test results |
| 58 | + if: failure() |
| 59 | + uses: actions/upload-artifact@v4 |
| 60 | + with: |
| 61 | + name: coverage-test-failures |
| 62 | + path: ${{ runner.temp }}/package |
0 commit comments