.gitlab-ci.yml 5.12 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 15 16
  - test
  - deploy

17
.test-python: &test-python
Colm Talbot's avatar
Colm Talbot committed
18
  stage: initial
19 20 21 22 23 24 25 26 27
  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"
28
    - python -c "import bilby.core.prior"
29
    - python -c "import bilby.core.sampler"
30
    - python -c "import bilby.gw"
31 32
    - python -c "import bilby.gw.detector"
    - python -c "import bilby.gw.sampler"
33 34
    - python -c "import bilby.hyper"
    - python -c "import cli_bilby"
35 36 37
    - for script in $(pip show -f bilby | grep "bin\/" | xargs -I {} basename {}); do
          ${script} --help;
      done
38 39 40 41 42 43

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

44
# test example on python 3.7
45
python-3.7:
Gregory Ashton's avatar
Gregory Ashton committed
46
  stage: test
47
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
Gregory Ashton's avatar
Gregory Ashton committed
48
  script:
49
    - python -m pip install .
Gregory Ashton's avatar
Gregory Ashton committed
50 51 52 53

    # Run pyflakes
    - flake8 .

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

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

docs:
  stage: initial
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
  script:
68
    # Make the documentation
Colm Talbot's avatar
Colm Talbot committed
69 70
    - apt-get -yqq install pandoc
    - python -m pip install .
71
    - cd docs
Colm Talbot's avatar
Colm Talbot committed
72 73 74 75 76 77
    - 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
78
    - make clean
79 80
    - make html

Gregory Ashton's avatar
Gregory Ashton committed
81 82
  artifacts:
    paths:
83
      - docs/_build/html/
Gregory Ashton's avatar
Gregory Ashton committed
84

Gregory Ashton's avatar
Gregory Ashton committed
85 86 87
# test example on python 3.8
python-3.8:
  stage: test
88
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python38
Gregory Ashton's avatar
Gregory Ashton committed
89 90 91 92 93
  script:
    - python -m pip install .

    - pytest

94
# test example on python 3.6
Gregory Ashton's avatar
Gregory Ashton committed
95 96
python-3.6:
  stage: test
97
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python36
Gregory Ashton's avatar
Gregory Ashton committed
98 99 100 101
  script:
    - python -m pip install .

    - pytest
102

Gregory Ashton's avatar
Gregory Ashton committed
103 104 105
# test samplers on python 3.7
python-3.7-samplers:
  stage: test
106
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
Gregory Ashton's avatar
Gregory Ashton committed
107 108 109
  script:
    - python -m pip install .

Moritz Huebner's avatar
Moritz Huebner committed
110 111
    - pytest test/integration/sampler_run_test.py --durations 10
    - pytest test/integration/sample_from_the_prior_test.py
Gregory Ashton's avatar
Gregory Ashton committed
112 113 114 115

# test samplers on python 3.6
python-3.6-samplers:
  stage: test
116
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python36
Gregory Ashton's avatar
Gregory Ashton committed
117 118 119
  script:
    - python -m pip install .

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

Colm Talbot's avatar
Colm Talbot committed
122 123
# Test containers are up to date
containers:
Colm Talbot's avatar
Colm Talbot committed
124
  stage: initial
125
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
Colm Talbot's avatar
Colm Talbot committed
126 127 128 129 130 131 132
  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

133 134 135
# Tests run at a fixed schedule rather than on push
scheduled-python-3.7:
  stage: test
136
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
137 138 139
  only:
    - schedules
  script:
140
    - python -m pip install .
141 142

    # Run tests which are only done on schedule
Moritz Huebner's avatar
Moritz Huebner committed
143 144
    - pytest test/integration/example_test.py
    - pytest test/integration/sample_from_the_prior_test.py
145

Colm Talbot's avatar
Colm Talbot committed
146 147
plotting:
  stage: test
148
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
Colm Talbot's avatar
Colm Talbot committed
149 150 151 152 153 154
  only:
    - schedules
  script:
    - python -m pip install .
    - python -m pip install ligo.skymap

Moritz Huebner's avatar
Moritz Huebner committed
155
    - pytest test/gw/plot_test.py
156 157

authors:
Colm Talbot's avatar
Colm Talbot committed
158
  stage: initial
159
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
160 161
  script:
    - python test/check_author_list.py
Colm Talbot's avatar
Colm Talbot committed
162

Gregory Ashton's avatar
Gregory Ashton committed
163 164 165
pages:
  stage: deploy
  dependencies:
Colm Talbot's avatar
Colm Talbot committed
166
    - docs
167
    - python-3.7
Gregory Ashton's avatar
Gregory Ashton committed
168
  script:
169
    - mkdir public/
Gregory Ashton's avatar
Gregory Ashton committed
170
    - mv htmlcov/ public/
171
    - mv coverage_badge.svg public/
172
    - mv docs/_build/html/* public/
Gregory Ashton's avatar
Gregory Ashton committed
173 174 175 176
  artifacts:
    paths:
      - public
    expire_in: 30 days
177 178
  only:
    - master
179 180 181

deploy_release:
  stage: deploy
182
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
183 184 185 186 187 188 189 190 191 192
  variables:
    TWINE_USERNAME: $PYPI_USERNAME
    TWINE_PASSWORD: $PYPI_PASSWORD
  before_script:
    - pip install twine
    - python setup.py sdist
  script:
    - twine upload dist/*
  only:
  - tags
193 194 195


precommits-py3.7:
Colm Talbot's avatar
Colm Talbot committed
196
  stage: initial
197
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
198 199 200 201 202 203 204 205 206 207
  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