From b32a409bfe7ce66f422a83e0769a6eb26db9e316 Mon Sep 17 00:00:00 2001 From: wlangera Date: Tue, 26 Mar 2024 15:59:44 +0100 Subject: [PATCH] code coverage --- .github/.gitignore | 1 + .github/workflows/R-CMD-check.yaml | 50 ++++++++++++++++++++++++++++ .github/workflows/test-coverage.yaml | 50 ++++++++++++++++++++++++++++ README.Rmd | 2 ++ 4 files changed, 103 insertions(+) create mode 100644 .github/.gitignore create mode 100644 .github/workflows/R-CMD-check.yaml create mode 100644 .github/workflows/test-coverage.yaml diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..2d19fc7 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..14159b7 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,50 @@ +# 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: R-CMD-check + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: macos-latest, r: 'release'} + - {os: windows-latest, r: 'release'} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} + + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck + needs: check + + - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true + build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml new file mode 100644 index 0000000..21b8a93 --- /dev/null +++ b/.github/workflows/test-coverage.yaml @@ -0,0 +1,50 @@ +# 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 + +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 + needs: coverage + + - name: Test coverage + run: | + covr::codecov( + quiet = FALSE, + clean = FALSE, + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") + ) + shell: Rscript {0} + + - 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 diff --git a/README.Rmd b/README.Rmd index c4a34e8..3efaf9b 100644 --- a/README.Rmd +++ b/README.Rmd @@ -23,6 +23,8 @@ knitr::opts_chunk$set( [![Codecov test coverage](https://codecov.io/gh/b-cubed-eu/simcuber/branch/main/graph/badge.svg)](https://app.codecov.io/gh/b-cubed-eu/simcuber?branch=main) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/b-cubed-eu/simcuber.svg) ![GitHub repo size](https://img.shields.io/github/repo-size/b-cubed-eu/simcuber.svg) +[![R-CMD-check](https://github.com/b-cubed-eu/simcuber/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/b-cubed-eu/simcuber/actions/workflows/R-CMD-check.yaml) +[![test-coverage](https://github.com/b-cubed-eu/simcuber/actions/workflows/test-coverage.yaml/badge.svg)](https://github.com/b-cubed-eu/simcuber/actions/workflows/test-coverage.yaml) # simcuber