2
2
# Github Actions workflow to analyze CmdStanR code, test coverage
3
3
# yamllint disable rule:line-length
4
4
5
- name : Test coverage
6
-
7
- ' on ' :
5
+ on :
8
6
push :
9
7
branches :
10
8
- master
11
9
pull_request :
12
- branches :
13
- - master
10
+
11
+ name : Test coverage
12
+
13
+ permissions : read-all
14
14
15
15
jobs :
16
16
test-coverage :
@@ -38,16 +38,18 @@ jobs:
38
38
- uses : n1hility/cancel-previous-runs@v3
39
39
with :
40
40
token : ${{ secrets.GITHUB_TOKEN }}
41
- workflow : Test-coverage.yml
41
+ workflow : Test-coverage.yaml
42
42
if : " !startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'"
43
+
43
44
- uses : actions/checkout@v4
44
45
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
47
48
48
- - uses : r-lib/actions/setup-r-dependencies@v2.11.3
49
+ - uses : r-lib/actions/setup-r-dependencies@v2
49
50
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
51
53
52
54
- name : Install cmdstan
53
55
run : |
@@ -57,16 +59,55 @@ jobs:
57
59
58
60
- name : Test coverage (Linux)
59
61
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)
61
71
shell : Rscript {0}
62
72
env :
63
- CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
73
+ CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
64
74
65
75
- name : Test coverage (Windows)
66
76
if : runner.os == 'Windows'
67
77
run : |
68
78
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)
70
88
shell : Rscript {0}
71
89
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