forked from bilby-dev/bilby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
287 lines (250 loc) · 7.55 KB
/
.gitlab-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
# This script is an edited version of the example found at
# https://git.ligo.org/lscsoft/example-ci-project/blob/python/.gitlab-ci.yml
# Each 0th-indentation level is a job that will be run within GitLab CI
# The only exception are a short list of reserved keywords
#
# https://docs.gitlab.com/ee/ci/yaml/#gitlab-ci-yml
# stages is a reserved keyword that defines job dependencies and
# parallelization. each stage runs in parallel but must complete
# before the next stage begins
stages:
- initial
- test
- docs
- deploy
# ------------------- Initial stage -------------------------------------------
.list-env: &list-env
- PREFIX="$(dirname $(which python))/.."
- if [ -d "${PREFIX}/conda-meta" ]; then
conda list --prefix "${PREFIX}" --show-channel-urls;
else
python -m pip list installed;
fi
# Check author list is up to date
authors:
stage: initial
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python310
script:
- python test/check_author_list.py
# Test containers scripts are up to date
containers:
stage: initial
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python310
script:
- cd containers
- python write_dockerfiles.py #HACK
# Fail if differences exist. If this fails, you may need to run
# write_dockerfiles.py and commit the changes.
- git diff --exit-code
.test-python: &test-python
stage: initial
image: python
script:
- python -m pip install .
- *list-env
- python -c "import bilby"
- python -c "import bilby.bilby_mcmc"
- python -c "import bilby.core"
- python -c "import bilby.core.prior"
- python -c "import bilby.core.sampler"
- python -c "import bilby.core.utils"
- python -c "import bilby.gw"
- python -c "import bilby.gw.detector"
- python -c "import bilby.gw.eos"
- python -c "import bilby.gw.likelihood"
- python -c "import bilby.gw.sampler"
- python -c "import bilby.hyper"
- python -c "import cli_bilby"
- python test/import_test.py
- for script in $(pip show -f bilby | grep "bin\/" | xargs -I {} basename {}); do
${script} --help;
done
basic-3.9:
<<: *test-python
image: python:3.9
basic-3.10:
<<: *test-python
image: python:3.10
.test-samplers-import: &test-samplers-import
stage: initial
script:
- python -m pip install .
- *list-env
- python test/test_samplers_import.py
import-samplers-3.9:
<<: *test-samplers-import
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python39
import-samplers-3.10:
<<: *test-samplers-import
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python310
.precommits: &precommits
stage: initial
script:
- source activate $PYVERSION
- mkdir -p $CACHE_DIR
- pip install --upgrade pip
- pip --cache-dir=$CACHE_DIR install --upgrade bilby
- pip --cache-dir=$CACHE_DIR install .
- pip --cache-dir=$CACHE_DIR install pre-commit
# Run precommits (flake8, spellcheck, isort, no merge conflicts, etc)
- pre-commit run --all-files --verbose --show-diff-on-failure
precommits-py3.9:
<<: *precommits
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python39
variables:
CACHE_DIR: ".pip39"
PYVERSION: "python39"
precommits-py3.10:
<<: *precommits
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python310
variables:
CACHE_DIR: ".pip310"
PYVERSION: "python310"
install:
stage: initial
parallel:
matrix:
- EXTRA: [gw, mcmc, all]
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python310
script:
- pip install .[$EXTRA]
# ------------------- Test stage -------------------------------------------
.unit-tests: &unit-test
stage: test
script:
- python -m pip install .
- *list-env
- pytest --cov=bilby --durations 10
python-3.9:
<<: *unit-test
needs: ["basic-3.9", "precommits-py3.9"]
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python39
python-3.10:
<<: *unit-test
needs: ["basic-3.10", "precommits-py3.10"]
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python310
after_script:
- coverage html
- coverage xml
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
paths:
- htmlcov/
expire_in: 30 days
.test-sampler: &test-sampler
stage: test
script:
- python -m pip install .[all]
- *list-env
- pytest test/integration/sampler_run_test.py --durations 10 -v
python-3.9-samplers:
<<: *test-sampler
needs: ["basic-3.9", "precommits-py3.9"]
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python39
python-3.10-samplers:
<<: *test-sampler
needs: ["basic-3.10", "precommits-py3.10"]
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python310
integration-tests-python-3.10:
stage: test
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python310
needs: ["basic-3.10", "precommits-py3.10"]
only:
- schedules
script:
- python -m pip install .
- *list-env
# Run tests which are only done on schedule
- pytest test/integration/example_test.py
.plotting: &plotting
stage: test
only:
- schedules
script:
- python -m pip install .
- *list-env
- pytest test/gw/plot_test.py
plotting-python-3.9:
<<: *plotting
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python39
needs: ["basic-3.9", "precommits-py3.9"]
plotting-python-3.10:
<<: *plotting
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python310
needs: ["basic-3.10", "precommits-py3.10"]
# ------------------- Docs stage -------------------------------------------
docs:
stage: docs
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python310
before_script:
- conda install -c conda-forge pandoc ipython jupyter nbconvert
- python -m pip install ipykernel
- python -m ipykernel install
script:
# Make the documentation
- python -m pip install .
- cd examples/tutorials
- jupyter nbconvert --to notebook --execute *.ipynb --output-dir ../../docs
- cd ../../docs
- make clean
- make html
artifacts:
paths:
- docs/_build/html/
# ------------------- Deploy stage -------------------------------------------
pages:
stage: deploy
needs: ["docs", "python-3.10"]
script:
- mkdir public/
- mv htmlcov/ public/
- mv docs/_build/html/* public/
artifacts:
paths:
- public
expire_in: 30 days
only:
- master
.build-container: &build-container
stage: deploy
image: docker:20.10.23
needs: ["containers"]
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
compare_to: 'refs/heads/main'
paths:
- containers/*
when: manual
- if: $CI_PIPELINE_SOURCE == "schedule"
script:
- cd containers
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build --tag v3-bilby-$PYVERSION - < v3-dockerfile-test-suite-$PYVERSION
- docker image tag v3-bilby-$PYVERSION containers.ligo.org/lscsoft/bilby/v2-bilby-$PYVERSION:latest
- docker image push containers.ligo.org/lscsoft/bilby/v2-bilby-$PYVERSION:latest
build-python39-container:
<<: *build-container
variables:
PYVERSION: "python39"
build-python310-container:
<<: *build-container
variables:
PYVERSION: "python310"
pypi-release:
stage: deploy
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python310
variables:
TWINE_USERNAME: $PYPI_USERNAME
TWINE_PASSWORD: $PYPI_PASSWORD
before_script:
- python -m pip install twine setuptools_scm build
- python -m build --sdist --wheel --outdir dist/ .
script:
- twine upload dist/*
only:
- tags