forked from NeuralEnsemble/elephant
-
Notifications
You must be signed in to change notification settings - Fork 9
484 lines (415 loc) · 15.3 KB
/
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
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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
# This workflow will set up GitHub-hosted runners and install the required dependencies for elephant tests.
# On a pull requests and on pushes to master it will run different tests for elephant.
name: tests
# define events that trigger workflow 'tests'
on:
workflow_dispatch: # enables manual triggering of workflow
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
pull_request:
branches:
- master
types:
#- assigned
#- unassigned
#- labeled
#- unlabeled
- opened
#- edited
#- closed
- reopened
- synchronize
#- converted_to_draft
#- ready_for_review
#- locked
#- unlocked
#- review_requested
#- review_request_removed
#- auto_merge_enabled
#- auto_merge_disabled
push:
branches:
- master
# jobs define the steps that will be executed on the runner
jobs:
# _
# _ __ (_)_ __
# | '_ \| | '_ \
# | |_) | | |_) |
# | .__/|_| .__/
# |_| |_|
# install dependencies and elephant with pip and run tests with pytest
build-and-test-pip:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# python versions for elephant: [3.8, 3.9, "3.10", 3.11]
python-version: [3.8, 3.9, "3.10", 3.11]
# OS [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest]
# do not cancel all in-progress jobs if any matrix job fails
fail-fast: false
steps:
# used to reset cache every month
- name: Get current year-month
id: date
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: '**/requirements.txt'
- name: Cache test_env
uses: actions/cache@v3
with:
path: /home/runner/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements files
# cache will be reset on changes to any requirements or every month
key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements-tests.txt') }}
-${{ hashFiles('**/requirements-extras.txt') }}-${{ hashFiles('**/CI.yml') }}-${{ hashFiles('setup.py') }}
-${{ steps.date.outputs.date }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install coveralls
pip install -r requirements/requirements-tests.txt
pip install -r requirements/requirements.txt
pip install -r requirements/requirements-extras.txt
pip install -e .
- name: List packages
run: |
pip list
python --version
- name: Test with pytest
run: |
coverage run --source=elephant -m pytest
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ___ ____
# _ __ ___ __ _ ___ / _ \/ ___|
# | '_ ` _ \ / _` |/ __| | | \___ \
# | | | | | | (_| | (__| |_| |___) |
# |_| |_| |_|\__,_|\___|\___/|____/
test-macOS:
name: conda (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
# do not cancel all in-progress jobs if any matrix job fails
fail-fast: false
matrix:
# OS [ubuntu-latest, macos-latest, windows-latest]
os: [macos-11,macos-12]
python-version: [3.9]
steps:
- name: Get current year-month
id: date
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3
- name: Cache conda
uses: actions/cache@v3
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{hashFiles('requirements/environment.yml') }}-${{ hashFiles('**/CI.yml') }}-${{ steps.date.outputs.date }}
- uses: conda-incubator/setup-miniconda@3b0f2504dd76ef23b6d31f291f4913fb60ab5ff3 # corresponds to v2.2.0
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
activate-environment: elephant
environment-file: requirements/environment-tests.yml
auto-activate-base: false
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
- name: Install dependencies
shell: bash -l {0}
run: |
python --version
conda env list
conda install mpi4py openmpi
conda install pytest
conda install pytest-cov coveralls
pip install -e .[extras]
- name: List packages
shell: bash -l {0}
run: |
pip list
conda list
python --version
- name: Test with pytest
shell: bash -l {0}
run: |
pytest --cov=elephant
# __ ___ _
# \ \ / (_)_ __ __| | _____ _____
# \ \ /\ / /| | '_ \ / _` |/ _ \ \ /\ / / __|
# \ V V / | | | | | (_| | (_) \ V V /\__ \
# \_/\_/ |_|_| |_|\__,_|\___/ \_/\_/ |___/
# install dependencies with pip and run tests with pytest
test-pip:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# python versions for elephant: [3.8, 3.9, 3.10, 3.11]
python-version: [3.8,]
# OS [ubuntu-latest, macos-latest, windows-latest]
os: [windows-latest]
include:
# - os: ubuntu-latest
# path: ~/.cache/pip
# - os: macos-latest
# path: ~/Library/Caches/pip
- os: windows-latest
path: ~\AppData\Local\pip\Cache
# do not cancel all in-progress jobs if any matrix job fails
fail-fast: false
steps:
- name: Get current year-month
id: date
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
uses: actions/cache@v3
with:
path: ${{ matrix.path }}
# Look to see if there is a cache hit for the corresponding requirements files
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements-tests.txt') }}
-${{ hashFiles('**/requirements-extras.txt') }}-${{ hashFiles('setup.py') }} -${{ hashFiles('**/CI.yml') }}-${{ steps.date.outputs.date }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/requirements-tests.txt
pip install -r requirements/requirements.txt
pip install -r requirements/requirements-extras.txt
pip install pytest-cov coveralls
pip install -e .
- name: List packages
run: |
pip list
python --version
- name: Test with pytest
run: |
pytest --cov=elephant
# __ __ ____ ___
# | \/ | _ \_ _|
# | |\/| | |_) | |
# | | | | __/| |
# |_| |_|_| |___|
# install dependencies and elephant with pip and run MPI
test-pip-MPI:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# python versions for elephant: [3.8, 3.9, 3.10, 3.11]
python-version: [3.9]
# OS [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest]
# do not cancel all in-progress jobs if any matrix job fails
fail-fast: false
steps:
- name: Get current year-month
id: date
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache test_env
uses: actions/cache@v3
with:
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements files
# cache will be reset on changes to any requirements or every month
key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements-tests.txt') }}
-${{ hashFiles('**/requirements-extras.txt') }}-${{ hashFiles('setup.py') }} -${{ hashFiles('**/CI.yml') }}-${{ steps.date.outputs.date }}
- name: Setup environment
run: |
sudo apt-get update
sudo apt install -y libopenmpi-dev openmpi-bin
python -m pip install --upgrade pip
pip install mpi4py
pip install coveralls
pip install -r requirements/requirements-tests.txt
pip install -r requirements/requirements.txt
pip install -r requirements/requirements-extras.txt
pip install pytest-cov coveralls
pip install -e .
- name: List packages
run: |
pip list
python --version
- name: Test with pytest
run: |
mpiexec -n 1 python -m mpi4py -m coverage run --source=elephant -m pytest
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ____ _
# / ___|___ _ __ __| | __ _
# | | / _ \| '_ \ / _` |/ _` |
# | |__| (_) | | | | (_| | (_| |
# \____\___/|_| |_|\__,_|\__,_|
# install dependencies with conda and run tests with pytest
test-conda:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# OS [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest]
python-version: [3.9]
# do not cancel all in-progress jobs if any matrix job fails
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{hashFiles('requirements/environment-tests.yml') }}-${{ hashFiles('**/CI.yml') }}-${{ steps.date.outputs.date }}
- uses: conda-incubator/setup-miniconda@3b0f2504dd76ef23b6d31f291f4913fb60ab5ff3 # corresponds to v2.2.0
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
activate-environment: elephant
environment-file: requirements/environment-tests.yml
auto-activate-base: false
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
- name: Install dependencies
shell: bash -l {0}
run: |
python --version
conda env list
conda install mpi4py openmpi
conda install pytest
conda install pytest-cov coveralls
pip install -e .
- name: List packages
shell: bash -l {0}
run: |
pip list
conda list
python --version
- name: Test with pytest
shell: bash -l {0}
run: |
pytest --cov=elephant
# ____
# | _ \ ___ ___ ___
# | | | |/ _ \ / __/ __|
# | |_| | (_) | (__\__ \
# |____/ \___/ \___|___/
# install dependencies for the documentation and build .html
docs:
name: docs (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
# OS [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest]
steps:
- name: Get current year-month
id: date
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3
- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements files
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-docs.txt') }}-${{ hashFiles('**/requirements-tutorials.txt') }}-${{ hashFiles('**/environment-docs.yml') }}
-${{ hashFiles('**/CI.yml') }}-${{ steps.date.outputs.date }}
- name: Install dependencies
run: |
conda config --add channels conda-forge # bugfix with scipy==1.8.1: libstdcxx-ng 12.1.0 required
sudo apt-get update
sudo apt install -y libopenmpi-dev openmpi-bin
conda update conda
conda install -c conda-forge openmpi pandoc libstdcxx-ng # fix libstdc++.so.6: version for new scipy versions > 1.9.1
conda env update --file requirements/environment-docs.yml --name base
activate base
python -m pip install --upgrade pip
pip install -r requirements/requirements-docs.txt
pip install -r requirements/requirements-tutorials.txt
pip install -e .[extras]
# run notebooks
sed -i -E "s/nbsphinx_execute *=.*/nbsphinx_execute = 'always'/g" doc/conf.py
- name: List packages
run: |
activate base
pip list
conda list
python --version
- name: make html
run: |
activate base
cd doc
make html
# install dependencies and elephant with pip and run tests with pytest
doctests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# python versions for elephant: [3.7, 3.8, 3.9, "3.10"]
python-version: ["3.10"]
# OS [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest]
# do not cancel all in-progress jobs if any matrix job fails
fail-fast: false
steps:
# used to reset cache every month
- name: Get current year-month
id: date
run: echo "::set-output name=date::$(date +'%Y-%m')"
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache test_env
uses: actions/cache@v3
with:
path: ~/test_env
# Look to see if there is a cache hit for the corresponding requirements files
# cache will be reset on changes to any requirements or every month
key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements-tests.txt') }}
-${{ hashFiles('**/requirements-extras.txt') }}-${{ hashFiles('**/CI.yml') }}-${{ hashFiles('setup.py') }}
-${{ steps.date.outputs.date }}
- name: Install dependencies
run: |
# create an environment and install everything
python -m venv ~/test_env
source ~/test_env/bin/activate
sudo apt install -y libopenmpi-dev openmpi-bin
python -m pip install --upgrade pip
pip install mpi4py
pip install -r requirements/requirements-tests.txt
pip install -r requirements/requirements.txt
pip install -r requirements/requirements-extras.txt
pip install pytest-cov coveralls
pip install -e .
- name: List packages
run: |
source ~/test_env/bin/activate
pip list
python --version
- name: Run doctests
run: |
source ~/test_env/bin/activate
pytest elephant --doctest-modules --ignore=elephant/test/