-
Notifications
You must be signed in to change notification settings - Fork 15
314 lines (273 loc) · 10.6 KB
/
nmodl-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
311
312
313
name: NMODL CI
concurrency:
group: ${{ github.workflow }}#${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- master
- release/**
pull_request:
branches:
- master
- release/**
env:
PYTHON_VERSION: 3.8
DESIRED_CMAKE_VERSION: 3.15.0
jobs:
ci:
runs-on: ${{matrix.config.os}}
name: ${{toJson(matrix.config)}}
strategy:
matrix:
include:
- config:
os: ubuntu-20.04
- config:
flag_warnings: ON
glibc_asserts: ON
os: ubuntu-22.04
- config:
os: macos-13
- config:
os: macos-14
- config:
os: windows-latest
# TODO: might be interesting to add the thread sanitizer too
- config:
os: ubuntu-22.04
# Hyphens here will be replaced with commas before the value is
# passed to NMODL_SANITIZERS
sanitizer: address-leak
- config:
os: ubuntu-22.04
enable_usecases: On
update_references: On
- config:
flag_warnings: ON
os: ubuntu-22.04
sanitizer: undefined
fail-fast: true
steps:
- name: Fix kernel mmap rnd bits
# Asan in llvm 14 provided in ubuntu 22.04 is incompatible with
# high-entropy ASLR in much newer kernels that GitHub runners are
# using leading to random crashes: https://reviews.llvm.org/D148280
run: sudo sysctl vm.mmap_rnd_bits=28
if: matrix.config.os == 'ubuntu-22.04'
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: ${{ env.DESIRED_CMAKE_VERSION }}
- name: Install homebrew packages
if: startsWith(matrix.config.os, 'macOS')
run: |
brew install [email protected] || true
brew link --overwrite [email protected]
brew install ccache coreutils bison boost flex ninja
echo /usr/local/opt/flex/bin:/usr/local/opt/bison/bin:/opt/homebrew/opt/flex/bin:/opt/homebrew/opt/bison/bin >> $GITHUB_PATH
# Taken from https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
echo CMAKE_BUILD_PARALLEL_LEVEL=3 >> $GITHUB_ENV
shell: bash
- name: Install apt packages
if: startsWith(matrix.config.os, 'ubuntu')
run: |
sudo apt-get install bison ccache flex libfl-dev ninja-build python3-dev python3-pip
# Taken from https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
echo CMAKE_BUILD_PARALLEL_LEVEL=2 >> $GITHUB_ENV
shell: bash
- name: Install choco packages
if: startsWith(matrix.config.os, 'windows')
run: |
choco install winflexbison3
- name: Configure VS Toolchain (Windows)
if: startsWith(matrix.config.os, 'windows')
uses: ilammy/msvc-dev-cmd@v1
- name: Set up Python3
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: actions/checkout@v4
- name: Install Python3 dependencies
working-directory: ${{runner.workspace}}/nmodl
run: |
python3 -m pip install -U pip setuptools
python3 -m pip install --user -r requirements.txt
- name: Install neuron-nightly
if: ${{matrix.config.enable_usecases == 'On'}}
run: |
python3 -m pip install neuron-nightly
- name: Register compiler warning problem matcher
if: ${{matrix.config.flag_warnings == 'ON'}}
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
- name: Register sanitizer problem matcher
if: ${{matrix.config.sanitizer}}
run: echo "::add-matcher::.github/problem-matchers/${{matrix.config.sanitizer}}.json"
- name: Configure Windows
if: startsWith(matrix.config.os, 'windows')
run: |
cmake -S . -B build -DFLEX_INCLUDE_PATH=C:/ProgramData/chocolatey/lib/winflexbison3/tools -DBUILD_SHARED_LIBS=OFF
- name: Configure Linux/MacOS
if: ${{ !startsWith(matrix.config.os, 'windows') }}
shell: bash
working-directory: ${{runner.workspace}}/nmodl
run: |
echo "------- Configure -------"
cmake_args=(-G Ninja
-DPYTHON_EXECUTABLE=$(which python3) \
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR)
if [[ -n "${{matrix.config.flag_warnings}}" ]]; then
cmake_args+=(-DNMODL_EXTRA_CXX_FLAGS="-Wall \
-Wno-reorder \
-Wno-unknown-pragmas \
-Wno-sign-compare \
-Wno-overloaded-virtual")
fi
if [[ -n "${{matrix.config.enable_usecases}}" ]]; then
cmake_args+=(-DNMODL_ENABLE_USECASES=${{matrix.config.enable_usecases}})
fi
if [[ -n "${{matrix.config.sanitizer}}" ]]; then
cmake_args+=(-DCMAKE_BUILD_TYPE=Custom \
-DCMAKE_CXX_FLAGS="-O1 -g" \
-DNMODL_SANITIZERS=$(echo ${{matrix.config.sanitizer}} | sed -e 's/-/,/g'))
CXX=$(command -v clang++-14)
else
CXX=${CXX:-g++}
if [[ -n "${{matrix.config.glibc_asserts}}" ]]; then
cmake_args+=(-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS=-D_GLIBCXX_DEBUG)
fi
fi
cmake_args+=(-DCMAKE_CXX_COMPILER=${CXX} \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache)
cmake_args+=(-DNMODL_ENABLE_BACKWARD=On)
cmake -B build -S . "${cmake_args[@]}"
env:
INSTALL_DIR: ${{ runner.workspace }}/install
- name: Dump config dictionary
if: ${{ !startsWith(matrix.config.os, 'windows') }}
run: |
cat << EOF > matrix.json
${{toJSON(matrix.config)}}
EOF
echo matrix.config JSON:
cat matrix.json
echo -----
- name: Restore compiler cache
if: ${{ !startsWith(matrix.config.os, 'windows') }}
uses: actions/cache@v4
with:
path: |
${{runner.workspace}}/ccache
key: ${{hashfiles('matrix.json')}}-${{github.ref}}-${{github.sha}}
restore-keys: |
${{hashfiles('matrix.json')}}-${{github.ref}}-
${{hashfiles('matrix.json')}}-
save-always: true
- name: Build Windows
if: startsWith(matrix.config.os, 'windows')
run: |
cmake --build build --verbose
- name: Build Linux/MacOS
if: ${{ !startsWith(matrix.config.os, 'windows') }}
shell: bash
working-directory: ${{runner.workspace}}/nmodl
env:
CCACHE_BASEDIR: ${{runner.workspace}}/nmodl
CCACHE_DIR: ${{runner.workspace}}/ccache
PYTHONMALLOC: malloc
run: |
if ccache --version | grep -E '^ccache version 4\.(4|4\.1)$'
then
echo "------- Disable ccache direct mode -------"
# https://github.com/ccache/ccache/issues/935
export CCACHE_NODIRECT=1
fi
echo "------- Building -------"
ccache -z
# Older versions don't support -v (verbose)
ccache -vs 2>/dev/null || ccache -s
cmake --build build --verbose
ccache -vs 2>/dev/null || ccache -s
- name: Test
shell: bash
working-directory: ${{runner.workspace}}/nmodl/build
env:
PYTHONMALLOC: malloc
run: |
ctest --output-on-failure --parallel 4
- name: Install
shell: bash
working-directory: ${{runner.workspace}}/nmodl
run: |
cmake --install build
- name: Update references
if: matrix.config.update_references == 'On'
shell: bash
working-directory: ${{runner.workspace}}/nmodl/test/usecases
run : |
export PATH="${INSTALL_DIR}/bin:${PATH}"
export PYTHONPATH="${INSTALL_DIR}/lib:${PYTHONPATH}"
for d in */
do
./generate_references.py nmodl "$d" "$OUTPUT_DIR/$d"
done
cd $OUTPUT_DIR
tar cf ../references.tar *
env:
INSTALL_DIR: ${{ runner.workspace }}/install
OUTPUT_DIR: ${{ runner.workspace }}/references
- uses: actions/upload-artifact@v4
if: matrix.config.update_references == 'On'
with:
name: references
path: ${{runner.workspace}}/references.tar
- uses: actions/upload-artifact@v4
with:
name: ctest-results-${{hashfiles('matrix.json')}}
path: ${{runner.workspace}}/nmodl/build/Testing/*/Test.xml
# This step will set up an SSH connection on tmate.io for live debugging.
# To enable it, you have to:
# * add 'live-debug-tests' to your PR title
# * push something to your PR branch (note that just re-running disregards the title update)
- name: live debug session on failure (manual steps required, check `nmodl-ci.yml`)
if: failure() && contains(github.event.pull_request.title, 'live-debug-tests')
uses: mxschmitt/action-tmate@v3
timeout-minutes: 60
commit-references:
runs-on: ubuntu-latest
needs: ci
steps:
- uses: actions/download-artifact@v4
with:
name: references
path: ${{runner.workspace}}/
- name: Check out nmodl-references
uses: actions/checkout@v4
with:
repository: BlueBrain/nmodl-references
token: ${{ secrets.NMODL_REFERENCES_ACCESS_TOKEN }}
- name: Update references
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<>"
# If not a PR, then `pr_number` is the branch name.
if [[ ${{ github.event_name }} == "pull_request" ]]
then
pr_number="$(echo ${GITHUB_REF_NAME} | sed "s/^\([0-9]*\)\/merge/\1/")"
nmodl_desc=https://github.com/BlueBrain/nmodl/pull/${pr_number}
branch="nmodl-${pr_number}"
else
nmodl_desc="nmodl@${GITHUB_SHA}"
branch="main"
fi
git fetch
git checkout ${branch} 2>/dev/null || git checkout -b ${branch}
for d in */
do
rm -rf "$d"
done
tar xf ${{ runner.workspace }}/references.tar
git add .
git commit --allow-empty -m "References for '${nmodl_desc}'."
git push 2>/dev/null || git push --set-upstream origin ${branch}