.gitlab-ci.yml 5.3 KB
Newer Older
Gregory Ashton's avatar
Gregory Ashton committed
1 2
# This script is an edited version of the example found at
# https://git.ligo.org/lscsoft/example-ci-project/blob/python/.gitlab-ci.yml
3
# Each 0th-indentation level is a job that will be run within GitLab CI
Gregory Ashton's avatar
Gregory Ashton committed
4 5 6 7 8 9 10 11 12
# 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:
Colm Talbot's avatar
Colm Talbot committed
13
  - initial
Gregory Ashton's avatar
Gregory Ashton committed
14
  - test
Colm Talbot's avatar
Fix ci  
Colm Talbot committed
15
  - docs
Gregory Ashton's avatar
Gregory Ashton committed
16 17
  - deploy

18
.test-python: &test-python
Colm Talbot's avatar
Colm Talbot committed
19
  stage: initial
20 21 22 23 24 25 26 27 28
  image: python
  before_script:
    # this is required because pytables doesn't use a wheel on py37
    - apt-get -yqq update
    - apt-get -yqq install libhdf5-dev
  script:
    - python -m pip install .
    - python -c "import bilby"
    - python -c "import bilby.core"
29
    - python -c "import bilby.core.prior"
30
    - python -c "import bilby.core.sampler"
31
    - python -c "import bilby.gw"
32 33
    - python -c "import bilby.gw.detector"
    - python -c "import bilby.gw.sampler"
34 35
    - python -c "import bilby.hyper"
    - python -c "import cli_bilby"
Colm Talbot's avatar
Colm Talbot committed
36
    - python test/import_test.py
37 38 39
    - for script in $(pip show -f bilby | grep "bin\/" | xargs -I {} basename {}); do
          ${script} --help;
      done
40 41 42 43 44 45

# test basic setup on python3
basic-3.7:
  <<: *test-python
  image: python:3.7

46
# test example on python 3.7
47
python-3.7:
Gregory Ashton's avatar
Gregory Ashton committed
48
  stage: test
Colm Talbot's avatar
Colm Talbot committed
49
  needs: ["basic-3.7", "precommits-py3.7"]
50
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
Gregory Ashton's avatar
Gregory Ashton committed
51
  script:
52
    - python -m pip install .
Gregory Ashton's avatar
Gregory Ashton committed
53 54 55 56

    # Run pyflakes
    - flake8 .

Gregory Ashton's avatar
Gregory Ashton committed
57
    # Run tests and collect coverage data
Gregory Ashton's avatar
Gregory Ashton committed
58
    - pytest --cov=bilby --durations 10
59 60
    - coverage html
    - coverage-badge -o coverage_badge.svg -f
61

Colm Talbot's avatar
Colm Talbot committed
62 63 64 65 66 67
  artifacts:
    paths:
      - coverage_badge.svg
      - htmlcov/

docs:
Colm Talbot's avatar
Fix ci  
Colm Talbot committed
68
  stage: docs
Colm Talbot's avatar
Colm Talbot committed
69
  needs: ["basic-3.7"]
Colm Talbot's avatar
Colm Talbot committed
70 71
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
  script:
72
    # Make the documentation
Colm Talbot's avatar
Colm Talbot committed
73 74
    - apt-get -yqq install pandoc
    - python -m pip install .
75
    - cd docs
Colm Talbot's avatar
Colm Talbot committed
76 77 78 79 80 81
    - pip install ipykernel ipython jupyter
    - cp ../examples/tutorials/*.ipynb ./
    - rm basic_ptmcmc_tutorial.ipynb
    - rm compare_samplers.ipynb
    - rm visualising_the_results.ipynb
    - jupyter nbconvert --to notebook --execute *.ipynb --inplace
Gregory Ashton's avatar
Gregory Ashton committed
82
    - make clean
83 84
    - make html

Gregory Ashton's avatar
Gregory Ashton committed
85 86
  artifacts:
    paths:
87
      - docs/_build/html/
Gregory Ashton's avatar
Gregory Ashton committed
88

Gregory Ashton's avatar
Gregory Ashton committed
89 90 91
# test example on python 3.8
python-3.8:
  stage: test
Colm Talbot's avatar
Colm Talbot committed
92
  needs: ["basic-3.7", "precommits-py3.7"]
93
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python38
Gregory Ashton's avatar
Gregory Ashton committed
94 95 96 97 98
  script:
    - python -m pip install .

    - pytest

99
# test example on python 3.6
Gregory Ashton's avatar
Gregory Ashton committed
100 101
python-3.6:
  stage: test
Colm Talbot's avatar
Colm Talbot committed
102
  needs: ["basic-3.7", "precommits-py3.7"]
103
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python36
Gregory Ashton's avatar
Gregory Ashton committed
104 105 106 107
  script:
    - python -m pip install .

    - pytest
108

Gregory Ashton's avatar
Gregory Ashton committed
109 110 111
# test samplers on python 3.7
python-3.7-samplers:
  stage: test
Colm Talbot's avatar
Colm Talbot committed
112
  needs: ["basic-3.7", "precommits-py3.7"]
113
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
Gregory Ashton's avatar
Gregory Ashton committed
114 115 116
  script:
    - python -m pip install .

Moritz Huebner's avatar
Moritz Huebner committed
117
    - pytest test/integration/sampler_run_test.py --durations 10
Gregory Ashton's avatar
Gregory Ashton committed
118 119 120 121

# test samplers on python 3.6
python-3.6-samplers:
  stage: test
Colm Talbot's avatar
Colm Talbot committed
122
  needs: ["basic-3.7", "precommits-py3.7"]
123
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python36
Gregory Ashton's avatar
Gregory Ashton committed
124 125 126
  script:
    - python -m pip install .

Moritz Huebner's avatar
Moritz Huebner committed
127
    - pytest test/integration/sampler_run_test.py
Gregory Ashton's avatar
Gregory Ashton committed
128

Colm Talbot's avatar
Colm Talbot committed
129 130
# Test containers are up to date
containers:
Colm Talbot's avatar
Colm Talbot committed
131
  stage: initial
132
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
Colm Talbot's avatar
Colm Talbot committed
133 134 135 136 137 138 139
  script:
    - cd containers
    - python write_dockerfiles.py
    # Fail if differences exist. If this fails, you may need to run
    # write_dockerfiles.py and commit the changes.
    - git diff --exit-code

140 141 142
# Tests run at a fixed schedule rather than on push
scheduled-python-3.7:
  stage: test
143
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
144 145 146
  only:
    - schedules
  script:
147
    - python -m pip install .
148 149

    # Run tests which are only done on schedule
Moritz Huebner's avatar
Moritz Huebner committed
150
    - pytest test/integration/example_test.py
151

Colm Talbot's avatar
Colm Talbot committed
152 153
plotting:
  stage: test
154
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
Colm Talbot's avatar
Colm Talbot committed
155 156 157 158 159 160
  only:
    - schedules
  script:
    - python -m pip install .
    - python -m pip install ligo.skymap

Moritz Huebner's avatar
Moritz Huebner committed
161
    - pytest test/gw/plot_test.py
162 163

authors:
Colm Talbot's avatar
Colm Talbot committed
164
  stage: initial
165
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
166 167
  script:
    - python test/check_author_list.py
Colm Talbot's avatar
Colm Talbot committed
168

Gregory Ashton's avatar
Gregory Ashton committed
169 170
pages:
  stage: deploy
Colm Talbot's avatar
Colm Talbot committed
171
  needs: ["docs", "python-3.7"]
Gregory Ashton's avatar
Gregory Ashton committed
172
  dependencies:
Colm Talbot's avatar
Colm Talbot committed
173
    - docs
174
    - python-3.7
Gregory Ashton's avatar
Gregory Ashton committed
175
  script:
176
    - mkdir public/
Gregory Ashton's avatar
Gregory Ashton committed
177
    - mv htmlcov/ public/
178
    - mv coverage_badge.svg public/
179
    - mv docs/_build/html/* public/
Gregory Ashton's avatar
Gregory Ashton committed
180 181 182 183
  artifacts:
    paths:
      - public
    expire_in: 30 days
184 185
  only:
    - master
186 187 188

deploy_release:
  stage: deploy
189
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
190 191 192 193 194 195 196 197 198 199
  variables:
    TWINE_USERNAME: $PYPI_USERNAME
    TWINE_PASSWORD: $PYPI_PASSWORD
  before_script:
    - pip install twine
    - python setup.py sdist
  script:
    - twine upload dist/*
  only:
  - tags
200 201 202


precommits-py3.7:
Colm Talbot's avatar
Colm Talbot committed
203
  stage: initial
204
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
205 206 207 208 209 210 211 212 213 214
  script:
    - source activate python37
    - mkdir -p .pip37
    - pip install --upgrade pip
    - pip --cache-dir=.pip37 install --upgrade bilby
    - pip --cache-dir=.pip37 install .
    - pip --cache-dir=.pip37 install pre-commit

    # Run precommits (flake8, spellcheck, isort, no merge conflicts, etc)
    - pre-commit run --all-files --verbose --show-diff-on-failure