Skip to content

Commit

Permalink
try covr and testthat
Browse files Browse the repository at this point in the history
  • Loading branch information
dieghernan committed Feb 6, 2025
1 parent ae7cc0b commit e24fbdb
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,28 @@ jobs:

- name: Test coverage
run: |
wdir <- file.path(normalizePath(getwd()))
cat(wdir)
pkgname <- as.character(unname(read.dcf("DESCRIPTION", "Package")))
cod <- paste0("testthat::test_package('", pkgname, "', reporter = testthat::JunitReporter$new(file = 'junit.xml'))")
cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
type = "none",
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package"),
code = cod
)
print(cov)
covr::to_cobertura(cov)
shell: Rscript {0}
- name: Create Junit Report
if: always()
run: |
test_out <- path.expand(file.path(getwd(), "junit.xml"))
testthat::test_local(reporter = testthat::JunitReporter$new(test_out))
shell: Rscript {0}
findjun <- list.files(recursive = TRUE, pattern = "junit.xml", full.names = TRUE)
file.copy(findjun, wdir, overwrite = TRUE)
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
# Fail if error if not on PR, or if on PR and token is given
fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }}
file: ./junit.xml
token: ${{ secrets.CODECOV_TOKEN }}
cat(list.files(), sep = "\n")
shell: Rscript {0}

- name: Upload coverage report
uses: codecov/codecov-action@v5
Expand All @@ -64,6 +63,15 @@ jobs:
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
# Fail if error if not on PR, or if on PR and token is given
fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }}
file: ./junit.xml
token: ${{ secrets.CODECOV_TOKEN }}

- name: Show testthat output
if: always()
run: |
Expand Down

0 comments on commit e24fbdb

Please sign in to comment.