-
Notifications
You must be signed in to change notification settings - Fork 86
246 lines (217 loc) · 8.41 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
name: Build and Test
on:
push:
branches:
- main
pull_request:
types: [assigned, opened, synchronize, reopened]
workflow_dispatch:
defaults:
run:
# This is already the default, except when running inside another Docker
# image, which is the case here. So set it up globally to avoid
# repeating elsewhere.
shell: bash
env:
# Run apt package manager in the CI in non-interactive mode.
# Otherwise, on Ubuntu 20.04 the installation of tzdata asking question
# freezes libboost installation.
DEBIAN_FRONTEND: noninteractive
jobs:
build-repo:
name: Build and Test
# By latest GitHub means actually latest LTS only
runs-on: ubuntu-latest
permissions:
pull-requests: write
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 ]
# Using a container instead of running native on public GitHub
# Action has also the advantage of having 2 CPU instead of 1, so
# it runs faster. But these images have quite less software
# installed compared to the GitHub Ubuntu distribution for example.
container:
image: docker://ubuntu:${{matrix.ubuntu_version}}
steps:
- name: Display environment variables
run: env
- name: User and group ids
run: id -a
- name: Execution context information
# Display a lot of information to help further development
# https://docs.github.com/en/actions/learn-github-actions/variables
# https://docs.github.com/en/enterprise-cloud@latest/actions/learn-github-actions/contexts
# The problem is that echo-ing directly ${{ toJSON(github) }}
# in the shell is not escaped and for example '&' breaks
# things or can lead to server-side script injection. :-(
# So, use environment setting and display the environment
# variable in the shell between "" to avoid unsafe
# interpretation.
env:
execution_context_var_github: ${{ toJSON(github) }}
execution_context_var_env: ${{ toJSON(env) }}
execution_context_var_vars: ${{ toJSON(vars) }}
execution_context_var_job: ${{ toJSON(job) }}
execution_context_var_steps: ${{ toJSON(steps) }}
execution_context_var_runner: ${{ toJSON(runner) }}
execution_context_var_strategy: ${{ toJSON(strategy) }}
execution_context_var_matrix: ${{ toJSON(matrix) }}
execution_context_var_needs: ${{ toJSON(needs) }}
execution_context_var_inputs: ${{ toJSON(inputs) }}
run: |
echo "::group::github context"
echo "$execution_context_var_github"
echo "::endgroup::"
echo "::group::env context"
echo "$execution_context_var_env"
echo "::endgroup::"
echo "::group::vars context"
echo "$execution_context_var_vars"
echo "::endgroup::"
echo "::group::job context"
echo "$execution_context_var_job"
echo "::endgroup::"
echo "::group::steps context"
echo "$execution_context_var_steps"
echo "::endgroup::"
echo "::group::runner context"
echo "$execution_context_var_runner"
echo "::endgroup::"
echo "::group::strategy context"
echo "$execution_context_var_strategy"
echo "::endgroup::"
echo "::group::matrix context"
echo "$execution_context_var_matrix"
echo "::endgroup::"
echo "::group::needs context"
echo "$execution_context_var_needs"
echo "::endgroup::"
echo "::group::inputs context"
echo "$execution_context_var_inputs"
echo "::endgroup::"
- name: Configure Environment
run: echo "$GITHUB_WORKSPACE/llvm/install/bin" >> $GITHUB_PATH
- name: Install git
run: |
apt-get update
apt-get install -y git sudo
# 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"
- name: Install libboost
run: apt-get install -y libboost-all-dev
- name: Install Python and other packages
# Install cmake here to get the latest version to compile
# LLVM. The Ubuntu 20.04 cmake version is only 3.16.3
run: |
apt-get install -y pip
pip install cmake numpy psutil pybind11 rich
- name: Install Ninja
# Can not use the following since it wants to use `sudo` not
# available in the case of Docker execution
# https://github.com/llvm/actions/tree/main/install-ninja
# uses: llvm/actions/install-ninja@6a57890d0e3f9f35dfc72e7e48bc5e1e527cdd6c
# So just use the specific implementation instead:
run: apt-get install -y ninja-build
# Because the build requires to use explicitly this compiler
- name: Install Clang & Clang++ and linker
run: apt-get install -y clang lld
- name: Get Submodule Hash
id: get-submodule-hash
run: echo "hash=$(md5sum $(echo utils/clone-llvm.sh))" >> $GITHUB_OUTPUT
- name: Ccache for C++ compilation
# https://github.com/hendrikmuhs/ccache-action/releases/tag/v1.2.9
uses: hendrikmuhs/ccache-action@ca3acd2731eef11f1572ccb126356c2f9298d35e
with:
key: ${{ runner.os }}-clangreleaseasserts-${{ steps.get-submodule-hash.outputs.hash }}
max-size: 1G
- name: Get LLVM
id: clone-llvm
run: utils/clone-llvm.sh
- name: Rebuild and Install LLVM
run: utils/build-llvm.sh
# 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
cd build
cmake .. \
-GNinja \
-DCMAKE_BUILD_TYPE=Debug \
-DAIE_COMPILER=NONE \
-DAIE_LINKER=NONE \
-DHOST_COMPILER=NONE \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCMAKE_MODULE_PATH=`pwd`/../cmake/modulesXilinx \
-DMLIR_DIR=../llvm/install/lib/cmake/mlir \
-DLLVM_DIR=../llvm/install/lib/cmake/llvm \
-DCMAKE_LINKER=lld \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_COMPILE_WARNING_AS_ERROR=ON \
-DLLVM_EXTERNAL_LIT=`pwd`/../llvm/build/bin/llvm-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
cd build
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DAIE_COMPILER=NONE \
-DAIE_LINKER=NONE \
-DHOST_COMPILER=NONE \
-DLLVM_ENABLE_ASSERTIONS=OFF \
-DCMAKE_MODULE_PATH=`pwd`/../cmake/modulesXilinx \
-DMLIR_DIR=../llvm/install/lib/cmake/mlir \
-DLLVM_DIR=../llvm/install/lib/cmake/llvm \
-DCMAKE_LINKER=lld \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_COMPILE_WARNING_AS_ERROR=ON \
-DLLVM_EXTERNAL_LIT=`pwd`/../llvm/build/bin/llvm-lit \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
make -j$(nproc)
make check-aie
make check-tutorials
make check-reference-designs
- uses: cpp-linter/cpp-linter-action@v2
id: linter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
style: file
database: build
- name: Check for cpp-linter fails
if: steps.linter.outputs.checks-failed > 0
run: exit 1
format-python:
name: Check Python code format
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v3
- uses: reviewdog/action-black@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-check
level: error
filter_mode: file
verbose: true
fail_on_error: true