-
Notifications
You must be signed in to change notification settings - Fork 15
185 lines (168 loc) · 6.38 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
name: NMODL CI
concurrency:
group: ${{ github.workflow }}#${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- master
- release/**
pull_request:
branches:
- master
- release/**
env:
CTEST_PARALLEL_LEVEL: 1
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
os: ubuntu-22.04
- config:
os: macos-11
# 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:
flag_warnings: ON
os: ubuntu-22.04
sanitizer: undefined
fail-fast: true
steps:
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v1
with:
cmake-version: ${{ env.DESIRED_CMAKE_VERSION }}
- name: Install homebrew packages
if: startsWith(matrix.config.os, 'macOS')
run: |
brew install ccache coreutils bison boost flex ninja
echo /usr/local/opt/flex/bin:/usr/local/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: Set up Python3
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: actions/checkout@v3
- 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: 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
shell: bash
working-directory: ${{runner.workspace}}/nmodl
run: |
echo "------- Configure -------"
mkdir build && pushd build
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.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++}
fi
cmake_args+=(-DCMAKE_CXX_COMPILER=${CXX} \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache)
cmake .. "${cmake_args[@]}"
env:
INSTALL_DIR: ${{ runner.workspace }}/install
- name: Dump config dictionary
run: |
cat << EOF > matrix.json
${{toJSON(matrix.config)}}
EOF
echo matrix.config JSON:
cat matrix.json
echo -----
- name: Restore compiler cache
uses: pat-s/always-upload-cache@v3
with:
path: |
${{runner.workspace}}/ccache
key: ${{hashfiles('matrix.json')}}-${{github.ref}}-${{github.sha}}
restore-keys: |
${{hashfiles('matrix.json')}}-${{github.ref}}-
${{hashfiles('matrix.json')}}-
- name: Build
shell: bash
working-directory: ${{runner.workspace}}/nmodl/build
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 .
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 -T Test
- name: Install
shell: bash
working-directory: ${{runner.workspace}}/nmodl/build
run: |
cmake --build . --target install
- uses: actions/upload-artifact@v3
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