Skip to content

Commit

Permalink
add code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui committed Jan 15, 2025
1 parent de969dd commit ab61ce3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 26 additions & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,15 @@ jobs:
run: |
brew install --cask xquartz
- name: Whether to use codecov
run: |
echo "USE_R_CODECOV=${{ (runner.os == 'Linux' && matrix.config.r == 'release') && true || false }}" >> $GITHUB_ENV
- uses: r-lib/actions/setup-r-dependencies@HEAD
if: matrix.config.r >= '4.0'
with:
# install the package itself as we register vignette engine
extra-packages: any::rcmdcheck, local::.
extra-packages: any::rcmdcheck, local::. ${{ env.USE_R_CODECOV == 'true' && ', any::covr, any::xml2' || '' }}
needs: check

- uses: r-lib/actions/check-r-package@HEAD
Expand All @@ -72,6 +76,27 @@ jobs:
R CMD build litedown
R CMD check --as-cran --no-manual litedown_*.tar.gz
- name: Test coverage
if: success() && env.USE_R_CODECOV == 'true'
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@v5
if: env.USE_R_CODECOV == 'true'
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 }}
files: ./cobertura.xml
plugins: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}

- uses: actions/checkout@HEAD
if: runner.os == 'macOS'
with:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
release](https://www.r-pkg.org/badges/version/litedown)](https://cran.r-project.org/package=litedown)
[![litedown on
r-universe](https://yihui.r-universe.dev/badges/litedown)](https://yihui.r-universe.dev/litedown)
[![Codecov test
coverage](https://codecov.io/gh/yihui/litedown/branch/main/graph/badge.svg)](https://app.codecov.io/gh/yihui/litedown?branch=main)

<!-- badges: end -->

Expand Down

0 comments on commit ab61ce3

Please sign in to comment.