forked from ROCm/rocm-libraries
-
Notifications
You must be signed in to change notification settings - Fork 0
312 lines (285 loc) · 11.7 KB
/
Copy pathclang-tidy.yml
File metadata and controls
312 lines (285 loc) · 11.7 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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
name: clang-tidy
on:
# Paths filtering is intentionally not used at the trigger level.
# - For pushes, dorny/paths-filter in the setup job determines which opted-in
# libraries changed (via each library's path_filters) and builds the matrix.
# - For PRs, the workflow must always run so the required check is registered
# for every PR; the clang-tidy job is skipped when no opted-in component is affected.
push:
branches:
- develop
- release/therock-*
pull_request:
workflow_dispatch:
concurrency:
# For PRs, group by PR number so a new commit cancels any in-progress run
# for the same PR. For postsubmits, group by commit SHA (unique per commit)
# so runs never cancel each other. The workflow name is prepended to avoid
# conflicts between different workflows.
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
cancel-in-progress: true
jobs:
setup:
name: "Setup"
runs-on: ubuntu-24.04
outputs:
matrix: ${{ steps.build-matrix.outputs.matrix }}
steps:
- name: Checkout rocm-libraries
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
sparse-checkout: .github
sparse-checkout-cone-mode: true
fetch-depth: 2
- name: Define opted-in libraries
id: lib-config
run: |
# To opt in a new library: add one jq -cn block to LIBS below, then:
# - Add an "Install deps (<name>)" step in the clang-tidy job if needed.
# - Add a "Run clang-tidy (<name>)" step in the clang-tidy job.
# Required fields: name, path_filters (array), checkout_paths (array)
# Optional fields: (all build config is handled in the per-library run step)
# path_filters controls which file changes trigger clang-tidy for this library;
# use specific globs rather than /** to avoid false triggers.
# NOTE: dorny/paths-filter uses picomatch where '?' means "any single char",
# NOT GitHub Actions' "zero or one of preceding char". Use explicit extensions.
# checkout_paths lists all repo paths needed for sparse checkout.
LIBS=()
# hipDNN
LIBS+=($(jq -cn '{
name: "hipdnn",
path_filters: [
"projects/hipdnn/**/*.{c,h,cpp,hpp,cxx,hxx}",
"projects/hipdnn/cmake/ClangTidy.cmake",
"projects/hipdnn/.clang-tidy"
],
checkout_paths: ["projects/hipdnn"]
}'))
# stinkytofu
LIBS+=($(jq -cn '{
name: "stinkytofu",
path_filters: [
"shared/stinkytofu/**/*.{c,h,cpp,hpp,cxx,hxx,def}",
"shared/stinkytofu/.clang-tidy",
"cmake/modules/ClangTidy.cmake",
"cmake/modules/CheckToolVersion.cmake"
],
checkout_paths: ["shared/stinkytofu", "cmake/modules"]
}'))
# MIOpen
LIBS+=($(jq -cn '{
name: "miopen",
path_filters: [
"projects/miopen/**/*.{c,h,cpp,hpp,cxx,hxx}",
"projects/miopen/cmake/ClangTidy.cmake",
"projects/miopen/.clang-tidy"
],
checkout_paths: ["projects/miopen", "shared/ctest"]
}'))
# Disabled: see https://github.com/ROCm/rocm-libraries/issues/5067
# LIBS+=($(jq -cn '{
# name: "miopen-provider",
# path_filters: [
# "dnn-providers/miopen-provider/**/*.{c,h,cpp,hpp,cxx,hxx}",
# "dnn-providers/miopen-provider/cmake/ClangTidy.cmake",
# "dnn-providers/miopen-provider/.clang-tidy"
# ],
# checkout_paths: ["dnn-providers/miopen-provider"]
# }'))
# Common filters applied to every library — changes here re-run all opted-in libraries.
COMMON_FILTERS='[".github/workflows/clang-tidy.yml"]'
printf '%s\n' "${LIBS[@]}" \
| jq -rs --argjson common "$COMMON_FILTERS" \
'.[] | "\(.name):\n" + ((.path_filters + $common) | map(" - \"\(.)\"") | join("\n")) + "\n"' \
> path-filters.yml
LIBS_JSON=$(printf '%s\n' "${LIBS[@]}" \
| jq -sc '[.[] | . + {checkout_paths_str: (.checkout_paths | join("\n"))}]')
echo "libs=${LIBS_JSON}" >> "$GITHUB_OUTPUT"
- name: Detect changed opted-in projects
uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
id: changes
with:
filters: path-filters.yml
- name: Build job matrix
id: build-matrix
run: |
CHANGED='${{ steps.changes.outputs.changes }}'
LIBS='${{ steps.lib-config.outputs.libs }}'
IS_DISPATCH=${{ github.event_name == 'workflow_dispatch' }}
MATRIX=$(
echo "$LIBS" | jq -c \
--argjson changed "$CHANGED" \
--argjson dispatch "$IS_DISPATCH" \
'[.[] | select($dispatch or (.name as $n | $changed | index($n) != null))]
| {"include": .}'
)
echo "matrix=${MATRIX}" >> "$GITHUB_OUTPUT"
clang-tidy:
name: "clang-tidy (${{ matrix.name }})"
needs: setup
if: needs.setup.outputs.matrix != '{"include":[]}'
strategy:
matrix: ${{ fromJSON(needs.setup.outputs.matrix) }}
fail-fast: false
runs-on: azure-linux-scale-rocm
steps:
- name: Checkout rocm-libraries
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
sparse-checkout: ${{ matrix.checkout_paths_str }}
sparse-checkout-cone-mode: true
- name: Checkout TheRock
uses: actions/checkout@v6.0.2
with:
repository: ROCm/TheRock
path: TheRock
- name: Install base dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
ninja-build \
python3-venv \
python3-dev \
lsb-release wget \
software-properties-common \
gnupg
python3 -m venv .venv
. .venv/bin/activate
pip install boto3 cmake
pip install -r TheRock/requirements.txt
- name: Install ROCm
run: |
sudo .venv/bin/python3 TheRock/build_tools/install_rocm_from_artifacts.py \
--latest-release \
--amdgpu-family gfx94X-dcgpu \
--output-dir /opt/rocm \
--base-only
# Per-library optional dependency steps — only the matching step runs.
# Add a new step here when opting in a library that has custom deps.
- name: Install deps (hipDNN)
if: matrix.name == 'hipdnn'
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 20
sudo apt-get update
sudo apt-get install -y \
clang-tidy-20 \
clang-tools-20
- name: Install deps (stinkytofu)
if: matrix.name == 'stinkytofu'
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 20
sudo apt-get update
sudo apt-get install -y \
clang-tidy-20 \
clang-tools-20 \
libgtest-dev \
python3-dev
. .venv/bin/activate
pip install -r shared/stinkytofu/requirements.txt
- name: Install deps (miopen)
if: matrix.name == 'miopen'
run: |
. .venv/bin/activate
# cmake 4.x removed compat with cmake_minimum_required(VERSION <3.5);
# several MIOpen deps (e.g. bzip2@1.0.8) still declare old minimums.
pip install 'cmake<4' \
https://github.com/pfultz2/cget/archive/b5dd36cafa2804e6146c5021eb2469c4b2d3ad42.tar.gz \
https://github.com/RadeonOpenCompute/rbuild/archive/c33b1a7e74ae7f72379364b523f73d30fd4d765c.tar.gz
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 21
sudo apt-get install -y clang-tidy-21
cp projects/miopen/requirements.txt /tmp/requirements.txt
cp projects/miopen/rbuild.ini /tmp/rbuild.ini
cp projects/miopen/dev-requirements.txt /tmp/dev-requirements.txt
# Strip deps not available/needed on CI runner
sed -i '/composablekernel/d; /half/d; /rocMLIR/d' /tmp/requirements.txt
cd /tmp && CMAKE_GENERATOR=Ninja rbuild prepare -s develop -d /tmp/miopen-deps
# Disabled: see https://github.com/ROCm/rocm-libraries/issues/5067
# To re-enable: uncomment the LIBS entry above and these two steps.
# - name: Install deps (miopen-provider)
# if: matrix.name == 'miopen-provider'
# run: |
# wget https://apt.llvm.org/llvm.sh
# chmod +x llvm.sh
# sudo ./llvm.sh 20
# sudo apt-get update
# sudo apt-get install -y \
# clang-tidy-20 \
# clang-tools-20
# Per-library run steps — each library defines its own build and tidy sequence.
# Add a new step here when opting in a library.
- name: Run clang-tidy (hipDNN)
if: matrix.name == 'hipdnn'
run: |
. .venv/bin/activate
export PATH=/opt/rocm/bin:/opt/rocm/llvm/bin:$PATH
export CXX=/opt/rocm/llvm/bin/clang++
cmake -S projects/hipdnn -B build-hipdnn -G Ninja \
-DENABLE_CLANG_TIDY=ON \
-DROCM_PATH=/opt/rocm \
-DCMAKE_PREFIX_PATH=/opt/rocm \
-DENABLE_CLANG_FORMAT=OFF \
-DHIP_PLATFORM=amd \
-DHIPDNN_BUILD_PYTHON_BINDINGS=ON
ninja -C build-hipdnn tidy
- name: Run clang-tidy (stinkytofu)
if: matrix.name == 'stinkytofu'
run: |
. .venv/bin/activate
export ROCM_PATH=/opt/rocm
cd shared/stinkytofu
invoke build
invoke tidy
- name: Run clang-tidy (miopen)
if: matrix.name == 'miopen'
run: |
. .venv/bin/activate
export PATH=/opt/rocm/bin:/opt/rocm/llvm/bin:$PATH
export CXX=/opt/rocm/llvm/bin/clang++
# TODO: remove -DMIOPEN_USE_MLIR=OFF once rocMLIR is removed from MIOpen
cmake -S projects/miopen -B build-miopen -G Ninja \
-DMIOPEN_BACKEND=HIP \
-DBUILD_DEV=ON \
-DMIOPEN_USE_MLIR=OFF \
-DCLANG_TIDY_EXE=/usr/bin/clang-tidy-21 \
-DCMAKE_PREFIX_PATH="/opt/rocm;/tmp/miopen-deps" \
-DROCM_PATH=/opt/rocm
ninja -C build-miopen analyze
# Disabled: see https://github.com/ROCm/rocm-libraries/issues/5067
# - name: Run clang-tidy (miopen-provider)
# if: matrix.name == 'miopen-provider'
# run: |
# . .venv/bin/activate
# export PATH=/opt/rocm/bin:/opt/rocm/llvm/bin:$PATH
# export CXX=/opt/rocm/llvm/bin/clang++
# cmake -S dnn-providers/miopen-provider -B build-miopen-provider -G Ninja \
# -DENABLE_CLANG_TIDY=ON \
# -DROCM_PATH=/opt/rocm \
# -DCMAKE_PREFIX_PATH=/opt/rocm \
# -DENABLE_CLANG_FORMAT=OFF \
# -DHIP_PLATFORM=amd
# ninja -C build-miopen-provider tidy
clang_tidy_summary:
name: "clang-tidy summary"
if: always()
needs:
- setup
- clang-tidy
runs-on: ubuntu-24.04
steps:
- name: Output failed jobs
run: |
echo '${{ toJson(needs) }}'
FAILED_JOBS="$(echo '${{ toJson(needs) }}' \
| jq --raw-output \
'map_values(select(.result!="success" and .result!="skipped")) | keys | join(",")' \
)"
if [[ "${FAILED_JOBS}" != "" ]]; then
echo "The following jobs failed: ${FAILED_JOBS}"
exit 1
fi