-
Notifications
You must be signed in to change notification settings - Fork 2
/
lint-tasks.yaml
190 lines (174 loc) · 4.97 KB
/
lint-tasks.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
version: "3"
vars:
G_LINT_VENV_DIR: "{{.G_BUILD_DIR}}/lint-venv"
G_LINT_VENV_CHECKSUM_FILE: "{{.G_BUILD_DIR}}/lint#venv.md5"
tasks:
check:
cmds:
- task: "cmake-check"
- task: "cpp-check"
- task: "yml-check"
fix:
cmds:
- task: "cmake-fix"
- task: "cpp-fix"
- task: "yml-fix"
cmake-check:
deps: ["venv"]
cmds:
- task: "cmake"
vars:
FLAGS: "--check"
cmake-fix:
deps: ["venv"]
cmds:
- task: "cmake"
vars:
FLAGS: "--in-place"
cpp-configs: "tools/yscope-dev-utils/lint-configs/symlink-cpp-lint-configs.sh"
cpp-check:
cmds:
- task: "cpp-format-check"
- task: "cpp-static-check"
cpp-fix:
cmds:
- task: "cpp-format-fix"
- task: "cpp-static-fix"
cpp-format-check:
sources: &cpp_format_src_files
- "{{.G_LINT_VENV_CHECKSUM_FILE}}"
- "{{.G_SRC_SPIDER_DIR}}/.clang-format"
- "{{.G_SRC_SPIDER_DIR}}/**/*.cpp"
- "{{.G_SRC_SPIDER_DIR}}/**/*.h"
- "{{.G_SRC_SPIDER_DIR}}/**/*.hpp"
- "{{.G_TEST_DIR}}/**/*.cpp"
- "{{.G_TEST_DIR}}/**/*.h"
- "{{.G_TEST_DIR}}/**/*.hpp"
- "{{.TASKFILE}}"
- "tools/yscope-dev-utils/lint-configs/.clang-format"
deps: ["cpp-configs", "venv"]
cmds:
- task: "clang-format"
vars:
FLAGS: "--dry-run"
SRC_DIR: "{{.G_SRC_SPIDER_DIR}}"
cpp-format-fix:
sources: *cpp_format_src_files
deps: ["cpp-configs", "venv"]
cmds:
- task: "clang-format"
vars:
FLAGS: "-i"
SRC_DIR: "{{.G_SRC_SPIDER_DIR}}"
- task: "clang-format"
vars:
FLAGS: "-i"
SRC_DIR: "{{.G_TEST_DIR}}"
cpp-static-check:
# Alias task to `cpp-static-fix` since we don't currently support automatic fixes.
# NOTE: clang-tidy does have the ability to fix some errors, but the fixes can be inaccurate.
# When we eventually determine which errors can be safely fixed, we'll allow clang-tidy to
# fix them.
aliases: ["cpp-static-fix"]
sources:
- "{{.G_LINT_VENV_CHECKSUM_FILE}}"
- "{{.G_SRC_SPIDER_DIR}}/**/*.cpp"
- "{{.G_SRC_SPIDER_DIR}}/**/*.h"
- "{{.G_SRC_SPIDER_DIR}}/**/*.hpp"
- "{{.G_TEST_DIR}}/**/*.cpp"
- "{{.G_TEST_DIR}}/**/*.h"
- "{{.G_TEST_DIR}}/**/*.hpp"
- "{{.G_SPIDER_CMAKE_CACHE}}"
- "{{.G_SPIDER_COMPILE_COMMANDS_DB}}"
- "{{.TASKFILE}}"
- "taskfile.yaml"
- "tools/yscope-dev-utils/lint-configs/.clang-tidy"
deps: [":config-cmake-project", "cpp-configs", "venv"]
cmds:
- task: "clang-tidy"
vars:
FLAGS: "--config-file=.clang-tidy -p {{.G_SPIDER_COMPILE_COMMANDS_DB}}"
SRC_DIR: "{{.G_SRC_SPIDER_DIR}}"
TEST_DIR: "{{.G_TEST_DIR}}"
yml:
aliases:
- "yml-check"
- "yml-fix"
deps: ["venv"]
cmds:
- |-
. "{{.G_LINT_VENV_DIR}}/bin/activate"
yamllint \
--config-file "tools/yscope-dev-utils/lint-configs/.yamllint.yml" \
--strict \
.gersemirc \
.github/ \
build-tasks.yaml \
dep-tasks.yaml \
lint-tasks.yaml \
taskfile.yaml \
test-tasks.yaml
clang-format:
internal: true
requires:
vars: ["FLAGS", "SRC_DIR"]
cmd: |-
. "{{.G_LINT_VENV_DIR}}/bin/activate"
find "{{.SRC_DIR}}" \
-type f \
\( -iname "*.cpp" -o -iname "*.h" -o -iname "*.hpp" \) \
-print0 | \
xargs -0 --no-run-if-empty clang-format {{.FLAGS}} -Werror
clang-tidy:
internal: true
requires:
vars: ["FLAGS", "SRC_DIR", "TEST_DIR"]
cmd: |-
. "{{.G_LINT_VENV_DIR}}/bin/activate"
find "{{.SRC_DIR}}" "{{.TEST_DIR}}" \
-type f \
\( -iname "*.cpp" -o -iname "*.h" -o -iname "*.hpp" \) \
-print0 | \
xargs -0 --no-run-if-empty clang-tidy {{.FLAGS}}
cmake:
internal: true
requires:
vars: ["FLAGS"]
sources:
- "CMakeLists.txt"
- "src/spider/CMakeLists.txt"
- "tests/CMakeLists.txt"
- "cmake/Modules/*.cmake"
cmds:
- for: "sources"
cmd: |-
. "{{.G_LINT_VENV_DIR}}/bin/activate"
gersemi {{.FLAGS}} {{.ITEM}}
venv:
internal: true
vars:
CHECKSUM_FILE: "{{.G_LINT_VENV_CHECKSUM_FILE}}"
OUTPUT_DIR: "{{.G_LINT_VENV_DIR}}"
sources:
- "{{.ROOT_DIR}}/taskfile.yaml"
- "{{.TASKFILE}}"
- "lint-requirements.txt"
generates: ["{{.CHECKSUM_FILE}}"]
run: "once"
deps:
- ":init"
- task: ":utils:validate-checksum"
vars:
CHECKSUM_FILE: "{{.CHECKSUM_FILE}}"
DATA_DIR: "{{.OUTPUT_DIR}}"
cmds:
- task: ":utils:create-venv"
vars:
LABEL: "lint"
OUTPUT_DIR: "{{.OUTPUT_DIR}}"
REQUIREMENTS_FILE: "lint-requirements.txt"
# This command must be last
- task: ":utils:compute-checksum"
vars:
DATA_DIR: "{{.OUTPUT_DIR}}"
OUTPUT_FILE: "{{.CHECKSUM_FILE}}"