22# Github Actions workflow to analyze CmdStanR code, test coverage
33# yamllint disable rule:line-length
44
5- name : Test coverage
6-
7- ' on ' :
5+ on :
86 push :
97 branches :
108 - master
119 pull_request :
12- branches :
13- - master
10+
11+ name : Test coverage
12+
13+ permissions : read-all
1414
1515jobs :
1616 test-coverage :
@@ -38,16 +38,18 @@ jobs:
3838 - uses : n1hility/cancel-previous-runs@v3
3939 with :
4040 token : ${{ secrets.GITHUB_TOKEN }}
41- workflow : Test-coverage.yml
41+ workflow : Test-coverage.yaml
4242 if : " !startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'"
43+
4344 - uses : actions/checkout@v4
4445
45- - uses : r-lib/actions/setup-r@v2.11.3
46- - uses : r-lib/actions/setup-pandoc@v2.11.3
46+ - uses : r-lib/actions/setup-r@v2
47+ - uses : r-lib/actions/setup-pandoc@v2
4748
48- - uses : r-lib/actions/setup-r-dependencies@v2.11.3
49+ - uses : r-lib/actions/setup-r-dependencies@v2
4950 with :
50- extra-packages : any::rcmdcheck, local::., any::covr, any::gridExtra
51+ extra-packages : any::rcmdcheck, local::., any::covr, any::gridExtra, any::xml2
52+ needs : coverage
5153
5254 - name : Install cmdstan
5355 run : |
@@ -57,16 +59,55 @@ jobs:
5759
5860 - name : Test coverage (Linux)
5961 if : runner.os == 'Linux'
60- run : covr::codecov(type = "tests")
62+ run : |
63+ cov <- covr::package_coverage(
64+ quiet = FALSE,
65+ clean = FALSE,
66+ install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package"),
67+ type = "tests"
68+ )
69+ print(cov)
70+ covr::to_cobertura(cov)
6171 shell : Rscript {0}
6272 env :
63- CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
73+ CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
6474
6575 - name : Test coverage (Windows)
6676 if : runner.os == 'Windows'
6777 run : |
6878 options(covr.gcov = 'C:/rtools44/mingw64/bin/gcov.exe');
69- covr::codecov(type = "tests", function_exclusions = "sample_mpi")
79+ cov <- covr::package_coverage(
80+ quiet = FALSE,
81+ clean = FALSE,
82+ install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package"),
83+ type = "tests",
84+ function_exclusions = "sample_mpi"
85+ )
86+ print(cov)
87+ covr::to_cobertura(cov)
7088 shell : Rscript {0}
7189 env :
72- CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
90+ CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
91+
92+ - uses : codecov/codecov-action@v5
93+ with :
94+ # Fail if error if not on PR, or if on PR and token is given
95+ fail_ci_if_error : ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }}
96+ files : ./cobertura.xml
97+ plugins : noop
98+ disable_search : true
99+ token : ${{ secrets.CODECOV_TOKEN }}
100+
101+ - name : Show testthat output
102+ if : always()
103+ run : |
104+ ## --------------------------------------------------------------------
105+ find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
106+ shell : bash
107+
108+ - name : Upload test results
109+ if : failure()
110+ uses : actions/upload-artifact@v4
111+ with :
112+ name : coverage-test-failures
113+ path : ${{ runner.temp }}/package
0 commit comments