forked from wlav/CPyCppyy
-
Notifications
You must be signed in to change notification settings - Fork 5
310 lines (303 loc) · 12.7 KB
/
ci.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
name: Main
on:
pull_request:
branches: [master]
push:
branches: [master]
release:
types: [published]
schedule:
- cron: '30 20 * * *' # Warning: Timezone dep - 20:00 is 1:00
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
build:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: ubu22-gcc9-clang13
os: ubuntu-22.04
compiler: gcc-9
clang-runtime: '13'
cling: On
# - name: ubu22-gcc9-clang14
# os: ubuntu-22.04
# compiler: gcc-9
# clang-runtime: '14'
- name: ubu22-gcc9-clang16
os: ubuntu-22.04
compiler: gcc-9
clang-runtime: '16'
cling: Off
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Save PR Info
run: |
mkdir -p ./pr
echo ${{ github.event.number }} > ./pr/NR
echo ${{ github.repository }} > ./pr/REPO
cling_on="${{ matrix.cling }}"
if [[ "${cling_on^^}" == "ON" ]]; then
export CLING_HASH=$(git ls-remote https://github.com/root-project/cling.git HEAD| tr '\t' '-')
else
export CLING_HASH="Repl"
fi
# FIXME: We need something like cling-llvm to bump automatically...
export LLVM_HASH=$(git ls-remote https://github.com/root-project/llvm-project.git cling-llvm${{ matrix.clang-runtime}} | tr '\t' '-')
#patch in LLVM_HASH
echo "CLING_HASH=$CLING_HASH" >> $GITHUB_ENV
echo "LLVM_HASH=$LLVM_HASH" >> $GITHUB_ENV
- uses: nelonoel/[email protected]
- name: Setup compiler on Linux
if: runner.os == 'Linux'
run: |
# https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html
vers="${compiler#*-}"
os_codename="`cat /etc/os-release | grep UBUNTU_CODENAME | cut -d = -f 2`"
###sudo apt update
if [[ "${{ matrix.compiler }}" == *"gcc"* ]]; then
sudo apt install -y gcc-${vers} g++-${vers} lld
echo "CC=gcc-${vers}" >> $GITHUB_ENV
echo "CXX=g++-${vers}" >> $GITHUB_ENV
else
if ! sudo apt install -y clang-${vers}; then
curl https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
echo "deb https://apt.llvm.org/${os_codename}/ llvm-toolchain-${os_codename}-${vers} main" | sudo tee -a /etc/apt/sources.list
sudo apt update
sudo apt install -y clang-${vers}
fi
echo "CC=clang-${vers}" >> $GITHUB_ENV
echo "CXX=clang++-${vers}" >> $GITHUB_ENV
fi
env:
compiler: ${{ matrix.compiler }}
- name: Install deps on Linux
if: runner.os == 'Linux'
run: |
# Install deps
###sudo apt update
sudo apt install git g++ debhelper devscripts gnupg python3 valgrind
conda install -y -q -c conda-forge \
distro \
pytest
- name: Restore Cache LLVM/Clang runtime build directory
uses: actions/cache/restore@v3
id: cache
with:
path: |
llvm-project
${{ matrix.cling=='On' && 'cling' || '' }}
#key: ...-.x-patch-${{ hashFiles('patches/llvm/*') }}
#key: ${{ env.CLING_HASH }}-${{ env.LLVM_HASH }}-${{ runner.os }}-${{ matrix.os }}-${{ matrix.compiler }}-clang-${{ matrix.clang-runtime }}.x
key: ${{ env.CLING_HASH }}-${{ runner.os }}-${{ matrix.os }}-${{ matrix.compiler }}-clang-${{ matrix.clang-runtime }}.x-patch-${{ hashFiles(format('patches/llvm/clang{0}-*.patch', matrix.clang-runtime)) || 'none' }}
- name: Build LLVM/Cling on Linux if the cache is invalid
if: ${{ runner.os == 'Linux' && steps.cache.outputs.cache-hit != 'true' }}
run: |
cling_on="${{ matrix.cling }}"
if [[ "${cling_on^^}" == "ON" ]]; then
git clone --depth=1 https://github.com/root-project/cling.git
git clone --depth=1 -b cling-llvm${{ matrix.clang-runtime }} https://github.com/root-project/llvm-project.git
else # repl
git clone --depth=1 -b release/${{ matrix.clang-runtime }}.x https://github.com/llvm/llvm-project.git
fi
cd llvm-project
# Apply patches
echo "Apply clang${{ matrix.clang-runtime }}-*.patch patches:"
compgen -G "../patches/llvm/clang${{ matrix.clang-runtime }}-*.patch" > /dev/null && find ../patches/llvm/clang${{ matrix.clang-runtime }}-*.patch -printf "%f\n" && git apply ../patches/llvm/clang${{ matrix.clang-runtime }}-*.patch
# Build
mkdir build
cd build
if [[ "${cling_on^^}" == "ON" ]]; then
cmake -DLLVM_ENABLE_PROJECTS=clang \
-DLLVM_EXTERNAL_PROJECTS=cling \
-DLLVM_EXTERNAL_CLING_SOURCE_DIR=../../cling \
-DLLVM_TARGETS_TO_BUILD="host;NVPTX" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_USE_LINKER=lld \
-DCLANG_ENABLE_STATIC_ANALYZER=OFF \
-DCLANG_ENABLE_ARCMT=OFF \
-DCLANG_ENABLE_FORMAT=OFF \
-DCLANG_ENABLE_BOOTSTRAP=OFF \
../llvm
cmake --build . --target clang --parallel $(nproc --all)
cmake --build . --target cling --parallel $(nproc --all)
# Now build gtest.a and gtest_main for InterOp to run its tests.
cmake --build . --target gtest_main --parallel $(nproc --all)
else
cmake -DLLVM_ENABLE_PROJECTS=clang \
-DLLVM_TARGETS_TO_BUILD="host;NVPTX" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_USE_LINKER=lld \
-DCLANG_ENABLE_STATIC_ANALYZER=OFF \
-DCLANG_ENABLE_ARCMT=OFF \
-DCLANG_ENABLE_FORMAT=OFF \
-DCLANG_ENABLE_BOOTSTRAP=OFF \
../llvm
cmake --build . --target clang clang-repl --parallel $(nproc --all)
fi
cd ../../
- name: Save Cache LLVM/Clang runtime build directory
uses: actions/cache/save@v3
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
with:
path: |
llvm-project
${{ matrix.cling=='On' && 'cling' || '' }}
key: ${{ steps.cache.outputs.cache-primary-key }}
- name: Build and Install InterOp on Linux
if: runner.os == 'Linux'
run: |
# Build InterOp next to cling and llvm-project.
LLVM_DIR="$(realpath llvm-project)"
LLVM_BUILD_DIR="$(realpath llvm-project/build)"
cling_on="${{ matrix.cling }}"
if [[ "${cling_on^^}" == "ON" ]]; then
CLING_DIR="$(realpath cling)"
CLING_BUILD_DIR="$(realpath cling/build)"
CPLUS_INCLUDE_PATH="${CLING_DIR}/tools/cling/include:${CLING_BUILD_DIR}/include:${LLVM_DIR}/llvm/include:${LLVM_DIR}/clang/include:${LLVM_BUILD_DIR}/include:${LLVM_BUILD_DIR}/tools/clang/include"
else # repl
CPLUS_INCLUDE_PATH="${LLVM_DIR}/llvm/include:${LLVM_DIR}/clang/include:${LLVM_BUILD_DIR}/include:${LLVM_BUILD_DIR}/tools/clang/include"
fi
git clone https://github.com/compiler-research/InterOp.git
export INTEROP_DIR=$PWD/cppyy-backend/python/cppyy_backend/
cd InterOp
mkdir build
cd build
export INTEROP_BUILD_DIR=$PWD
cling_on="${{ matrix.cling }}"
if [[ "${cling_on^^}" == "ON" ]]; then
cmake -DCMAKE_BUILD_TYPE=Release \
-DUSE_CLING=ON \
-DUSE_REPL=OFF \
-DCling_DIR=$LLVM_BUILD_DIR \
-DLLVM_DIR=$LLVM_BUILD_DIR \
-DLLVM_USE_LINKER=lld \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_PREFIX=$INTEROP_DIR \
../
else
cmake -DCMAKE_BUILD_TYPE=Release \
-DUSE_CLING=OFF \
-DUSE_REPL=ON \
-DLLVM_DIR=$LLVM_BUILD_DIR \
-DLLVM_USE_LINKER=lld \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_PREFIX=$INTEROP_DIR \
../
fi
cmake --build . --parallel $(nproc --all)
cd ../..
# We need INTEROP_DIR, LLVM_BUILD_DIR and CPLUS_INCLUDE_PATH later
echo "INTEROP_DIR=$INTEROP_DIR" >> $GITHUB_ENV
echo "INTEROP_BUILD_DIR=$INTEROP_BUILD_DIR" >> $GITHUB_ENV
echo "LLVM_BUILD_DIR=$LLVM_BUILD_DIR" >> $GITHUB_ENV
echo "CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH" >> $GITHUB_ENV
- name: Build and Install cppyy-backend on Linux
if: runner.os == 'Linux'
run: |
# Install cppyy-backend
git clone https://github.com/compiler-research/cppyy-backend.git
cd cppyy-backend
mkdir -p python/cppyy_backend/lib build && cd build
(cd $INTEROP_BUILD_DIR && cmake --build . --target install --parallel $(nproc --all))
cmake -DInterOp_DIR=$INTEROP_DIR ..
cmake --build . --parallel $(nproc --all)
cp libcppyy-backend.so ../python/cppyy_backend/lib/
#
cd ../python
export CB_PYTHON_DIR=$PWD
cd ../..
# We need CB_PYTHON_DIR later
echo "CB_PYTHON_DIR=$CB_PYTHON_DIR" >> $GITHUB_ENV
- name: Install CPyCppyy on Linux
if: runner.os == 'Linux'
run: |
# Setup virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Install CPyCppyy
mkdir build && cd build
cmake ..
cmake --build . --parallel $(nproc --all)
#
export CPYCPPYY_DIR=$PWD
cd ../..
# We need CPYCPPYY_DIR later
echo "CPYCPPYY_DIR=$CPYCPPYY_DIR" >> $GITHUB_ENV
- name: Install cppyy on Linux
if: runner.os == 'Linux'
run: |
# source virtual environment
source .venv/bin/activate
# Install cppyy
git clone https://github.com/compiler-research/cppyy.git
cd cppyy
python -m pip install --upgrade . --no-deps
cd ..
- name: Run cppyy on Linux
if: runner.os == 'Linux'
run: |
# Run cppyy
source .venv/bin/activate
export PYTHONPATH=$PYTHONPATH:$CPYCPPYY_DIR:$CB_PYTHON_DIR
python -c "import cppyy"
# We need PYTHONPATH later
echo "PYTHONPATH=$PYTHONPATH" >> $GITHUB_ENV
- name: Run the tests on Linux
if: runner.os == 'Linux'
run: |
# Run the tests
source .venv/bin/activate
cd cppyy/test
echo ::group::Prepare For Testing
make all
python -m pip install --upgrade pip
python -m pip install pytest
python -m pip install pytest-xdist
echo ::endgroup::
echo ::group::Crashing Test Logs
# See if we don't have a crash that went away
# Comment out all xfails but the ones that have a run=False condition.
find . -name "*.py" -exec sed -i '/run=False/!s/^ *@mark.xfail\(.*\)/#&/' {} \;
python -m pytest -n 1 -m "xfail" --runxfail -sv --max-worker-restart 512 | tee test_crashed.log 2>&1
git checkout .
echo ::endgroup::
echo ::group::XFAIL Test Logs
# Rewrite all xfails that have a run clause to skipif. This way we will
# avoid conditionally crashing xfails
find . -name "*.py" -exec sed -i -E 's/(^ *)@mark.xfail\(run=(.*)/\[email protected](condition=not \2/g' {} \;
# See if we don't have an xfail that went away
python -m pytest --runxfail -sv | tee test_xfailed.log 2>&1
git checkout .
echo ::endgroup::
echo ::group::Passing Test Logs
# Run the rest of the non-crashing tests.
declare -i RETCODE=0
set -o pipefail
valgrind --error-exitcode=1 --suppressions=../etc/valgrind-cppyy-cling.supp python -m pytest -m "not xfail" -v
export RETCODE=+$?
echo ::endgroup::
RETCODE=+$?
echo "Crashing Summary: \n"
tail -n1 test_crashed.log
echo "XFAIL Summary:"
tail -n1 test_xfailed.log
echo "Return Code: ${RETCODE}"
exit $RETCODE
- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
# When debugging increase to a suitable value!
timeout-minutes: ${{ github.event.pull_request && 1 || 20 }}