.gitlab-ci.yml 4.65 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 13 14 15
# 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:
  - test
  - deploy

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

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

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

    # Run pyflakes
    - flake8 .

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

    # Make the documentation
    - cd docs
Gregory Ashton's avatar
Gregory Ashton committed
60
    - make clean
61 62
    - make html

Gregory Ashton's avatar
Gregory Ashton committed
63 64 65
  artifacts:
    paths:
      - htmlcov/
66
      - coverage_badge.svg
67
      - docs/_build/html/
Gregory Ashton's avatar
Gregory Ashton committed
68

Gregory Ashton's avatar
Gregory Ashton committed
69 70 71
# test example on python 3.8
python-3.8:
  stage: test
72
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python38
Gregory Ashton's avatar
Gregory Ashton committed
73 74 75 76 77
  script:
    - python -m pip install .

    - pytest

78
# test example on python 3.6
Gregory Ashton's avatar
Gregory Ashton committed
79 80
python-3.6:
  stage: test
81
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python36
Gregory Ashton's avatar
Gregory Ashton committed
82 83 84 85
  script:
    - python -m pip install .

    - pytest
86

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

Moritz Huebner's avatar
Moritz Huebner committed
94 95
    - 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
96 97 98 99

# test samplers on python 3.6
python-3.6-samplers:
  stage: test
100
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python36
Gregory Ashton's avatar
Gregory Ashton committed
101 102 103
  script:
    - python -m pip install .

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

Colm Talbot's avatar
Colm Talbot committed
106 107 108
# Test containers are up to date
containers:
  stage: test
109
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
Colm Talbot's avatar
Colm Talbot committed
110 111 112 113 114 115 116
  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

117 118 119
# Tests run at a fixed schedule rather than on push
scheduled-python-3.7:
  stage: test
120
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
121 122 123
  only:
    - schedules
  script:
124
    - python -m pip install .
125 126

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

Colm Talbot's avatar
Colm Talbot committed
130 131
plotting:
  stage: test
132
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
Colm Talbot's avatar
Colm Talbot committed
133 134 135 136 137 138
  only:
    - schedules
  script:
    - python -m pip install .
    - python -m pip install ligo.skymap

Moritz Huebner's avatar
Moritz Huebner committed
139
    - pytest test/gw/plot_test.py
140 141 142

authors:
  stage: test
143
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
144 145
  script:
    - python test/check_author_list.py
Colm Talbot's avatar
Colm Talbot committed
146

Gregory Ashton's avatar
Gregory Ashton committed
147 148 149
pages:
  stage: deploy
  dependencies:
150
    - python-3.7
Gregory Ashton's avatar
Gregory Ashton committed
151
  script:
152
    - mkdir public/
Gregory Ashton's avatar
Gregory Ashton committed
153
    - mv htmlcov/ public/
154
    - mv coverage_badge.svg public/
155
    - mv docs/_build/html/* public/
Gregory Ashton's avatar
Gregory Ashton committed
156 157 158 159
  artifacts:
    paths:
      - public
    expire_in: 30 days
160 161
  only:
    - master
162 163 164

deploy_release:
  stage: deploy
165
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
166 167 168 169 170 171 172 173 174 175
  variables:
    TWINE_USERNAME: $PYPI_USERNAME
    TWINE_PASSWORD: $PYPI_PASSWORD
  before_script:
    - pip install twine
    - python setup.py sdist
  script:
    - twine upload dist/*
  only:
  - tags
176 177 178 179


precommits-py3.7:
  stage: test
180
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
181 182 183 184 185 186 187 188 189 190
  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