From e19bc2ca47ed20f2add2686e14959d9a08abdf82 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sat, 29 Jun 2024 14:55:45 +0200 Subject: [PATCH 1/3] Check examples with stricter settings --- .github/workflows/check-all-examples.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check-all-examples.yaml b/.github/workflows/check-all-examples.yaml index 36415fc90..d1f1507f0 100644 --- a/.github/workflows/check-all-examples.yaml +++ b/.github/workflows/check-all-examples.yaml @@ -37,6 +37,12 @@ jobs: - name: Run examples run: | - options(crayon.enabled = TRUE) + options( + crayon.enabled = TRUE, + warn = 2L, + warnPartialMatchArgs = TRUE, + warnPartialMatchAttr = TRUE, + warnPartialMatchDollar = TRUE + ) devtools::run_examples(fresh = TRUE, run_dontrun = TRUE, run_donttest = TRUE) shell: Rscript {0} From 27a07d52ea23ec4b7698efd678c50aa1c9e36992 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Mon, 1 Jul 2024 16:03:34 +0200 Subject: [PATCH 2/3] Create check-test-warnings.yaml --- .github/workflows/check-test-warnings.yaml | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/check-test-warnings.yaml diff --git a/.github/workflows/check-test-warnings.yaml b/.github/workflows/check-test-warnings.yaml new file mode 100644 index 000000000..414385293 --- /dev/null +++ b/.github/workflows/check-test-warnings.yaml @@ -0,0 +1,39 @@ +# based on test-coverage, running testthat with options(warn = 2) to fail on test warnings +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: test-package + +jobs: + test-package: + 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: local::. + + - name: Run Tests + run: | + ## -------------------------------------------------------------------- + options( + crayon.enabled = TRUE, + warn = 2L, + warnPartialMatchArgs = TRUE, + warnPartialMatchAttr = TRUE, + warnPartialMatchDollar = TRUE + ) + if (Sys.getenv("_R_CHECK_FORCE_SUGGESTS_", "") == "") Sys.setenv("_R_CHECK_FORCE_SUGGESTS_" = "false") + testthat::test_dir("tests") + shell: Rscript {0} From 173d39722718c004017dde31194b1a5e47d6b99a Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sat, 30 Nov 2024 20:42:54 +0100 Subject: [PATCH 3/3] consolidate into an existing check --- .github/workflows/check-all-examples.yaml | 48 ---------------------- .github/workflows/check-no-warnings.yaml | 48 ++++++++++++++++++++++ .github/workflows/check-test-warnings.yaml | 39 ------------------ 3 files changed, 48 insertions(+), 87 deletions(-) delete mode 100644 .github/workflows/check-all-examples.yaml create mode 100644 .github/workflows/check-no-warnings.yaml delete mode 100644 .github/workflows/check-test-warnings.yaml diff --git a/.github/workflows/check-all-examples.yaml b/.github/workflows/check-all-examples.yaml deleted file mode 100644 index d1f1507f0..000000000 --- a/.github/workflows/check-all-examples.yaml +++ /dev/null @@ -1,48 +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] - -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: - use-public-rspm: true - - - uses: r-lib/actions/setup-r-dependencies@v2 - with: - pak-version: devel - extra-packages: | - any::devtools - local::. - - - name: Run examples - run: | - options( - crayon.enabled = TRUE, - warn = 2L, - warnPartialMatchArgs = TRUE, - warnPartialMatchAttr = TRUE, - warnPartialMatchDollar = TRUE - ) - devtools::run_examples(fresh = TRUE, run_dontrun = TRUE, run_donttest = TRUE) - shell: Rscript {0} diff --git a/.github/workflows/check-no-warnings.yaml b/.github/workflows/check-no-warnings.yaml new file mode 100644 index 000000000..4b792a68d --- /dev/null +++ b/.github/workflows/check-no-warnings.yaml @@ -0,0 +1,48 @@ +# execute all examples and tests with warnings turned into errors to look for new warnings +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: check-no-warnings + +jobs: + check-no-warnings: + 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: + pak-version: devel + extra-packages: | + any::devtools + local::. + + - 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)) + testthat::test_file(path, stop_on_failure = TRUE, stop_on_warning = TRUE) + } + purrr::walk(test_script_paths, test_with_warning_as_error) + shell: Rscript {0} diff --git a/.github/workflows/check-test-warnings.yaml b/.github/workflows/check-test-warnings.yaml deleted file mode 100644 index 414385293..000000000 --- a/.github/workflows/check-test-warnings.yaml +++ /dev/null @@ -1,39 +0,0 @@ -# based on test-coverage, running testthat with options(warn = 2) to fail on test warnings -on: - push: - branches: [main, master] - pull_request: - branches: [main, master] - -name: test-package - -jobs: - test-package: - 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: local::. - - - name: Run Tests - run: | - ## -------------------------------------------------------------------- - options( - crayon.enabled = TRUE, - warn = 2L, - warnPartialMatchArgs = TRUE, - warnPartialMatchAttr = TRUE, - warnPartialMatchDollar = TRUE - ) - if (Sys.getenv("_R_CHECK_FORCE_SUGGESTS_", "") == "") Sys.setenv("_R_CHECK_FORCE_SUGGESTS_" = "false") - testthat::test_dir("tests") - shell: Rscript {0}