-
Notifications
You must be signed in to change notification settings - Fork 98
412 lines (348 loc) · 14.6 KB
/
buildAndTest.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
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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
name: Build and Test
on:
push:
branches:
- main
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:
build-repo:
name: Build and Test
# By latest GitHub means actually latest LTS only
runs-on: ubuntu-latest
strategy:
# Run all the test even if there are some which fail
fail-fast: false
# Run the tests on the Cartesian product of the following
matrix:
build_type: [ Assert, Release ]
ubuntu_version: [ 20.04, 22.04 ]
steps:
# Clone the repo and its submodules. Do shallow clone to save clone
# time.
- name: Get the project repository
uses: actions/checkout@v3
with:
fetch-depth: 2
submodules: "true"
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install Python packages
run: |
pip install cmake numpy psutil pybind11 rich pkginfo lit PyYAML
- name: Install packages
run: sudo apt-get install -y ninja-build clang lld
- name: Get MLIR
id: mlir-wheels
run: |
pip -q download mlir -f https://github.com/Xilinx/mlir-aie/releases/expanded_assets/mlir-distro && unzip -q mlir-*.whl
WHL=$(ls mlir-*.whl)
echo "MLIR_WHEEL_VERSION=$(python -c "import pkginfo; w = pkginfo.Wheel('$WHL'); print(w.version.split('+')[0] + '+' + w.version.split('+')[1].rsplit('.', 1)[-1])")" | tee -a $GITHUB_OUTPUT
echo "MLIR_DIR=$PWD/mlir" | tee -a $GITHUB_OUTPUT
- name: Ccache for C++ compilation
uses: hendrikmuhs/ccache-action@ca3acd2731eef11f1572ccb126356c2f9298d35e
with:
# Since there are now several compilation jobs running in parallel,
# use a different key per job to avoid a ccache writing race condition
key: ${{ matrix.build_type }}-${{ runner.os }}-${{ matrix.ubuntu_version }}-${{ steps.mlir-wheels.outputs.MLIR_WHEEL_VERSION }}
max-size: 1G
# Build the repo test target in debug mode to build and test.
- name: Build and test (Assert)
if: matrix.build_type == 'Assert'
run: |
mkdir build_assert
cd build_assert
cmake .. \
-GNinja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_EXE_LINKER_FLAGS_INIT="-fuse-ld=lld" -DCMAKE_MODULE_LINKER_FLAGS_INIT="-fuse-ld=lld" -DCMAKE_SHARED_LINKER_FLAGS_INIT="-fuse-ld=lld" \
-DCMAKE_PLATFORM_NO_VERSIONED_SONAME=ON \
-DCMAKE_VISIBILITY_INLINES_HIDDEN=ON \
-DCMAKE_C_VISIBILITY_PRESET=hidden \
-DCMAKE_CXX_VISIBILITY_PRESET=hidden \
-DAIE_COMPILER=NONE \
-DAIE_LINKER=NONE \
-DHOST_COMPILER=NONE \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_RTTI=ON \
-DCMAKE_MODULE_PATH=`pwd`/../cmake/modulesXilinx \
-DMLIR_DIR=${{ steps.mlir-wheels.outputs.MLIR_DIR }}/lib/cmake/mlir \
-DLLVM_DIR=${{ steps.mlir-wheels.outputs.MLIR_DIR }}/lib/cmake/llvm \
-DLLVM_USE_LINKER=lld \
-DLLVM_EXTERNAL_LIT=$(which lit) \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
ninja
ninja check-aie
ninja check-tutorials
ninja check-reference-designs
# Build the repo test target in release mode to build and test.
- name: Build and test (Release)
if: matrix.build_type == 'Release'
run: |
mkdir build_release
cd build_release
cmake .. \
-GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_EXE_LINKER_FLAGS_INIT="-fuse-ld=lld" -DCMAKE_MODULE_LINKER_FLAGS_INIT="-fuse-ld=lld" -DCMAKE_SHARED_LINKER_FLAGS_INIT="-fuse-ld=lld" \
-DCMAKE_PLATFORM_NO_VERSIONED_SONAME=ON \
-DCMAKE_VISIBILITY_INLINES_HIDDEN=ON \
-DCMAKE_C_VISIBILITY_PRESET=hidden \
-DCMAKE_CXX_VISIBILITY_PRESET=hidden \
-DAIE_COMPILER=NONE \
-DAIE_LINKER=NONE \
-DHOST_COMPILER=NONE \
-DLLVM_ENABLE_ASSERTIONS=OFF \
-DLLVM_ENABLE_RTTI=ON \
-DCMAKE_MODULE_PATH=`pwd`/../cmake/modulesXilinx \
-DMLIR_DIR=${{ steps.mlir-wheels.outputs.MLIR_DIR }}/lib/cmake/mlir \
-DLLVM_DIR=${{ steps.mlir-wheels.outputs.MLIR_DIR }}/lib/cmake/llvm \
-DLLVM_USE_LINKER=lld \
-DLLVM_EXTERNAL_LIT=$(which lit)
ninja
ninja check-aie
ninja check-tutorials
ninja check-reference-designs
clang-tidy-pylint:
name: Python and C/C++ Lint
runs-on: ubuntu-22.04
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 2
submodules: "true"
- name: Install clang-tidy
run: |
sudo apt-get update
sudo apt-get install -y clang-tidy ninja-build clang
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install Python packages
run: |
pip install cmake numpy psutil pybind11 rich pkginfo lit PyYAML requests
- name: Get MLIR
id: mlir-wheels
run: |
pip -q download mlir -f https://github.com/Xilinx/mlir-aie/releases/expanded_assets/mlir-distro && unzip -q mlir-*.whl
echo "MLIR_DIR=$PWD/mlir" | tee -a $GITHUB_OUTPUT
- name: Prepare compile_commands.json
run: |
mkdir build
pushd build
cmake .. \
-GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_PLATFORM_NO_VERSIONED_SONAME=ON \
-DCMAKE_VISIBILITY_INLINES_HIDDEN=ON \
-DCMAKE_C_VISIBILITY_PRESET=hidden \
-DCMAKE_CXX_VISIBILITY_PRESET=hidden \
-DAIE_COMPILER=NONE \
-DAIE_LINKER=NONE \
-DHOST_COMPILER=NONE \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_RTTI=ON \
-DCMAKE_MODULE_PATH=`pwd`/../cmake/modulesXilinx \
-DMLIR_DIR=${{ steps.mlir-wheels.outputs.MLIR_DIR }}/lib/cmake/mlir \
-DLLVM_DIR=${{ steps.mlir-wheels.outputs.MLIR_DIR }}/lib/cmake/llvm \
-DLLVM_EXTERNAL_LIT=$(which lit) \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
ninja aie-headers mlir-headers
popd
- name: Analyze
run: |
git fetch origin main
git diff -U0 origin/main | clang-tidy-diff -p1 -path build -export-fixes fixes.yml
- name: Post clang-tidy requests
env:
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
PULL_REQUEST_ID="$(jq "if (.issue.number != null) then .issue.number else .number end" < "$GITHUB_EVENT_PATH")"
echo $PULL_REQUEST_ID
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} python utils/git/clang-tidy-pr.py \
--clang-tidy-fixes fixes.yml \
--pull-request-id "$PULL_REQUEST_ID" \
--repository "$GITHUB_REPOSITORY" \
--repository-root "$PWD" \
--request-changes "false" \
--suggestions-per-comment 10
- uses: dciborow/[email protected]
env:
PYTHONPATH: build/python
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-review
# GitHub Status Check won't become failure with warning.
level: warning
filter_mode: diff_context
# filter_mode: nofilter
workdir: python
glob_pattern: "**/*.py"
- uses: dciborow/[email protected]
env:
PYTHONPATH: build/python
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-review
# GitHub Status Check won't become failure with warning.
level: warning
filter_mode: diff_context
# filter_mode: nofilter
workdir: test/python
glob_pattern: "**/*.py"
formatting:
name: Python and C/C++ Formatting
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.11'
- 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
- name: Check C/C++ format
uses: reviewdog/action-suggester@v1
with:
tool_name: clang-format
level: error
fail_on_error: true
cleanup: true
- name: Run black format
if: success() || failure()
id: black-format
run: |
# FORMATTED=0
black --exclude python/compiler/aiecc/main.py . || true
black -l 10000 python/compiler/aiecc/main.py || true
# FORMATTED=$(git status -s -uno | wc -l | xargs)
# echo "FORMATTED=$FORMATTED" | tee -a $GITHUB_OUTPUT
- name: Check Python format
if: success() || failure()
uses: reviewdog/action-suggester@v1
with:
tool_name: black
level: error
fail_on_error: true
code-coverage:
name: C/C++ test code coverage
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"
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install Python and other packages
run: |
pip install cmake numpy psutil pybind11 rich lit
- name: Install Ninja
run: sudo apt-get install -y ninja-build clang lld llvm
- name: Get changed files
id: changed-files
run: |
git fetch origin main
# Because for the life of me I cannot figure out how to read the output of git diff into a bash array.
CHANGED_FILES=$(python utils/get_git_changed_files.py)
echo "changed-files=${CHANGED_FILES}" | tee $GITHUB_OUTPUT
- name: Get MLIR
id: mlir-wheels
run: |
pip -q download mlir -f https://github.com/Xilinx/mlir-aie/releases/expanded_assets/mlir-distro && unzip -q mlir-*.whl
echo "MLIR_DIR=$PWD/mlir" | tee -a $GITHUB_OUTPUT
- name: Ccache for C++ compilation
if: steps.changed-files.outputs.changed-files != ''
uses: hendrikmuhs/ccache-action@ca3acd2731eef11f1572ccb126356c2f9298d35e
with:
key: ${{ runner.os }}-${{ matrix.ubuntu_version }}-${{ steps.get-llvm-commit-hash.outputs.hash }}-code-cov
max-size: 1G
- name: Install our python reqs
if: steps.changed-files.outputs.changed-files != ''
run: pip install -r python/requirements.txt
- name: Build and generate coverage (Release)
if: steps.changed-files.outputs.changed-files != ''
run: |
mkdir build_release
cd build_release
cmake .. \
-GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PLATFORM_NO_VERSIONED_SONAME=ON \
-DCMAKE_VISIBILITY_INLINES_HIDDEN=ON \
-DCMAKE_C_VISIBILITY_PRESET=hidden \
-DCMAKE_CXX_VISIBILITY_PRESET=hidden \
-DAIE_COMPILER=NONE \
-DAIE_LINKER=NONE \
-DHOST_COMPILER=NONE \
-DLLVM_ENABLE_ASSERTIONS=OFF \
-DLLVM_ENABLE_RTTI=ON \
-DCMAKE_MODULE_PATH=`pwd`/../cmake/modulesXilinx \
-DMLIR_DIR=${{ steps.mlir-wheels.outputs.MLIR_DIR }}/lib/cmake/mlir \
-DLLVM_DIR=${{ steps.mlir-wheels.outputs.MLIR_DIR }}/lib/cmake/llvm \
-DLLVM_USE_LINKER=lld \
-DLLVM_EXTERNAL_LIT=$(which lit) \
\
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_EXE_LINKER_FLAGS_INIT="-fuse-ld=lld" -DCMAKE_MODULE_LINKER_FLAGS_INIT="-fuse-ld=lld" -DCMAKE_SHARED_LINKER_FLAGS_INIT="-fuse-ld=lld" \
-DBUILD_INSTRUMENTED_COVERAGE=ON \
-DINSTRUMENTED_COVERAGE_FILES="${{ steps.changed-files.outputs.changed-files }}"
ninja && ninja generate-aie-coverage-report
cat /home/runner/work/mlir-aie/mlir-aie/build_release/report/summary.txt
- name: Format coverage report
if: steps.changed-files.outputs.changed-files != ''
id: format-report
run: |
sed -i.bak 's/<!doctype html>/<!--<!doctype codecov html>-->/g' /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
sed -i.bak 's/<pre>//g' /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
sed -i.bak 's/<\/pre>//g' /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
sed -i.bak 's/([0-9]*\/[0-9]*)//g' /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
sed -i.bak "s/href=/href=''/g" /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
WORKSPACE=$(echo "/home/runner/work/mlir-aie/mlir-aie/" | sed 's/\//\\\//g')
sed -i.bak "s/$WORKSPACE//g" /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
- name: Update PR with coverage results
if: steps.changed-files.outputs.changed-files != '' && github.event.pull_request.head.repo.full_name == github.repository
uses: edumserrano/find-create-or-update-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: '<!--<!doctype codecov html>-->'
comment-author: 'github-actions[bot]'
body-path: /home/runner/work/mlir-aie/mlir-aie/build_release/report/index.html
edit-mode: replace