From ebfc4988bfdf1313276ddb84974869d45dd3a82b Mon Sep 17 00:00:00 2001 From: Koen Niemeijer Date: Wed, 16 Oct 2024 17:06:01 +0200 Subject: [PATCH] Add coverage report to repo --- .github/workflows/test-coverage.yaml | 61 ++++++++++++++++++++++++++++ R/timestamps_to_datetime.R | 4 +- R/write_mpath.R | 4 +- README.Rmd | 1 + README.md | 28 +++++++------ inst/WORDLIST | 1 + 6 files changed, 81 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/test-coverage.yaml diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml new file mode 100644 index 0000000..9882260 --- /dev/null +++ b/.github/workflows/test-coverage.yaml @@ -0,0 +1,61 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: test-coverage.yaml + +permissions: read-all + +jobs: + test-coverage: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::covr, any::xml2 + needs: coverage + + - name: Test coverage + run: | + cov <- covr::package_coverage( + quiet = FALSE, + clean = FALSE, + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") + ) + covr::to_cobertura(cov) + shell: Rscript {0} + + - uses: codecov/codecov-action@v4 + with: + fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }} + file: ./cobertura.xml + plugin: noop + disable_search: true + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Show testthat output + if: always() + run: | + ## -------------------------------------------------------------------- + find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash + + - name: Upload test results + if: failure() + uses: actions/upload-artifact@v4 + with: + name: coverage-test-failures + path: ${{ runner.temp }}/package diff --git a/R/timestamps_to_datetime.R b/R/timestamps_to_datetime.R index ecbed7e..11c3263 100644 --- a/R/timestamps_to_datetime.R +++ b/R/timestamps_to_datetime.R @@ -83,13 +83,13 @@ timestamps_to_datetime <- function(x, tz_offset = NULL, force_tz = NULL) { out <- as.POSIXct(x, origin = "1970-01-01", tz = "UTC") if (!is.null(force_tz)) { - if (!requireNamespace("lubridate", quietly = TRUE)) { + if (!requireNamespace("lubridate", quietly = TRUE)) { #nocov start cli_abort(c( paste0("Package `lubridate` is needed for this function to work."), i = paste0("Please install it using `install.packages(\"lubridate\")`")), call = call ) - } + } #nocov end out <- lubridate::force_tz(out, tzone = force_tz) } diff --git a/R/write_mpath.R b/R/write_mpath.R index 411e025..3746b54 100644 --- a/R/write_mpath.R +++ b/R/write_mpath.R @@ -61,9 +61,7 @@ write_mpath <- function( "accountCode", "questionListName", "questionListLabel", - "fromProtocolName", - "recording_recording_filename", - "recording_recording_metadata" + "fromProtocolName" ) # Find which columns are lists of strings diff --git a/README.Rmd b/README.Rmd index 98d0ac7..7ce079b 100644 --- a/README.Rmd +++ b/README.Rmd @@ -18,6 +18,7 @@ options(tibble.print_min = 5, tibble.print_max = 5) [![R-CMD-check](https://github.com/m-path-io/mpathr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/m-path-io/mpathr/actions/workflows/R-CMD-check.yaml) +[![Codecov test coverage](https://codecov.io/gh/m-path-io/mpathr/graph/badge.svg)](https://app.codecov.io/gh/m-path-io/mpathr) ## Overview diff --git a/README.md b/README.md index cf0317b..612d368 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ [![R-CMD-check](https://github.com/m-path-io/mpathr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/m-path-io/mpathr/actions/workflows/R-CMD-check.yaml) +[![Codecov test +coverage](https://codecov.io/gh/m-path-io/mpathr/graph/badge.svg)](https://app.codecov.io/gh/m-path-io/mpathr) ## Overview @@ -46,20 +48,20 @@ data <- read_mpath( print(data) #> # A tibble: 2,221 × 100 -#> connectionId legacyCode code alias initials accountCode scheduledBeepId sentBeepId -#> -#> 1 234609 !9v48@jp7a7 !byyo kjyt abc Ver jp7a7 -1 19355815 -#> 2 234609 !9v48@jp7a7 !byyo kjyt abc Ver jp7a7 28626776 19369681 -#> 3 234609 !9v48@jp7a7 !byyo kjyt abc Ver jp7a7 28626777 19370288 -#> 4 234609 !9v48@jp7a7 !byyo kjyt abc Ver jp7a7 28626781 19375253 -#> 5 234609 !9v48@jp7a7 !byyo kjyt abc Ver jp7a7 28626782 19377280 +#> connectionId legacyCode code alias initials accountCode scheduledBeepId +#> +#> 1 234609 !9v48@jp7a7 !byyo kjyt abc Ver jp7a7 -1 +#> 2 234609 !9v48@jp7a7 !byyo kjyt abc Ver jp7a7 28626776 +#> 3 234609 !9v48@jp7a7 !byyo kjyt abc Ver jp7a7 28626777 +#> 4 234609 !9v48@jp7a7 !byyo kjyt abc Ver jp7a7 28626781 +#> 5 234609 !9v48@jp7a7 !byyo kjyt abc Ver jp7a7 28626782 #> # ℹ 2,216 more rows -#> # ℹ 92 more variables: reminderForOriginalSentBeepId , questionListName , -#> # questionListLabel , fromProtocolName , timeStampScheduled , timeStampSent , -#> # timeStampStart , timeStampStop , originalTimeStampSent , timeZoneOffset , -#> # deltaUTC , consent_yesno_yesno , gender_multipleChoice_index , -#> # gender_multipleChoice_string , gender_multipleChoice_likert , age_open , -#> # SWLS_intro_basic , SWLS_1_multipleChoice_index , … +#> # ℹ 93 more variables: sentBeepId , reminderForOriginalSentBeepId , +#> # questionListName , questionListLabel , fromProtocolName , +#> # timeStampScheduled , timeStampSent , timeStampStart , +#> # timeStampStop , originalTimeStampSent , timeZoneOffset , +#> # deltaUTC , consent_yesno_yesno , +#> # gender_multipleChoice_index , gender_multipleChoice_string , … ``` ## Getting help diff --git a/inst/WORDLIST b/inst/WORDLIST index 0ba414b..1466d01 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -1,5 +1,6 @@ BFI CMD +Codecov ESM Github JSON