From 358cef3ea12be9ff5f502eafa67c56d3c8420477 Mon Sep 17 00:00:00 2001 From: Jeffrey Girard Date: Mon, 30 Nov 2026 11:55:13 -0600 Subject: [PATCH 1/4] Fail check-all-examples on deprecation warnings only Other warnings, which some examples raise on purpose, are shown as annotations. --- .github/workflows/check-all-examples.yaml | 60 +++++++++++++++++++++-- 1 file changed, 56 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check-all-examples.yaml b/.github/workflows/check-all-examples.yaml index 969bb93..a2c3642 100644 --- a/.github/workflows/check-all-examples.yaml +++ b/.github/workflows/check-all-examples.yaml @@ -33,11 +33,63 @@ jobs: ivprobit=?ignore-before-r=100.0.0 local::. + # Deprecation warnings fail the check. Other warnings, which some examples + # raise on purpose, show up as annotations and do not fail it. - name: Run examples run: | - options( - crayon.enabled = TRUE, - warn = 2L + options(crayon.enabled = TRUE) + + # base R and lifecycle deprecations have their own classes; easystats' + # own (insight::format_warning()) can only be told apart by their text + is_deprecation <- function(w) { + inherits(w, c("deprecatedWarning", "lifecycle_warning_deprecated")) || + grepl("deprecated", conditionMessage(w), ignore.case = TRUE) + } + + # the Rd file whose examples are running + current_rd <- function() { + for (i in rev(seq_len(sys.nframe()))) { + if (identical(sys.function(i), pkgload::run_example)) { + return(basename(get("path", envir = sys.frame(i)))) + } + } + "examples" + } + + annotate <- function(level, title, msg) { + msg <- gsub("\033\\[[0-9;]*m", "", msg) + msg <- gsub("%", "%25", msg, fixed = TRUE) + msg <- gsub("\r", "%0D", msg, fixed = TRUE) + msg <- gsub("\n", "%0A", msg, fixed = TRUE) + cat("\n::", level, " title=", title, "::", msg, "\n", sep = "") + } + + deprecations <- character() + result <- tryCatch( + withCallingHandlers( + devtools::run_examples(run_dontrun = TRUE, run_donttest = TRUE, document = FALSE), + warning = function(w) { + rd <- current_rd() + if (is_deprecation(w)) { + deprecations <<- c(deprecations, rd) + annotate("error", paste("Deprecation warning in", rd), conditionMessage(w)) + } else { + annotate("warning", paste("Warning in", rd), conditionMessage(w)) + } + invokeRestart("muffleWarning") + } + ), + error = function(e) e ) - devtools::run_examples(run_dontrun = TRUE, run_donttest = TRUE, document = FALSE) + + if (inherits(result, "error")) { + stop(result) + } + if (length(deprecations) > 0) { + stop( + "Deprecation warnings in the examples of: ", + toString(unique(deprecations)), + call. = FALSE + ) + } shell: Rscript {0} From cba046f0443cafe551aa74e8f1461e6832f0242a Mon Sep 17 00:00:00 2001 From: Jeffrey Girard Date: Mon, 30 Nov 2026 11:55:22 -0600 Subject: [PATCH 2/4] Describe the deprecation check in the README --- README.Rmd | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.Rmd b/README.Rmd index d896bcf..c2c56e3 100644 --- a/README.Rmd +++ b/README.Rmd @@ -83,7 +83,7 @@ name: test-coverage | test-coverage-examples.yaml | Checks code coverage via examples in the manual and vignettes | | test-coverage.yaml | Checks code coverage via tests | | check-random-test-order.yaml | Randomizes the order in which test files are run to check that tests are self-contained. | -| check-all-examples.yaml | Runs *all* examples and checks that they execute successfully and without warnings | +| check-all-examples.yaml | Runs *all* examples and checks that they run without errors or deprecation warnings | | check-link-rot.yaml | Checks that there are no outdated links (using `{urlchecker}`) | | check-readme.yaml | Checks that the README can be properly rendered | | check-spelling.yaml | Checks for spelling mistakes (using `{spelling}`) | diff --git a/README.md b/README.md index 3438890..9eb83d5 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ name: test-coverage | test-coverage-examples.yaml | Checks code coverage via examples in the manual and vignettes | | test-coverage.yaml | Checks code coverage via tests | | check-random-test-order.yaml | Randomizes the order in which test files are run to check that tests are self-contained. | -| check-all-examples.yaml | Runs *all* examples and checks that they execute successfully and without warnings | +| check-all-examples.yaml | Runs *all* examples and checks that they run without errors or deprecation warnings | | check-link-rot.yaml | Checks that there are no outdated links (using `{urlchecker}`) | | check-readme.yaml | Checks that the README can be properly rendered | | check-spelling.yaml | Checks for spelling mistakes (using `{spelling}`) | From 59f053689ae17b6b57ecd478f233d1e66e4b84ed Mon Sep 17 00:00:00 2001 From: Jeffrey Girard Date: Mon, 30 Nov 2026 11:57:29 -0600 Subject: [PATCH 3/4] Allow warnings signalled without a muffle restart --- .github/workflows/check-all-examples.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-all-examples.yaml b/.github/workflows/check-all-examples.yaml index a2c3642..11da13b 100644 --- a/.github/workflows/check-all-examples.yaml +++ b/.github/workflows/check-all-examples.yaml @@ -76,7 +76,7 @@ jobs: } else { annotate("warning", paste("Warning in", rd), conditionMessage(w)) } - invokeRestart("muffleWarning") + tryInvokeRestart("muffleWarning") } ), error = function(e) e From ec19c0d233db116c09f5c9dab0c1ac902d4441c9 Mon Sep 17 00:00:00 2001 From: Jeffrey Girard Date: Mon, 30 Nov 2026 12:05:56 -0600 Subject: [PATCH 4/4] Count defunct warnings as deprecations --- .github/workflows/check-all-examples.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-all-examples.yaml b/.github/workflows/check-all-examples.yaml index 11da13b..524f1c5 100644 --- a/.github/workflows/check-all-examples.yaml +++ b/.github/workflows/check-all-examples.yaml @@ -40,10 +40,11 @@ jobs: options(crayon.enabled = TRUE) # base R and lifecycle deprecations have their own classes; easystats' - # own (insight::format_warning()) can only be told apart by their text + # own (insight::format_warning()) can only be told apart by their text, + # which says "deprecated" or, once removed, "defunct" is_deprecation <- function(w) { inherits(w, c("deprecatedWarning", "lifecycle_warning_deprecated")) || - grepl("deprecated", conditionMessage(w), ignore.case = TRUE) + grepl("deprecated|defunct", conditionMessage(w), ignore.case = TRUE) } # the Rd file whose examples are running