From 252ceb4d3f5d42fc37a006987c5780eb5da132a2 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Tue, 3 Dec 2024 08:43:18 +0100 Subject: [PATCH] consolidate warning-as-errors into one workflow --- .github/workflows/check-all-examples.yaml | 49 ------------------- ...t-warnings.yaml => check-no-warnings.yaml} | 25 +++++++--- .../workflows/check-vignette-warnings.yaml | 41 ---------------- 3 files changed, 19 insertions(+), 96 deletions(-) delete mode 100644 .github/workflows/check-all-examples.yaml rename .github/workflows/{check-test-warnings.yaml => check-no-warnings.yaml} (55%) delete mode 100644 .github/workflows/check-vignette-warnings.yaml diff --git a/.github/workflows/check-all-examples.yaml b/.github/workflows/check-all-examples.yaml deleted file mode 100644 index ba24579e9..000000000 --- a/.github/workflows/check-all-examples.yaml +++ /dev/null @@ -1,49 +0,0 @@ -# Make sure all examples run successfully, even the ones that are not supposed -# to be run or tested on CRAN machines by default. -# -# The examples that fail should use -# - `if (FALSE) { ... }` (if example is included only for illustrative purposes) -# - `try({ ... })` (if the intent is to show the error) -# -# This workflow helps find such failing examples that need to be modified. - -on: - push: - branches: [main, master] - pull_request: - branches: [main, master] - schedule: - # * is a special character in YAML so you have to quote this string - # Trigger once a week at 00:00 on Sunday - - cron: "0 0 * * SUN" - -name: check-all-examples - -jobs: - check-all-examples: - runs-on: ubuntu-latest - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - - steps: - - uses: actions/checkout@v4 - - - uses: r-lib/actions/setup-r@v2 - with: - r-version: "devel" - use-public-rspm: true - - - uses: r-lib/actions/setup-r-dependencies@v2 - with: - pak-version: devel - upgrade: 'TRUE' - extra-packages: | - any::devtools - local::. - needs: check - - - name: Run examples - run: | - options(crayon.enabled = TRUE, warn = 2L) - devtools::run_examples(run_dontrun = TRUE, run_donttest = TRUE, document = FALSE) - shell: Rscript {0} diff --git a/.github/workflows/check-test-warnings.yaml b/.github/workflows/check-no-warnings.yaml similarity index 55% rename from .github/workflows/check-test-warnings.yaml rename to .github/workflows/check-no-warnings.yaml index 707d1081b..051583c62 100644 --- a/.github/workflows/check-test-warnings.yaml +++ b/.github/workflows/check-no-warnings.yaml @@ -1,14 +1,14 @@ -# Run tests with `options(warn = 2)` to fail on test warnings +# execute all examples, tests, and vignettes with warnings turned into errors on: push: branches: [main, master] pull_request: branches: [main, master] -name: check-test-warnings +name: check-no-warnings jobs: - check-test-warnings: + check-no-warnings: runs-on: ubuntu-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} @@ -18,21 +18,27 @@ jobs: - uses: r-lib/actions/setup-r@v2 with: - r-version: "devel" use-public-rspm: true - uses: r-lib/actions/setup-r-dependencies@v2 with: pak-version: devel - upgrade: 'TRUE' extra-packages: | + any::devtools local::. - needs: check + + - name: Run examples + run: | + options(crayon.enabled = TRUE, warn = 2L) + devtools::run_examples(fresh = TRUE, run_dontrun = TRUE, run_donttest = TRUE) + shell: Rscript {0} - name: Run Tests run: | options(crayon.enabled = TRUE) pkgload::load_all() + # this workaround needed to play nicely with parallel testing + # see: https://github.com/r-lib/testthat/issues/1912 test_script_paths <- testthat::find_test_scripts("tests/testthat") test_with_warning_as_error <- function(path) { withr::local_options(list(warn = 2L)) @@ -40,3 +46,10 @@ jobs: } purrr::walk(test_script_paths, test_with_warning_as_error) shell: Rscript {0} + + - name: Build vignettes + run: | + options(crayon.enabled = TRUE, warn = 2L) + vignettes <- fs::dir_ls("vignettes/", glob = "*.Rmd", recurse = TRUE) + purrr::walk(vignettes, rmarkdown::render) + shell: Rscript {0} diff --git a/.github/workflows/check-vignette-warnings.yaml b/.github/workflows/check-vignette-warnings.yaml deleted file mode 100644 index a863d5c35..000000000 --- a/.github/workflows/check-vignette-warnings.yaml +++ /dev/null @@ -1,41 +0,0 @@ -# Run vignettes with `options(warn = 2)` to fail on warnings -on: - push: - branches: [main, master] - pull_request: - branches: [main, master] - -name: check-vignette-warnings - -jobs: - check-vignette-warnings: - runs-on: ubuntu-latest - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - - steps: - - uses: actions/checkout@v4 - - - uses: r-lib/actions/setup-pandoc@v2 - with: - pandoc-version: "latest" - - - uses: r-lib/actions/setup-r@v2 - with: - r-version: "devel" - use-public-rspm: true - - - uses: r-lib/actions/setup-r-dependencies@v2 - with: - pak-version: devel - upgrade: 'TRUE' - extra-packages: | - local::. - needs: check - - - name: Build vignettes - run: | - options(crayon.enabled = TRUE, warn = 2L) - vignettes <- fs::dir_ls("vignettes/", glob = "*.Rmd", recurse = TRUE) - purrr::walk(vignettes, rmarkdown::render) - shell: Rscript {0}