-
Notifications
You must be signed in to change notification settings - Fork 31
358 lines (289 loc) · 10.5 KB
/
test_python_cplusplus.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
name: C++/Python Tests
on:
push:
merge_group:
workflow_dispatch:
pull_request:
branches:
- master
- develop
jobs:
ubuntu-cpp-python-tests:
name: C++/Python tests Ubuntu
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: [ "3.11" ]
steps:
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cache/pooch
key: ${{ runner.os }}-py${{ matrix.python-version }}-${{ github.job }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v4
- run: git fetch --prune --unshallow
- run: echo "AMICI_DIR=$(pwd)" >> $GITHUB_ENV
- name: Set up AMICI C++ libraries
uses: ./.github/actions/setup-amici-cpp
- name: Install libsuitesparse-dev
# We don't need libsuitesparse-dev, but let's have it installed,
# to ensure that its presence does not break the build
run: sudo apt-get install -y libsuitesparse-dev
- name: C++ tests
run: scripts/run-cpp-tests.sh
- name: Install python package
run: scripts/installAmiciSource.sh
- name: Check OpenMP support
run: source venv/bin/activate && python -c "import amici; import sys; sys.exit(not amici.compiledWithOpenMP())"
- name: Python tests (part 1)
run: |
source venv/bin/activate \
&& pytest \
--ignore-glob=*petab* \
--ignore-glob=*test_splines.py \
--ignore-glob=*test_splines_short.py \
--ignore-glob=*test_pysb.py \
--cov=amici \
--cov-report=xml:"${AMICI_DIR}/build/coverage_py.xml" \
--cov-append \
--durations=10 \
${AMICI_DIR}/python/tests
- name: Python tests splines
if: ${{ github.base_ref == 'master' || github.event.merge_group.base_ref == 'master'}}
run: |
source venv/bin/activate \
&& pytest \
--cov=amici \
--cov-report=xml:"${AMICI_DIR}/build/coverage_py.xml" \
--cov-append \
--durations=10 \
${AMICI_DIR}/python/tests/test_splines.py
- name: Codecov Python
if: github.event_name == 'pull_request' || github.repository_owner == 'AMICI-dev'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: build/coverage_py.xml
flags: python
fail_ci_if_error: true
verbose: true
- name: Capture coverage info (lcov)
run: |
lcov --compat-libtool --no-external \
-d ${AMICI_DIR}/build/CMakeFiles/amici.dir/src \
-b ${AMICI_DIR} -c -o coverage_cpp.info \
&& lcov --compat-libtool --no-external \
-d ${AMICI_DIR}/python/sdist/build/temp_amici/CMakeFiles/amici.dir/src \
-b ${AMICI_DIR}/python/sdist -c -o coverage_py.info \
&& lcov -a coverage_cpp.info -a coverage_py.info -o coverage.info
- name: Codecov CPP
if: github.event_name == 'pull_request' || github.repository_owner == 'AMICI-dev'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: coverage.info
flags: cpp
fail_ci_if_error: true
- name: Run sonar-scanner
if: ${{ env.SONAR_TOKEN != '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner \
-Dsonar.cfamily.build-wrapper-output=bw-output \
-Dsonar.projectVersion="$(git describe --abbrev=4 --dirty=-dirty --always --tags | tr -d '\n')"
ubuntu-python-tests:
name: Python tests Ubuntu
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: [ "3.10" ]
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cache/pooch
key: ${{ runner.os }}-py${{ matrix.python-version }}-${{ github.job }}
- uses: actions/checkout@v4
- run: git fetch --prune --unshallow
- run: echo "AMICI_DIR=$(pwd)" >> $GITHUB_ENV
- name: Set up AMICI C++ libraries
uses: ./.github/actions/setup-amici-cpp
- name: Install python package
run: scripts/installAmiciSource.sh
- name: Python tests
run: |
source venv/bin/activate \
&& pytest \
--cov=amici \
--cov-report=xml:"${AMICI_DIR}/build/coverage_py.xml" \
--cov-append \
--durations=10 \
${AMICI_DIR}/python/tests/test_pysb.py \
${AMICI_DIR}/python/tests/test_splines_short.py
- name: Codecov Python
if: github.event_name == 'pull_request' || github.repository_owner == 'AMICI-dev'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: build/coverage_py.xml
flags: python
fail_ci_if_error: true
verbose: true
- name: Capture coverage info (lcov)
run: |
lcov --compat-libtool --no-external \
-d ${AMICI_DIR}/build/CMakeFiles/amici.dir/src \
-b ${AMICI_DIR} -c -o coverage_cpp.info \
&& lcov --compat-libtool --no-external \
-d ${AMICI_DIR}/python/sdist/build/temp_amici/CMakeFiles/amici.dir/src \
-b ${AMICI_DIR}/python/sdist -c -o coverage_py.info \
&& lcov -a coverage_cpp.info -a coverage_py.info -o coverage.info
- name: Codecov CPP
if: github.event_name == 'pull_request' || github.repository_owner == 'AMICI-dev'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: coverage.info
flags: cpp_python
fail_ci_if_error: true
- name: Run sonar-scanner
if: ${{ env.SONAR_TOKEN != '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner \
-Dsonar.cfamily.build-wrapper-output=bw-output \
-Dsonar.projectVersion="$(git describe --abbrev=4 --dirty=-dirty --always --tags | tr -d '\n')"
ubuntu-notebook-tests:
name: Notebook tests Ubuntu
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: [ "3.11" ]
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cache/pooch
key: ${{ runner.os }}-py${{ matrix.python-version }}-${{ github.job }}
- uses: actions/checkout@v4
- run: git fetch --prune --unshallow
- run: echo "AMICI_DIR=$(pwd)" >> $GITHUB_ENV
- name: Set up AMICI C++ libraries
uses: ./.github/actions/setup-amici-cpp
- name: Install python package
run: scripts/installAmiciSource.sh
- name: example notebooks
run: scripts/runNotebook.sh python/examples/example_*/
- name: doc notebooks
run: scripts/runNotebook.sh documentation/GettingStarted.ipynb
# TODO: Include notebooks in coverage report
macos_cpp_py:
name: Tests MacOS C++/Python
runs-on: macos-latest
env:
PYTHONFAULTHANDLER: "1"
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- uses: actions/checkout@v4
- run: git fetch --prune --unshallow
- name: Install dependencies
uses: ./.github/actions/install-macos-dependencies
- name: homebrew
run: brew install cppcheck
- name: Build AMICI
run: scripts/buildAll.sh
- name: Install python package
run: scripts/installAmiciSource.sh
- name: Check OpenMP support
run: source venv/bin/activate && python -c "import amici; import sys; sys.exit(not amici.compiledWithOpenMP())"
- name: cppcheck
run: scripts/run-cppcheck.sh
- name: C++ tests
run: scripts/run-cpp-tests.sh
- name: Get Pooch Cache Directory
id: get-pooch-cache
run: |
echo "pooch-cache=$(source venv/bin/activate && python -c 'import pooch; print(pooch.os_cache("pooch"))')" >> $GITHUB_ENV
- name: Cache Pooch Directory
uses: actions/cache@v4
with:
path: ${{ env.pooch-cache }}
key: ${{ runner.os }}-py${{ matrix.python-version }}-${{ github.job }}
- name: Python tests
run: |
# ignore warnings until https://github.com/swig/swig/issues/3061 is resolved
scripts/run-python-tests.sh -W ignore:: \
test_pregenerated_models.py \
test_splines_short.py \
test_misc.py
macos_python:
name: Tests MacOS Python
runs-on: macos-latest
env:
PYTHONFAULTHANDLER: "1"
steps:
- name: Cache
uses: actions/cache@v4
with:
path: |
~/Library/Caches/pooch
key: ${{ runner.os }}-py${{ matrix.python-version }}-${{ github.job }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- uses: actions/checkout@v4
- run: git fetch --prune --unshallow
- name: Install dependencies
uses: ./.github/actions/install-macos-dependencies
- name: Install python package
run: |
pip show numpy > /dev/null || python3 -m pip install numpy
scripts/installAmiciSource.sh
- name: Check OpenMP support
run: source venv/bin/activate && python -c "import amici; import sys; sys.exit(not amici.compiledWithOpenMP())"
- name: Get BioNetGen
run: scripts/buildBNGL.sh
- name: Get Pooch Cache Directory
id: get-pooch-cache
run: |
echo "pooch-cache=$(source venv/bin/activate && python -c 'import pooch; print(pooch.os_cache("pooch"))')" >> $GITHUB_ENV
- name: Cache Pooch Directory
uses: actions/cache@v4
with:
path: ${{ env.pooch-cache }}
key: ${{ runner.os }}-py${{ matrix.python-version }}-${{ github.job }}
- name: Install PEtab benchmark collection
run: |
git clone --depth 1 https://github.com/benchmarking-initiative/Benchmark-Models-PEtab.git \
&& export BENCHMARK_COLLECTION="$(pwd)/Benchmark-Models-PEtab/Benchmark-Models/" \
&& source venv/bin/activate && python -m pip install -e $BENCHMARK_COLLECTION/../src/python
- name: Python tests
run: |
# ignore warnings until https://github.com/swig/swig/issues/3061 is resolved
scripts/run-python-tests.sh -W ignore:: \
--ignore=test_pregenerated_models.py \
--ignore=test_splines_short.py \
--ignore=test_misc.py