-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (61 loc) · 1.83 KB
/
Copy pathlint.yaml
File metadata and controls
69 lines (61 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Code style and linting check
on:
push:
branches: [main, dev]
pull_request:
branches: [main]
name: lint
jobs:
lint:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v5
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: |
any::lintr
any::styler
any::roxygen2
- name: Lint
continue-on-error: true
run: |
result <- tryCatch(
lintr::lint_package(),
error = function(e) {
message("lintr error: ", conditionMessage(e))
data.frame()
}
)
n <- if (is.data.frame(result)) nrow(result) else 0
if (n > 0) {
print(result)
message(sprintf("\n%d lint(s) found (non-blocking)", n))
} else {
message("No lints found")
}
shell: Rscript {0}
- name: Check code style
continue-on-error: true
run: |
changed <- tryCatch({
styled <- styler::style_pkg(dry = "on")
if (!is.null(styled)) {
ch <- styled$changed
if (is.na(ch)) 0 else sum(ch)
} else 0
}, error = function(e) {
message("styler check skipped: ", conditionMessage(e))
NA_integer_
})
if (is.na(changed) || changed > 0) {
if (is.na(changed)) message("NOTE: styler check failed — see warnings above.")
message(sprintf("NOTE: %d file(s) need styling. Run styler::style_pkg().", if (is.na(changed)) 0 else changed))
} else {
message("Code style: OK")
}
shell: Rscript {0}