-
Notifications
You must be signed in to change notification settings - Fork 148
296 lines (258 loc) · 12 KB
/
Copy pathcoverage.yml
File metadata and controls
296 lines (258 loc) · 12 KB
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
name: NEURON Code Coverage
concurrency:
# Don't cancel on master, creating a PR when a push workflow is already going will cancel the push workflow in favour of the PR workflow
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/master' && github.run_id || github.event.number && github.head_ref || github.ref_name }}
cancel-in-progress: true
on:
merge_group:
push:
branches:
- master
- release/**
pull_request:
branches:
- master
- release/**
# TODO : https://github.com/neuronsimulator/nrn/issues/1063
# paths-ignore:
# - '**.md'
# - '**.rst'
# - 'docs/**'
env:
PY_MIN_VERSION: '3.10'
PY_MID_VERSION: '3.11'
PY_MAX_VERSION: '3.14'
# The Linux runners have 4 cores:
# https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
CMAKE_BUILD_PARALLEL_LEVEL: '4'
CTEST_PARALLEL_LEVEL: '4'
CCACHE_DIR: ${{ github.workspace }}/ccache
jobs:
coverage:
runs-on: ubuntu-22.04
name: Code Coverage
timeout-minutes: 60
env:
DISPLAY: ${{ ':0' }}
MUSIC_INSTALL_DIR: /opt/MUSIC
# hash of commit containing mpi4py 4 fix
MUSIC_VERSION: '13f312338dcccebfe74d391b1b24f1b6d816ac6c'
steps:
- name: Install apt packages
run: |
sudo apt-get update
sudo apt-get install -y xfonts-100dpi build-essential doxygen lcov libboost-all-dev libopenmpi-dev libmpich-dev libx11-dev libxcomposite-dev mpich openmpi-bin gpg ninja-build flex bison libfl-dev libdw-dev binutils-dev
shell: bash
env:
DEBIAN_FRONTEND: noninteractive
- name: Install a new ccache
run: |
# versions older than 4.10 do not support -fprofile-update=atomic
wget 'https://github.com/ccache/ccache/releases/download/v4.11.3/ccache-4.11.3-linux-x86_64.tar.xz'
tar xf ccache-4.11.3-linux-x86_64.tar.xz
sudo cp -a ccache-4.11.3-linux-x86_64/ccache /usr/bin/ccache
working-directory: ${{runner.temp}}
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version : '3.19'
- name: Setup Caliper profiler
run: |
git clone --branch v2.12.1 --depth 1 --recurse-submodules --shallow-submodules https://github.com/LLNL/Caliper.git
cd Caliper
cmake -B build -G Ninja .
sudo cmake --build build --target install
working-directory: ${{runner.temp}}
- name: Setup Xvfb
run: |
sudo apt-get install xvfb
sudo /usr/bin/Xvfb $DISPLAY -screen 0 1600x1200x24 -noreset -nolock -shmem & # run in bg
- uses: actions/checkout@v4
with:
fetch-depth: 2
# Restore (and later save) dependencies for min version of Python
- name: Restore Python@${{ env.PY_MIN_VERSION }} dependencies
id: cache-python-min-packages-restore
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/pip_cache${{ env.PY_MIN_VERSION }}
key: cache-${{ env.PY_MIN_VERSION }}-${{ hashFiles('ci/requirements.txt') }}
- name: Set up Python@${{ env.PY_MIN_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PY_MIN_VERSION }}
- name: Install Python@${{ env.PY_MIN_VERSION }} dependencies
working-directory: ${{runner.workspace}}/nrn
run: |
python -m pip install -r ci/uv_requirements.txt
python -m uv pip install -r ci/requirements.txt --cache-dir ${{ github.workspace }}/pip_cache${{ env.PY_MIN_VERSION }}
- name: Save Python@${{ env.PY_MIN_VERSION }} dependencies
id: cache-python-min-packages-save
if: always() && steps.cache-python-min-packages-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ steps.cache-python-min-packages-restore.outputs.cache-primary-key }}
path: ${{ github.workspace }}/pip_cache${{ env.PY_MIN_VERSION }}
# Restore (and later save) dependencies for mid version of Python
- name: Restore Python@${{ env.PY_MID_VERSION }} dependencies
id: cache-python-mid-packages-restore
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/pip_cache${{ env.PY_MID_VERSION }}
key: cache-${{ env.PY_MID_VERSION }}-${{ hashFiles('ci/requirements.txt') }}
- name: Set up Python@${{ env.PY_MID_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PY_MID_VERSION }}
- name: Install Python@${{ env.PY_MID_VERSION }} dependencies
working-directory: ${{runner.workspace}}/nrn
run: |
python -m pip install -r ci/uv_requirements.txt
python -m uv pip install -r ci/requirements.txt --cache-dir ${{ github.workspace }}/pip_cache${{ env.PY_MID_VERSION }}
- name: Save Python@${{ env.PY_MID_VERSION }} dependencies
id: cache-python-mid-packages-save
if: always() && steps.cache-python-mid-packages-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ steps.cache-python-mid-packages-restore.outputs.cache-primary-key }}
path: ${{ github.workspace }}/pip_cache${{ env.PY_MID_VERSION }}
# Restore (and later save) dependencies for max version of Python
- name: Restore Python@${{ env.PY_MAX_VERSION }} dependencies
id: cache-python-max-packages-restore
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/pip_cache${{ env.PY_MAX_VERSION }}
key: cache-${{ env.PY_MAX_VERSION }}-${{ hashFiles('ci/requirements.txt') }}
- name: Set up Python@${{ env.PY_MAX_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PY_MAX_VERSION }}
- name: Install Python@${{ env.PY_MAX_VERSION }} dependencies
working-directory: ${{runner.workspace}}/nrn
run: |
python -m pip install -r ci/uv_requirements.txt
python -m uv pip install -r ci/requirements.txt --cache-dir ${{ github.workspace }}/pip_cache${{ env.PY_MAX_VERSION }}
- name: Save Python@${{ env.PY_MAX_VERSION }} dependencies
id: cache-python-max-packages-save
if: always() && steps.cache-python-max-packages-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ steps.cache-python-max-packages-restore.outputs.cache-primary-key }}
path: ${{ github.workspace }}/pip_cache${{ env.PY_MAX_VERSION }}
- name: Setup MUSIC@${{ env.MUSIC_VERSION }}
run: |
python -m venv music-venv
source music-venv/bin/activate
python -m pip install -r ${{ github.workspace }}/ci/uv_requirements.txt
python -m uv pip install -r ${{ github.workspace }}/ci/requirements.txt --cache-dir ${{ github.workspace }}/pip_cache${{ env.PY_MAX_VERSION }}
sudo mkdir -p $MUSIC_INSTALL_DIR
sudo chown -R $USER $MUSIC_INSTALL_DIR
curl -L -o MUSIC.zip https://github.com/INCF/MUSIC/archive/${MUSIC_VERSION}.zip
unzip MUSIC.zip && mv MUSIC-* MUSIC && cd MUSIC
./autogen.sh
./configure --with-python-sys-prefix --prefix=$MUSIC_INSTALL_DIR --disable-anysource
make -j install
deactivate
working-directory: ${{runner.temp}}
# Restore (and later save) ccache
- name: Restore compiler cache
id: restore-compiler-cache
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/ccache
key: ccache-coverage-${{runner.os}}-${{github.ref_name}}
restore-keys: |
ccache-coverage-${{runner.os}}-master
- name: Build & Test
id: build-test
shell: bash
working-directory: ${{runner.workspace}}/nrn
run: |
export SHELL="/bin/bash"
# Compiler setup
export CC=gcc
export CXX=g++
# Python setup
export PYTHON_MIN=$(which $PYTHON_MIN_NAME);
export PYTHON_MID=$(which $PYTHON_MID_NAME);
export PYTHON_MAX=$(which $PYTHON_MAX_NAME);
# Update all submodules with depth 1
git submodule update --init --recursive --depth 1
mkdir build && cd build;
# CMake options & flags
cmake_args=(-G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_COMPILER="$CC" \
-DCMAKE_CXX_COMPILER="$CXX" \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DNRN_ENABLE_BACKTRACE=ON \
-DNRN_ENABLE_CORENEURON=ON \
-DNRN_ENABLE_COVERAGE=ON \
-DNRN_ENABLE_INTERVIEWS=ON \
-DNRN_ENABLE_MPI=ON \
-DNRN_ENABLE_PERFORMANCE_TESTS=OFF \
-DNRN_ENABLE_PROFILING=ON \
-DNRN_ENABLE_PYTHON=ON \
-DNRN_ENABLE_PYTHON_DYNAMIC=ON \
-DNRN_PYTHON_DYNAMIC="${PYTHON_MIN};${PYTHON_MAX}" \
-DNRN_PYTHON_EXTRA_FOR_TESTS=${PYTHON_MID} \
-DNRN_ENABLE_TESTS=ON \
-DNRN_ENABLE_MUSIC=ON \
-DCMAKE_PREFIX_PATH="${MUSIC_INSTALL_DIR}" \
-DMUSIC_ROOT="${MUSIC_INSTALL_DIR}")
cmake .. "${cmake_args[@]}"
# Coverage
ccache -z
ccache -s -v || ccache -s
cmake --build .
ccache -s -v || ccache -s
cmake --build . --target cover_baseline
xvfb-run ctest --rerun-failed --output-on-failure
for python in "${PYTHON_MIN}" "${PYTHON_MAX}"
do
echo "Using ${python}"
NEURONHOME="${PWD}/share/nrn" \
PYTHONPATH="${PWD}/lib/python:${PYTHONPATH}" \
PATH="${PWD}/bin:${PATH}" \
LD_LIBRARY_PATH="${PWD}/lib:${LD_LIBRARY_PATH}" \
DYLD_LIBRARY_PATH="${PWD}/lib:${DYLD_LIBRARY_PATH}" \
"${python}" -c "from neuron import h; import neuron; neuron.test();neuron.test_rxd(); from neuron.tests import test_nmodl; test_nmodl.test_nmodl()"
done
cmake --build . --target cover_collect
cmake --build . --target cover_combine
env:
MATRIX_EVAL: "CC=gcc CXX=g++"
PYTHON_MIN_NAME: "python${{ env.PY_MIN_VERSION }}"
PYTHON_MID_NAME: "python${{ env.PY_MID_VERSION }}"
PYTHON_MAX_NAME: "python${{ env.PY_MAX_VERSION }}"
- name: Upload build artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-${{runner.os}}
path: |
${{runner.workspace}}/nrn/build/CMakeCache.txt
${{runner.workspace}}/nrn/build/build.ninja
${{runner.workspace}}/nrn/build/cmake_install.cmake
- name: Save compiler cache
id: save-compiler-cache
if: always() && steps.restore-compiler-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ steps.restore-compiler-cache.outputs.cache-primary-key }}
path: ${{ github.workspace }}/ccache
# This step will set up an SSH connection on tmate.io for live debugging.
# To enable it, you have to:
# * add 'live-debug-coverage' to your PR title
# * push something to your PR branch (note that just re-running the pipeline disregards the title update)
- name: live debug session on failure (manual steps required, check `.github/coverage.yml`)
if: failure() && contains(github.event.pull_request.title, 'live-debug-coverage')
uses: mxschmitt/action-tmate@v3
- uses: codecov/codecov-action@v4
with:
directory: ./build
fail_ci_if_error: true
verbose: true
# token: ${{ contains(github.head_ref, 'dependabot/') && secrets.CODECOV_TOKEN || '' }}
token: ${{ secrets.CODECOV_TOKEN }}