diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml new file mode 100644 index 0000000..60447cd --- /dev/null +++ b/.github/workflows/test-coverage.yaml @@ -0,0 +1,71 @@ +# 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 + +permissions: + contents: read + id-token: write + +jobs: + test-coverage: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v6 + + - 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") + ) + print(cov) + pct <- round(covr::percent_coverage(cov), 2) + cat(sprintf("Overall coverage: %s%%\n", pct)) + writeLines(as.character(pct), "coverage-percent.txt") + covr::to_cobertura(cov) + shell: Rscript {0} + + - name: Report coverage percent + run: | + echo "Overall package coverage: $(cat coverage-percent.txt)%" + + - uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7 + with: + fail_ci_if_error: true + files: ./cobertura.xml + plugins: noop + disable_search: true + use_oidc: true + + - 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@v7 + with: + name: coverage-test-failures + path: ${{ runner.temp }}/package diff --git a/README.md b/README.md index a508338..ed9a355 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # referent + +[![test-coverage](https://github.com/bbuchsbaum/referent/actions/workflows/test-coverage.yaml/badge.svg)](https://github.com/bbuchsbaum/referent/actions/workflows/test-coverage.yaml) +[![Codecov test coverage](https://codecov.io/gh/bbuchsbaum/referent/branch/main/graph/badge.svg)](https://app.codecov.io/gh/bbuchsbaum/referent?branch=main) + + Distributional reference models and individual deviation scores. `referent` estimates the conditional predictive distribution of one or more