-
Notifications
You must be signed in to change notification settings - Fork 26
188 lines (150 loc) · 5.12 KB
/
lintAndFormat.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
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
name: Lint and Format
on:
pull_request:
types: [assigned, opened, synchronize, reopened]
workflow_dispatch:
env:
# Run apt package manager in the CI in non-interactive mode.
# Otherwise, on Ubuntu 20.04 the installation of tzdata asking question
DEBIAN_FRONTEND: noninteractive
jobs:
clang-tidy-pylint:
name: C/C++ clang-tidy
runs-on: ubuntu-22.04
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
submodules: "true"
- name: Install clang-tidy
run: |
sudo apt-get update
sudo apt-get install -y clang-tidy ninja-build clang libelf-dev
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Get Submodule Hash
id: get-submodule-hash
run: echo "::set-output name=hash::$(md5sum $(echo utils/clone-mlir-aie.sh))"
shell: bash
- name: Ccache for C++ compilation
uses: hendrikmuhs/ccache-action@4687d037e4d7cf725512d9b819137a3af34d39b3
with:
key: ${{ runner.os }}-lintformat-${{ steps.get-submodule-hash.outputs.hash }}
max-size: 1G
- name: Build and Install libxaie
run: utils/github-clone-build-libxaie.sh
- name: Get mlir-aie
id: clone-mlir-aie
run: utils/clone-mlir-aie.sh
- name: Build and install mlir-aie
run: |
pushd mlir-aie
pip install -r python/requirements.txt
VERSION=$(utils/clone-llvm.sh --get-wheel-version)
pip -q download mlir==$VERSION \
-f https://github.com/Xilinx/mlir-aie/releases/expanded_assets/mlir-distro
unzip -q mlir-*.whl
find mlir -exec touch -a -m -t 201108231405.14 {} \;
popd
utils/github-build-mlir-aie.sh
- name: Prepare compile_commands.json
run: |
mkdir build
pushd build
cmake .. \
-GNinja \
-DCMAKE_TOOLCHAIN_FILE=`pwd`/../cmake/modules/toolchain_x86_64.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCMAKE_MODULE_PATH=`pwd`/../mlir-aie/cmake/modulesXilinx \
-DMLIR_DIR=`pwd`/../mlir-aie/mlir/lib/cmake/mlir \
-DLLVM_DIR=`pwd`/../mlir-aie/mlir/lib/cmake/llvm \
-DAIE_DIR=`pwd`/../mlir-aie/install/lib/cmake/aie/ \
-DLibXAIE_ROOT=`pwd`/../aienginev2/install \
-DAIR_RUNTIME_TARGETS:STRING="x86_64" \
-Dx86_64_TOOLCHAIN_FILE=`pwd`/../cmake/modules/toolchain_x86_64.cmake \
-DLLVM_EXTERNAL_LIT=$(which lit) \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
ninja air-headers mlir-headers
popd
- name: Analyze
id: clang-tidy-fixes
run: |
git fetch origin main
git diff -U0 origin/main | clang-tidy-diff -p1 -path build -export-fixes fixes.yml
if [ -f fixes.yml ]; then
echo "FIXES=true" | tee $GITHUB_OUTPUT
fi
- name: Upload clang-tidy fixes
if: ${{ steps.clang-tidy-fixes.outputs.FIXES }}
uses: actions/upload-artifact@v3
with:
path: fixes.yml
name: clang-tidy-fixes.yml
formatting:
name: Python and C/C++ Check Format
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Get the project repository
uses: actions/checkout@v3
with:
fetch-depth: 2
submodules: "true"
- name: Install clang-format
uses: aminya/setup-cpp@v1
with:
clangformat: 17.0.1
- name: Setup Python env
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install black
run: pip install black[jupyter]
- name: Run git-clang-format
id: git-clang-format
run: |
git fetch origin main
# git clang-format returns an error if changes made?
git clang-format origin/main || true
git diff > clang-format.diff
cat clang-format.diff
- name: Upload clang-format
uses: actions/upload-artifact@v3
with:
path: clang-format.diff
name: format_diffs
- name: Check C/C++ format
uses: reviewdog/action-suggester@v1
with:
tool_name: clang-format
level: error
cleanup: true
fail_on_error: true
- name: Run black format
if: success() || failure()
id: black-format
run: |
black . || true
git diff > black-format.diff
cat black-format.diff
- name: Upload black-format
uses: actions/upload-artifact@v3
with:
path: black-format.diff
name: format_diffs
- name: Check Python format
if: success() || failure()
uses: reviewdog/action-suggester@v1
with:
tool_name: black
level: error
fail_on_error: true