|
1 | | -name: Coverage |
2 | | - |
| 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 | 3 | on: |
4 | 4 | push: |
5 | | - branches: |
6 | | - - master |
| 5 | + branches: [main, master] |
7 | 6 | pull_request: |
8 | | - branches: |
9 | | - - master |
| 7 | + branches: [main, master] |
10 | 8 |
|
11 | | -jobs: |
12 | | - cleanup: |
13 | | - name: Cancel Previous Runs |
14 | | - runs-on: ubuntu-latest |
15 | | - steps: |
16 | | - - uses: styfle/cancel-workflow-action@0.12.1 |
17 | | - with: |
18 | | - access_token: ${{ github.token }} |
| 9 | +name: Coverage |
19 | 10 |
|
20 | | - codecov: |
| 11 | +permissions: read-all |
| 12 | + |
| 13 | +jobs: |
| 14 | + test-coverage: |
21 | 15 | if: contains(github.event.head_commit.message, '[ci skip]') == false |
22 | | - name: codecov ${{ matrix.os }} |
23 | | - strategy: |
24 | | - fail-fast: false |
25 | | - matrix: |
26 | | - include: |
27 | | - # - os: ubuntu-latest |
28 | | - # log_file: /tmp/languageserver/ubuntu-log |
29 | | - - os: macos-latest |
30 | | - log_file: /tmp/languageserver/macos-log |
31 | | - # - os: windows-latest |
32 | | - # log_file: C:/tmp/languageserver/windows-log |
33 | | - runs-on: ${{ matrix.os }} |
| 16 | + runs-on: ubuntu-latest |
34 | 17 | env: |
| 18 | + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} |
35 | 19 | NOT_CRAN: true |
36 | 20 | _R_CHECK_CRAN_INCOMING_: false |
37 | 21 | R_LANGSVR_LOG: ${{ matrix.log_file }} |
38 | 22 | R_LANGSVR_POOL_SIZE: 1 |
39 | 23 | R_LANGSVR_TEST_FAST: NO |
| 24 | + |
40 | 25 | steps: |
41 | | - - uses: actions/checkout@v4 |
| 26 | + - uses: actions/checkout@v6 |
42 | 27 | - uses: r-lib/actions/setup-r@v2 |
43 | 28 | with: |
| 29 | + use-public-rspm: true |
44 | 30 | r-version: release |
45 | | - - name: Create log directory on Linux or macOS |
46 | | - if: runner.os != 'Windows' |
47 | | - run: mkdir -p $(dirname ${{ env.R_LANGSVR_LOG }}) |
48 | | - - name: Create log directory on Windows |
49 | | - if: runner.os == 'Windows' |
50 | | - run: New-Item -ItemType directory -Path (Split-Path -Parent ${{ env.R_LANGSVR_LOG }}) |
51 | | - - name: Query dependencies |
| 31 | + |
| 32 | + - uses: r-lib/actions/setup-r-dependencies@v2 |
| 33 | + with: |
| 34 | + extra-packages: any::covr, any::xml2 |
| 35 | + needs: coverage |
| 36 | + |
| 37 | + - name: Test coverage |
52 | 38 | run: | |
53 | | - install.packages('remotes') |
54 | | - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) |
55 | | - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") |
| 39 | + cov <- covr::package_coverage( |
| 40 | + quiet = FALSE, |
| 41 | + clean = FALSE, |
| 42 | + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") |
| 43 | + ) |
| 44 | + print(cov) |
| 45 | + covr::to_cobertura(cov) |
56 | 46 | shell: Rscript {0} |
57 | | - - name: Restore R package cache |
58 | | - uses: actions/cache@v4 |
| 47 | + - uses: codecov/codecov-action@v5 |
59 | 48 | with: |
60 | | - path: ${{ env.R_LIBS_USER }} |
61 | | - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} |
62 | | - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- |
63 | | - - name: Install system dependencies |
64 | | - if: runner.os == 'Linux' |
65 | | - run: | |
66 | | - while read -r cmd |
67 | | - do |
68 | | - eval sudo $cmd |
69 | | - done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))') |
70 | | - - name: Install dependencies |
71 | | - run: | |
72 | | - Rscript -e "remotes::install_deps(dependencies = TRUE)" |
73 | | - Rscript -e "remotes::install_cran('covr')" |
74 | | - - name: Install a sperate copy on Windows |
75 | | - if: runner.os == 'Windows' |
| 49 | + # Fail if error if not on PR, or if on PR and token is given |
| 50 | + fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }} |
| 51 | + files: ./cobertura.xml |
| 52 | + plugins: noop |
| 53 | + disable_search: true |
| 54 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 55 | + |
| 56 | + - name: Show testthat output |
| 57 | + if: always() |
76 | 58 | run: | |
77 | | - Rscript -e "remotes::install_local()" |
78 | | - - name: Codecov |
79 | | - run: Rscript -e "covr::codecov()" |
80 | | - env: |
81 | | - CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}} |
82 | | - - uses: actions/upload-artifact@v4 |
| 59 | + ## -------------------------------------------------------------------- |
| 60 | + find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true |
| 61 | + shell: bash |
| 62 | + |
| 63 | + - name: Upload test results |
83 | 64 | if: failure() |
| 65 | + uses: actions/upload-artifact@v6 |
84 | 66 | with: |
85 | | - name: ${{ runner.os }}-log |
86 | | - path: ${{ env.R_LANGSVR_LOG }} |
| 67 | + name: coverage-test-failures |
| 68 | + path: ${{ runner.temp }}/package |
0 commit comments