Skip to content

Commit

Permalink
Add coverage report to repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Koen Niemeijer committed Oct 16, 2024
1 parent 236927d commit ebfc498
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 18 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions R/timestamps_to_datetime.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 1 addition & 3 deletions R/write_mpath.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ options(tibble.print_min = 5, tibble.print_max = 5)

<!-- badges: start -->
[![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)
<!-- badges: end -->

## Overview
Expand Down
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<!-- badges: start -->

[![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)
<!-- badges: end -->

## Overview
Expand Down Expand Up @@ -46,20 +48,20 @@ data <- read_mpath(

print(data)
#> # A tibble: 2,221 × 100
#> connectionId legacyCode code alias initials accountCode scheduledBeepId sentBeepId
#> <int> <chr> <chr> <chr> <chr> <chr> <int> <int>
#> 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
#> <int> <chr> <chr> <chr> <chr> <chr> <int>
#> 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 <int>, questionListName <chr>,
#> # questionListLabel <lgl>, fromProtocolName <chr>, timeStampScheduled <int>, timeStampSent <int>,
#> # timeStampStart <int>, timeStampStop <int>, originalTimeStampSent <int>, timeZoneOffset <int>,
#> # deltaUTC <dbl>, consent_yesno_yesno <int>, gender_multipleChoice_index <int>,
#> # gender_multipleChoice_string <chr>, gender_multipleChoice_likert <int>, age_open <chr>,
#> # SWLS_intro_basic <int>, SWLS_1_multipleChoice_index <int>, …
#> # ℹ 93 more variables: sentBeepId <int>, reminderForOriginalSentBeepId <int>,
#> # questionListName <chr>, questionListLabel <chr>, fromProtocolName <chr>,
#> # timeStampScheduled <int>, timeStampSent <int>, timeStampStart <int>,
#> # timeStampStop <int>, originalTimeStampSent <int>, timeZoneOffset <int>,
#> # deltaUTC <dbl>, consent_yesno_yesno <int>,
#> # gender_multipleChoice_index <int>, gender_multipleChoice_string <chr>, …
```

## Getting help
Expand Down
1 change: 1 addition & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
BFI
CMD
Codecov
ESM
Github
JSON
Expand Down

0 comments on commit ebfc498

Please sign in to comment.