-
Notifications
You must be signed in to change notification settings - Fork 15
105 lines (90 loc) · 3 KB
/
clang-tidy.yml
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
name: check clang-tidy
permissions:
contents: read
on:
pull_request:
jobs:
clang_tidy:
runs-on: "ubuntu-latest"
env:
GH_TOKEN: ${{ github.token }}
steps:
- name: Install OpenMP
run: "sudo apt install -y libomp-dev opencl-c-headers"
- name: Fetch sources
uses: actions/checkout@v4
with:
path: 'graph-compiler'
fetch-depth: 0
submodules: true
- name: Fetch code tidy utils
uses: actions/checkout@v4
with:
repository: 'llvm/llvm-project'
ref: 'main'
sparse-checkout: |
clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
mlir/python/requirements.txt
mlir/.clang-tidy
sparse-checkout-cone-mode: false
path: llvm-project
- name: Read llvm version and run id
shell: bash
run: |
echo LLVM_HASH=$(cat graph-compiler/cmake/llvm-version.txt) >> $GITHUB_ENV
- name: Fetch llvm artifact
run: |
gh run download \
--repo ${{ github.repository }} \
-n "llvm-${{ env.LLVM_HASH }}" \
--dir llvm
tar -zxf llvm/llvm.tgz
- name: Unwrap pre-built llvm
run: |
cd llvm
tar -zxf llvm.tgz
- name: Get merge base
run: |
cd graph-compiler
echo "MERGE_BASE=$(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})" >> $GITHUB_ENV
- name: Get changed files
run: |
cd graph-compiler
echo "CHANGED_FILES=$(git diff --name-only --diff-filter=d $MERGE_BASE ${{ github.event.pull_request.head.sha }} | paste -sd' ')" >> $GITHUB_ENV
- name: Prepare Environment
shell: bash
run: |
python3 -m pip install -r llvm-project/mlir/python/requirements.txt
python3 -m pip install lit
- name: Prepare compile commands
shell: bash
run: |
mkdir build
cd build
cmake ../graph-compiler \
-DCMAKE_BUILD_TYPE=Release \
-DMLIR_DIR=$(pwd)/../llvm/lib/cmake/mlir \
-DCMAKE_EXPORT_COMPILE_COMMANDS=True \
-DCMAKE_C_COMPILER=$(which clang) \
-DCMAKE_CXX_COMPILER=$(which clang++) \
-DLLVM_EXTERNAL_LIT=$(which lit) \
-DDNNL_USE_CLANG_SANITIZER="Undefined"
- name: Prepare inc file
run: |
cd build
for f in $(find ./include -name Makefile); do
set +e;
targets=$(make -f $f help |grep IncGen);
if [[ $? -eq 0 ]]; then
set -e;
for target in $targets; do
cd ${f%Makefile} && make ${target#...} && cd -;
done
fi ;
set -e;
done
- name: Perform clang-tidy check
shell: bash
run: |
cd build
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-15) ${{ env.CHANGED_FILES }}