-
Notifications
You must be signed in to change notification settings - Fork 15
/
azure-pipelines.yml
317 lines (300 loc) · 11.5 KB
/
azure-pipelines.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
#=============================================================================
# Azure Pipeline NMODL settings
#=============================================================================
variables:
# defined in UI
#- ReleaseWheelBuild: False
#- UploadWheel: False
buildWheel: ${{ or(in(variables['Build.Reason'], 'Schedule'), in(variables['Build.Reason'], 'Manual')) }}
MACOSX_DEPLOYMENT_TARGET: 10.15
# Nightly build master for pypi upload
schedules:
- cron: "5 0 * * *"
branches:
include:
- master
always: True
# Auto cancel old PR builds
pr: none
# Trigger build for certain branches only
trigger:
- master
- llvm
- releases/*
stages:
- stage: fetch_config
jobs:
- job: github
pool:
vmImage: ubuntu-latest
steps:
- checkout: none
- script: |
if [[ -z ${SYSTEM_PULLREQUEST_PULLREQUESTNUMBER+x} ]]; then
echo "Not running on a PR."
exit 0
fi
cat > parse_description.py << END_SCRIPT
import os
import re
import requests
pr_info = requests.get("https://api.github.com/repos/{}/pulls/{}".format(
os.environ['BUILD_REPOSITORY_NAME'],
os.environ['SYSTEM_PULLREQUEST_PULLREQUESTNUMBER']),
headers={'Accept': 'application/vnd.github.v3+json'})
pr_body = pr_info.json()["body"]
# match something like NEURON_BRANCH=foo/bar
pat = re.compile('^([A-Z0-9_]+)_([A-Z]+)=([A-Z0-9\-\_\/\+]+)$', re.IGNORECASE)
def parse_term(m):
ref_type = m.group(2).lower()
if ref_type not in {'branch', 'tag', 'ref'}: return
variable = m.group(1).upper() + '_' + ref_type.upper()
value = m.group(3)
print('{}={}'.format(variable, value))
print('#{}[task.setvariable variable={};isOutput=true]{}'.format('#vso', variable, value))
if pr_body is not None:
for pr_body_line in pr_body.splitlines():
if not pr_body_line.startswith('CI_BRANCHES:'): continue
for config_term in pr_body_line[12:].split(','):
pat.sub(parse_term, config_term)
END_SCRIPT
echo '----'
cat parse_description.py
echo '----'
python parse_description.py
name: prdesc
- stage: build
dependsOn: fetch_config
variables:
NEURON_BRANCH: $[stageDependencies.fetch_config.github.outputs['prdesc.NEURON_BRANCH']]
jobs:
- job: 'ubuntu2004'
pool:
vmImage: 'ubuntu-20.04'
displayName: 'Ubuntu (20.04), GCC 9.4'
steps:
- checkout: self
submodules: False
- script: |
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-add-repository -y ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install -y g++-9 flex bison libfl-dev cython libx11-dev libxcomposite-dev libncurses-dev mpich
sudo apt-get install -y python3.9 python3.9-dev python3.9-venv ninja-build
sudo apt-get remove -y python3-importlib-metadata
python3.9 -m pip install --upgrade pip setuptools
python3.9 -m pip install --user -r requirements.txt
# we manually get version 3.15.0 to make sure that changes in the cmake
# files do not require unsupported versions of cmake in our package.
wget --quiet --output-document=- "https://github.com/Kitware/CMake/releases/download/$CMAKE_VER/$CMAKE_PKG.tar.gz" | tar xzpf -
env:
CMAKE_VER: 'v3.15.0'
CMAKE_PKG: 'cmake-3.15.0-Linux-x86_64'
displayName: 'Install Dependencies'
- script: |
export PATH=$(pwd)/$CMAKE_PKG/bin:/home/vsts/.local/bin:$PATH
export CXX='g++-9'
mkdir -p $(Build.Repository.LocalPath)/build
cd $(Build.Repository.LocalPath)/build
cmake --version
cmake .. -DPYTHON_EXECUTABLE=$(which python3.9) -DCMAKE_INSTALL_PREFIX=$HOME/nmodl -DCMAKE_BUILD_TYPE=Release
make -j 2
if [ $? -ne 0 ]
then
make VERBOSE=1
exit 1
fi
make install #this is needed for the integration tests
env CTEST_OUTPUT_ON_FAILURE=1 make test
env:
CMAKE_PKG: 'cmake-3.15.0-Linux-x86_64'
displayName: 'Build and Run Unit Tests'
- script: |
export PATH=$(pwd)/$CMAKE_PKG/bin:/home/vsts/.local/bin:$PATH
export CC='gcc-9'
export CXX='g++-9'
git clone${NEURON_BRANCH:+ --branch }${NEURON_BRANCH} --single-branch https://github.com/neuronsimulator/nrn.git
mkdir nrn/build
cd nrn/build
cmake --version
cmake .. -DNRN_ENABLE_CORENEURON=ON -DNRN_ENABLE_INTERVIEWS=OFF -DNRN_ENABLE_RX3D=OFF -DNRN_ENABLE_MPI=ON -DNRN_ENABLE_TESTS=ON -DCORENRN_ENABLE_NMODL=ON -DCORENRN_NMODL_DIR=$HOME/nmodl -DPYTHON_EXECUTABLE=$(which python3.9) -DCORENRN_NMODL_FLAGS="sympy --analytic"
make -j 2
if [ $? -ne 0 ]
then
make VERBOSE=1
exit 1
fi
ctest --output-on-failure
if [ $? -ne 0 ]
then
exit 1
fi
./bin/nrnivmodl-core $(Build.Repository.LocalPath)/test/integration/mod
env:
CMAKE_PKG: 'cmake-3.15.0-Linux-x86_64'
SHELL: 'bash'
displayName: 'Build Neuron and Run Integration Tests'
- job: 'osx11'
pool:
vmImage: 'macOS-12'
displayName: 'MacOS (12), AppleClang 14.0'
steps:
- checkout: self
submodules: True
- script: |
brew install flex bison cmake python@3
python3 -m pip install --upgrade pip "setuptools<=70.3.0"
python3 -m pip install --user -r requirements.txt
displayName: 'Install Dependencies'
- script: |
export PATH=/usr/local/opt/flex/bin:/usr/local/opt/bison/bin:$PATH;
mkdir -p $(Build.Repository.LocalPath)/build
cd $(Build.Repository.LocalPath)/build
cmake .. -DPYTHON_EXECUTABLE=$(which python3) -DCMAKE_INSTALL_PREFIX=$HOME/nmodl -DCMAKE_BUILD_TYPE=RelWithDebInfo -DNMODL_ENABLE_PYTHON_BINDINGS=OFF
make -j 2
if [ $? -ne 0 ]
then
make VERBOSE=1
exit 1
fi
ctest --output-on-failure
if [ $? -ne 0 ]
then
exit 1
fi
make install
displayName: 'Build and Run Tests'
- script: |
export PATH=$(pwd)/$CMAKE_PKG/bin:/home/vsts/.local/bin:$PATH
export PATH=/usr/local/opt/flex/bin:/usr/local/opt/bison/bin:$PATH;
export CC='gcc'
export CXX='g++'
git clone${NEURON_BRANCH:+ --branch }${NEURON_BRANCH} --single-branch https://github.com/neuronsimulator/nrn.git
mkdir nrn/build
cd nrn/build
cmake --version
cmake .. -DNRN_ENABLE_CORENEURON=ON -DNRN_ENABLE_INTERVIEWS=OFF -DNRN_ENABLE_RX3D=OFF -DNRN_ENABLE_MPI=OFF -DNRN_ENABLE_TESTS=ON -DCORENRN_ENABLE_MPI=OFF -DCORENRN_ENABLE_NMODL=ON -DCORENRN_NMODL_DIR=$HOME/nmodl -Dnmodl_PYTHONPATH=$HOME/nmodl/lib -DPYTHON_EXECUTABLE=$(which python3) -DCORENRN_NMODL_FLAGS="sympy --analytic"
make -j 2
if [ $? -ne 0 ]
then
make VERBOSE=1
exit 1
fi
ctest --output-on-failure
if [ $? -ne 0 ]
then
exit 1
fi
./bin/nrnivmodl-core $(Build.Repository.LocalPath)/test/integration/mod
env:
SHELL: 'bash'
displayName: 'Build Neuron and Run Integration Tests'
- job: 'manylinux_wheels'
timeoutInMinutes: 90
pool:
vmImage: 'ubuntu-20.04'
steps:
- task: UsePythonVersion@0
- checkout: self
submodules: True
condition: succeeded()
- script: |
if [[ "$(RELEASEWHEELBUILD)" != "True" ]]; then
echo "##vso[task.setvariable variable=TAG;]-nightly"
else
echo "##vso[task.setvariable variable=TAG;]"
fi
echo "Wheel tag: $TAG"
displayName: "Set wheel tag"
- script: |
echo "##vso[task.setvariable variable=CIBW_BUILD;]cp39* cp312*"
echo "Build identifiers: $CIBW_BUILD"
condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
displayName: "Set build identifiers"
- script: |
python3 -m pip install --upgrade pip
python3 -m pip install cibuildwheel==2.16.5 tomli tomli-w
# change the name accordingly
python3 packaging/change_name.py pyproject.toml "NMODL${TAG}"
export SETUPTOOLS_SCM_PRETEND_VERSION="$(git describe --tags | cut -d '-' -f 1,2 | tr - .)"
CIBW_BUILD="$(CIBW_BUILD)" CIBW_ENVIRONMENT_PASS_LINUX='SETUPTOOLS_SCM_PRETEND_VERSION' python3 -m cibuildwheel --output-dir wheelhouse
condition: succeeded()
displayName: 'Building ManyLinux Wheels'
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: '$(Build.SourcesDirectory)/wheelhouse'
condition: succeeded()
displayName: 'Publish wheel as build artifact'
- template: ci/upload-wheels.yml
- job: 'macos_wheels_x86_64'
timeoutInMinutes: 45
pool:
vmImage: 'macOS-12'
steps:
- checkout: self
submodules: True
condition: succeeded()
- script: |
brew install flex bison cmake ninja
condition: succeeded()
displayName: 'Install Dependencies'
- script: |
if [[ "$(RELEASEWHEELBUILD)" != "True" ]]; then
echo "##vso[task.setvariable variable=TAG;]-nightly"
else
echo "##vso[task.setvariable variable=TAG;]"
fi
echo "Wheel tag: $TAG"
displayName: "Set wheel tag"
- script: |
echo "##vso[task.setvariable variable=CIBW_BUILD;]cp39* cp312*"
echo "Build identifiers: $CIBW_BUILD"
condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
displayName: "Set build identifiers"
- task: UsePythonVersion@0
- script: |
python3 -m pip install --upgrade pip
python3 -m pip install cibuildwheel==2.16.5 tomli tomli-w
# change the name accordingly
python3 packaging/change_name.py pyproject.toml "NMODL${TAG}"
CIBW_BUILD="$(CIBW_BUILD)" SETUPTOOLS_SCM_PRETEND_VERSION="$(git describe --tags | cut -d '-' -f 1,2 | tr - .)" python3 -m cibuildwheel --output-dir wheelhouse
condition: succeeded()
displayName: 'Build macos Wheel (x86_64)'
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: '$(Build.SourcesDirectory)/wheelhouse'
condition: succeeded()
displayName: 'Publish wheel as build artifact'
- template: ci/upload-wheels.yml
- job: 'test_manylinux_wheels'
dependsOn: 'manylinux_wheels'
timeoutInMinutes: 45
pool:
vmImage: 'ubuntu-20.04'
strategy:
matrix:
${{ if eq(variables.buildWheel, True) }}:
Python39:
python.version: '3.9'
Python310:
python.version: '3.10'
Python311:
python.version: '3.11'
Python312:
python.version: '3.12'
${{ if eq(variables.buildWheel, False) }}:
Python311:
python.version: '3.11'
steps:
- download: current
patterns: 'drop/*.whl'
displayName: "Make manylinux wheels available"
- script: |
set -eux
sudo apt-add-repository -y ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install -y python$(python.version) python$(python.version)-dev python$(python.version)-venv
dotless_version="$(echo "$(python.version)" | tr -d '.')"
find $(Pipeline.Workspace) -name "*cp${dotless_version}-manylinux*.whl" -exec bash packaging/test_wheel.bash python$(python.version) {} \;
condition: succeeded()
displayName: 'Test manylinux Wheel with Python $(python.version)'