Skip to content

Commit 7c2c18b

Browse files
authored
Merge pull request #10 from pythonhealthdatascience/dev
Dev
2 parents d9b6ba9 + 712311e commit 7c2c18b

File tree

14 files changed

+359
-10
lines changed

14 files changed

+359
-10
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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]
6+
workflow_dispatch:
7+
8+
name: test-coverage.yaml
9+
10+
permissions: read-all
11+
12+
jobs:
13+
test-coverage:
14+
runs-on: ubuntu-latest
15+
env:
16+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- uses: r-lib/actions/setup-r@v2
22+
with:
23+
use-public-rspm: true
24+
25+
- uses: r-lib/actions/setup-r-dependencies@v2
26+
with:
27+
extra-packages: any::covr, any::xml2
28+
needs: coverage
29+
30+
- name: Test coverage
31+
run: |
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)
39+
shell: Rscript {0}
40+
41+
- uses: codecov/codecov-action@v5
42+
with:
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()
52+
run: |
53+
## --------------------------------------------------------------------
54+
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
55+
shell: bash
56+
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

DESCRIPTION

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,7 @@ Suggests:
3030
mockery,
3131
patrick,
3232
scales,
33-
testthat (>= 3.0.0)
33+
testthat (>= 3.0.0),
34+
covr,
35+
DT
3436
Config/testthat/edition: 3

R/validate_model_inputs.R

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ valid_inputs <- function(run_number, param) {
1010
check_run_number(run_number)
1111
check_all_param_names(param)
1212
check_param_values(param)
13+
check_log_file_path(param)
1314
}
1415

1516

@@ -213,3 +214,23 @@ check_param_values <- function(param) {
213214
}
214215
}
215216
}
217+
218+
#' Check logging file path
219+
#'
220+
#' @param param List containing parameters for the simulation.
221+
#'
222+
#' @return None. Throws an error if valid file path not provided, when
223+
#' log_to_file = TRUE.
224+
#' @export
225+
226+
check_log_file_path <- function(param) {
227+
log_to_file <- param[["log_to_file"]]
228+
file_path <- param[["file_path"]]
229+
if (isTRUE(log_to_file) && (is.null(file_path) || !nzchar(file_path))) {
230+
stop(
231+
"If 'log_to_file' is TRUE, you must provide a non-NULL, ",
232+
"non-empty 'file_path'.",
233+
call. = FALSE
234+
)
235+
}
236+
}

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
[![R-CMD-check](https://github.com/pythonhealthdatascience/rdesrap_stroke/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/pythonhealthdatascience/rdesrap_stroke/actions/workflows/R-CMD-check.yaml)
1010
[![Lint](https://github.com/pythonhealthdatascience/rdesrap_stroke/actions/workflows/lint.yaml/badge.svg)](https://github.com/pythonhealthdatascience/rdesrap_stroke/actions/workflows/lint.yaml)
1111
[![ORCID](https://img.shields.io/badge/ORCID_Amy_Heather-0000--0002--6596--3479-A6CE39?&logo=orcid&logoColor=white)](https://orcid.org/0000-0002-6596-3479)
12+
[![Codecov test coverage](https://codecov.io/gh/pythonhealthdatascience/rdesrap_stroke/graph/badge.svg)](https://app.codecov.io/gh/pythonhealthdatascience/rdesrap_stroke)
1213
<!-- badges: end -->
1314
</div>
1415

@@ -91,6 +92,12 @@ bash run_rmarkdown.sh
9192
devtools::test()
9293
```
9394

95+
**Compute test coverage:**
96+
97+
```{.r}
98+
devtools::test_coverage()
99+
```
100+
94101
**Lint code:**
95102

96103
```{.r}

0 commit comments

Comments
 (0)