Skip to content

Commit ddd9ee8

Browse files
committed
backport clangtidy workflow files
Signed-off-by: nindanaoto <matsuoka.kotaro@gmail.com>
1 parent ac0a756 commit ddd9ee8

File tree

4 files changed

+187
-68
lines changed

4 files changed

+187
-68
lines changed

.github/workflows/clang-tidy-review.yml

Lines changed: 0 additions & 63 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# SPDX-License-Identifier: MIT
2+
# Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.
3+
name: clang-tidy-post
4+
5+
on:
6+
workflow_run:
7+
workflows: ["clang-tidy-review"]
8+
types:
9+
- completed
10+
11+
permissions:
12+
pull-requests: write
13+
issues: write
14+
checks: write
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Post review messages
22+
uses: stsoe/clang-tidy-review/post/@patches
23+
with:
24+
token: ${{ secrets.GITHUB_TOKEN }}
25+
annotations: false
26+
max_comments: 25
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# SPDX-License-Identifier: MIT
2+
# Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.
3+
name: clang-tidy-review
4+
5+
on:
6+
pull_request:
7+
types: [opened, synchronize, reopened]
8+
branches: master
9+
10+
workflow_dispatch:
11+
12+
jobs:
13+
clangtidy:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
submodules: recursive
20+
fetch-depth: 0
21+
22+
# Dependencies needed for external cmake configuration
23+
- name: Install dependencies
24+
run: |
25+
sudo apt update
26+
sudo src/runtime_src/tools/scripts/xrtdeps.sh
27+
28+
- name: Configure legacy XRT build
29+
run: |
30+
cmake -B build/legacy \
31+
-DXRT_ENABLE_HIP=ON \
32+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
33+
-DCMAKE_BUILD_TYPE=Release src
34+
35+
- name: Configure edge XRT
36+
run: |
37+
env XRT_NATIVE_BUILD=no cmake -B build/edge \
38+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
39+
-DCMAKE_BUILD_TYPE=Release src
40+
41+
- name: Configure NPU XRT
42+
run: |
43+
cmake -B build/npu \
44+
-DXRT_NPU=1 \
45+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
46+
-DCMAKE_BUILD_TYPE=Release src
47+
48+
- name: Merge databases into one compile_commands.json
49+
run: |
50+
python <<EOF
51+
import json, os
52+
53+
# Last entry is preserved
54+
build_dirs = ["build/npu", "build/edge", "build/legacy"]
55+
merged_commands = {}
56+
57+
for build_dir in build_dirs:
58+
json_path = os.path.join(build_dir, "compile_commands.json")
59+
if os.path.exists(json_path):
60+
with open(json_path, "r") as f:
61+
commands = json.load(f)
62+
for entry in commands:
63+
merged_commands[entry["file"]] = entry
64+
65+
with open("compile_commands.json", "w") as f:
66+
json.dump(list(merged_commands.values()), f, indent=2)
67+
68+
print("Merged compile_commands.json created.")
69+
EOF
70+
71+
- name: Upload merged database
72+
uses: actions/upload-artifact@v4
73+
with:
74+
name: compile_commands
75+
path: compile_commands.json
76+
77+
# Review uses external combined database
78+
- name: Create clang-tidy review
79+
id: review
80+
uses: stsoe/clang-tidy-review@patches
81+
with:
82+
apt_packages: |
83+
cmake, g++, pkg-config, libdrm-dev,
84+
ocl-icd-dev, ocl-icd-libopencl1, ocl-icd-opencl-dev,
85+
libamdhip64-dev,
86+
libboost-dev, libboost-filesystem-dev, libboost-program-options-dev,
87+
libncurses5-dev,
88+
libssl-dev,
89+
rapidjson-dev,
90+
libelf-dev,
91+
libprotoc-dev, protobuf-compiler,
92+
uuid-dev,
93+
systemtap-sdt-dev,
94+
curl, libcurl4-openssl-dev,
95+
libudev-dev
96+
# disable default checks and rely on closest .clangtidy
97+
clang_tidy_checks: ''
98+
split_workflow: true
99+
100+
- name: Upload clang-tidy review
101+
uses: stsoe/clang-tidy-review/upload@patches
102+
id: upload-review

.github/workflows/clangtidy.yml

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,89 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout XRT
14-
uses: actions/checkout@v2
14+
uses: actions/checkout@v4
15+
with:
16+
submodules: recursive
17+
fetch-depth: 0
18+
1519
- name: Store sha
1620
run: echo ${{ github.sha }} > sha
21+
1722
- name: Compare sha
18-
uses: actions/cache@v2
23+
uses: actions/cache@v4
1924
id: cache-sha
2025
with:
2126
path: sha
2227
key: clangtidy-${{ github.sha }}
28+
2329
- name: Install dependencies
2430
if: steps.cache-sha.outputs.cache-hit != 'true'
2531
run: |
2632
sudo apt update
2733
sudo src/runtime_src/tools/scripts/xrtdeps.sh
2834
sudo pip3 install clang-html
35+
36+
- name: Configure legacy XRT
37+
if: steps.cache-sha.outputs.cache-hit != 'true'
38+
run: |
39+
cmake -B build/legacy \
40+
-DXRT_ENABLE_HIP=ON \
41+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
42+
-DCMAKE_BUILD_TYPE=Release src
43+
44+
- name: Configure edge XRT
45+
if: steps.cache-sha.outputs.cache-hit != 'true'
46+
run: |
47+
env XRT_NATIVE_BUILD=no cmake -B build/edge \
48+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
49+
-DCMAKE_BUILD_TYPE=Release src
50+
51+
- name: Configure NPU XRT
52+
if: steps.cache-sha.outputs.cache-hit != 'true'
53+
run: |
54+
cmake -B build/npu \
55+
-DXRT_NPU=1 \
56+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
57+
-DCMAKE_BUILD_TYPE=Release src
58+
59+
- name: Merge compile commands
60+
if: steps.cache-sha.outputs.cache-hit != 'true'
61+
run: |
62+
python <<EOF
63+
import json, os
64+
65+
build_dirs = ["build/legacy", "build/edge", "build/npu"]
66+
merged_commands = {}
67+
68+
for build_dir in build_dirs:
69+
json_path = os.path.join(build_dir, "compile_commands.json")
70+
if os.path.exists(json_path):
71+
with open(json_path, "r") as f:
72+
commands = json.load(f)
73+
for entry in commands:
74+
merged_commands[entry["file"]] = entry
75+
76+
with open("compile_commands.json", "w") as f:
77+
json.dump(list(merged_commands.values()), f, indent=2)
78+
79+
print("Merged compile_commands.json created.")
80+
EOF
81+
2982
- name: Build with clangtidy
3083
if: steps.cache-sha.outputs.cache-hit != 'true'
3184
run: |
32-
build/build.sh -clangtidy -opt |& tee build.clangtidy.log
85+
run-clang-tidy -p . -j 16 -export-fixes=fixes.yml |& tee build.clangtidy.log
3386
clang-tidy-html build.clangtidy.log
87+
3488
- name: Upload clang raw log
3589
if: steps.cache-sha.outputs.cache-hit != 'true'
36-
uses: actions/upload-artifact@v1
90+
uses: actions/upload-artifact@v4
3791
with:
3892
name: clang-tidy-log
3993
path: build.clangtidy.log
4094
- name: Upload clang html
4195
if: steps.cache-sha.outputs.cache-hit != 'true'
42-
uses: actions/upload-artifact@v1
96+
uses: actions/upload-artifact@v4
4397
with:
4498
name: clang-tidy-html
4599
path: clang.html

0 commit comments

Comments
 (0)