Skip to content

Commit 0225874

Browse files
committed
action: enable clang tidy
1 parent 5de3506 commit 0225874

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed

.github/workflows/clang-tidy.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: check clang-tidy
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
pull_request:
8+
9+
jobs:
10+
clang_tidy:
11+
runs-on: "ubuntu-latest"
12+
env:
13+
GH_TOKEN: ${{ github.token }}
14+
15+
steps:
16+
- name: Fetch sources
17+
uses: actions/checkout@v4
18+
with:
19+
path: 'graph-compiler'
20+
fetch-depth: 0
21+
submodules: true
22+
23+
- name: Fetch code tidy utils
24+
uses: actions/checkout@v4
25+
with:
26+
repository: 'llvm/llvm-project'
27+
ref: 'main'
28+
sparse-checkout: |
29+
clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
30+
mlir/python/requirements.txt
31+
mlir/.clang-tidy
32+
sparse-checkout-cone-mode: false
33+
path: llvm-project
34+
35+
- name: Read llvm version and run id
36+
shell: bash
37+
run: |
38+
echo LLVM_HASH=$(cat graph-compiler/cmake/llvm-version.txt) >> $GITHUB_ENV
39+
echo RUN_ID=$(gh run list -w "LLVM Build" --repo intel/graph-compiler --json databaseId --jq '.[0].databaseId') >> $GITHUB_ENV
40+
41+
- name: Fetch llvm artifact
42+
uses: actions/download-artifact@v4
43+
with:
44+
name: "llvm-${{ env.LLVM_HASH }}"
45+
path: llvm
46+
github-token: ${{ github.token }}
47+
run-id: ${{ env.RUN_ID }}
48+
49+
- name: Unwrap pre-built llvm
50+
run: |
51+
cd llvm
52+
tar -zxf llvm.tgz
53+
54+
- name: Get merge base
55+
run: |
56+
cd graph-compiler
57+
echo "MERGE_BASE=$(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})" >> $GITHUB_ENV
58+
59+
- name: Get changed files
60+
run: |
61+
cd graph-compiler
62+
echo "CHANGED_FILES=$(git diff --name-only $MERGE_BASE ${{ github.event.pull_request.head.sha }} | paste -sd' ')" >> $GITHUB_ENV
63+
64+
- name: Prepare Environment
65+
shell: bash
66+
run: |
67+
python3 -m pip install -r llvm-project/mlir/python/requirements.txt
68+
python3 -m pip install lit
69+
70+
- name: Prepare compile commands
71+
shell: bash
72+
run: |
73+
mkdir build
74+
cd build
75+
cmake ../graph-compiler \
76+
-DCMAKE_BUILD_TYPE=Release \
77+
-DMLIR_DIR=$(pwd)/../llvm/lib/cmake/mlir \
78+
-DCMAKE_EXPORT_COMPILE_COMMANDS=True \
79+
-DCMAKE_C_COMPILER=$(which clang) \
80+
-DCMAKE_CXX_COMPILER=$(which clang++) \
81+
-DLLVM_EXTERNAL_LIT=$(which lit)
82+
83+
- name: Prepare inc file
84+
run: |
85+
cd build
86+
for f in $(find ./include -name Makefile); do
87+
set +e;
88+
target=$(make -f $f help |grep IncGen);
89+
if [[ $? -eq 0 ]]; then
90+
set -e;
91+
cd ${f%Makefile} && make ${target#...} && cd -;
92+
fi ;
93+
set -e;
94+
done
95+
96+
- name: Perform clang-tidy check
97+
shell: bash
98+
run: |
99+
cd build
100+
python3 ../llvm-project/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py -warnings-as-errors=* -p ./ -config-file ../llvm-project/mlir/.clang-tidy -clang-tidy-binary $(which clang-tidy) ${{ env.CHANGED_FILES }}

0 commit comments

Comments
 (0)