Skip to content

Commit 94225ae

Browse files
Merge pull request #1219 from r-lib/strict-examples
Check for warnings in examples and tests
2 parents fa9d9f4 + 173d397 commit 94225ae

File tree

2 files changed

+48
-42
lines changed

2 files changed

+48
-42
lines changed

.github/workflows/check-all-examples.yaml

Lines changed: 0 additions & 42 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# execute all examples and tests with warnings turned into errors to look for new warnings
2+
on:
3+
push:
4+
branches: [main, master]
5+
pull_request:
6+
branches: [main, master]
7+
8+
name: check-no-warnings
9+
10+
jobs:
11+
check-no-warnings:
12+
runs-on: ubuntu-latest
13+
env:
14+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: r-lib/actions/setup-r@v2
20+
with:
21+
use-public-rspm: true
22+
23+
- uses: r-lib/actions/setup-r-dependencies@v2
24+
with:
25+
pak-version: devel
26+
extra-packages: |
27+
any::devtools
28+
local::.
29+
30+
- name: Run examples
31+
run: |
32+
options(crayon.enabled = TRUE, warn = 2L)
33+
devtools::run_examples(fresh = TRUE, run_dontrun = TRUE, run_donttest = TRUE)
34+
shell: Rscript {0}
35+
36+
- name: Run Tests
37+
run: |
38+
options(crayon.enabled = TRUE)
39+
pkgload::load_all()
40+
# this workaround needed to play nicely with parallel testing
41+
# see: https://github.com/r-lib/testthat/issues/1912
42+
test_script_paths <- testthat::find_test_scripts("tests/testthat")
43+
test_with_warning_as_error <- function(path) {
44+
withr::local_options(list(warn = 2L))
45+
testthat::test_file(path, stop_on_failure = TRUE, stop_on_warning = TRUE)
46+
}
47+
purrr::walk(test_script_paths, test_with_warning_as_error)
48+
shell: Rscript {0}

0 commit comments

Comments
 (0)