-
Notifications
You must be signed in to change notification settings - Fork 986
78 lines (73 loc) · 2.64 KB
/
code-quality.yaml
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
69
70
71
72
73
74
75
76
77
78
on:
push:
branches:
- master
pull_request:
branches:
- master
name: code-quality
jobs:
lint-r:
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: |
r-lib/lintr
local::.
needs: lint
- name: Lint
run: lintr::lint_package(pattern = "(?i)[.](r|rmd)$") # TODO(#5830): use the default pattern
shell: Rscript {0}
env:
LINTR_ERROR_ON_LINT: true
R_LINTR_LINTER_FILE: .ci/.lintr
lint-c:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: r-lib/actions/setup-r@v2
- name: Lint
run: |
linter_env = new.env()
for (f in list.files('.ci/linters/c', full.names=TRUE)) sys.source(f, linter_env)
for (f in list.files('src', pattern='[.][ch]$', full.names=TRUE)) {
c_obj = list(path = f, lines = readLines(f))
c_obj$preprocessed = system2("gcc", c("-fpreprocessed", "-E", f), stdout=TRUE, stderr=FALSE)
for (linter in ls(linter_env)) linter_env[[linter]](c_obj)
# TODO(#6272): Incorporate more checks from CRAN_Release
}
shell: Rscript {0}
lint-po:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: r-lib/actions/setup-r@v2
- name: Check translations
run: |
linter_env = new.env()
for (f in list.files('.ci/linters/po', full.names=TRUE)) sys.source(f, linter_env)
for (po_file in list.files(pattern = "[.]po$", full.names=TRUE)) {
# only pay attention to files edited in the current PR, otherwise we can get
# a situation like after #6424 where some untranslated messages were added
# as part of non-translation maintenance, but this GHA would go red repeatedly
# until a translation is added or the blank/fuzzy translations removed. We'd
# rather only have the failure on one PR, then ignore these files later.
diff_v_master = system2("git", c("diff", "master", po_file), stdout=TRUE)
if (!length(diff_v_master)) next
for (linter in ls(linter_env)) linter_env[[linter]](po_file)
}
shell: Rscript {0}
lint-md:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Lint
run: for (f in list.files('.ci/linters/md', full.names=TRUE)) source(f)
shell: Rscript {0}