Skip to content

Commit

Permalink
Update action
Browse files Browse the repository at this point in the history
  • Loading branch information
dieghernan committed Feb 6, 2025
1 parent 8ccc261 commit ee0decb
Showing 1 changed file with 32 additions and 17 deletions.
49 changes: 32 additions & 17 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,35 @@ jobs:

- name: Test coverage
run: |
# Need to config junit on working dir to locate it
wdir <- file.path(normalizePath(getwd(), winslash = "/"))
junfile <- file.path(wdir, "junit.xml")
# And get the name
pkgname <- as.character(unname(read.dcf("DESCRIPTION", "Package")))
# Create junit code as character
junreport <- paste0(
"testthat::test_package('",
pkgname, "', reporter = testthat::JunitReporter$new(file = '", junfile, "'))"
)
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 = junreport
)
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}
# Show results
print(cov)
- 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 }}
# Generate files for upload in the working dir
covr::to_cobertura(cov)
shell: Rscript {0}

- name: Upload coverage report
uses: codecov/codecov-action@v5
Expand All @@ -64,6 +70,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 ee0decb

Please sign in to comment.