.gitlab-ci.yml 4.13 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: 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 72 73 74 75 76 77
# test example on python 3.8
python-3.8:
  stage: test
  image: bilbydev/v2-dockerfile-test-suite-python38
  script:
    - python -m pip install .

    - pytest

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

    - pytest
86

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

Moritz Huebner's avatar
Moritz Huebner committed
94 95
    - pytest test/core/sampler/sampler_run_test.py --durations 10
    - pytest test/gw/sample_from_the_prior_test.py
Gregory Ashton's avatar
Gregory Ashton committed
96 97 98 99 100 101 102 103

# test samplers on python 3.6
python-3.6-samplers:
  stage: test
  image: bilbydev/v2-dockerfile-test-suite-python36
  script:
    - python -m pip install .

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

106 107 108
# Tests run at a fixed schedule rather than on push
scheduled-python-3.7:
  stage: test
Gregory Ashton's avatar
Gregory Ashton committed
109
  image: bilbydev/v2-dockerfile-test-suite-python37
110 111 112
  only:
    - schedules
  script:
113
    - python -m pip install .
114 115

    # Run tests which are only done on schedule
Moritz Huebner's avatar
Moritz Huebner committed
116 117 118
    - pytest test/core/example_test.py
    - pytest test/gw/example_test.py
    - pytest test/gw/sample_from_the_prior_test.py
119

Colm Talbot's avatar
Colm Talbot committed
120 121 122 123 124 125 126 127 128
plotting:
  stage: test
  image: bilbydev/bilby-test-suite-python37
  only:
    - schedules
  script:
    - python -m pip install .
    - python -m pip install ligo.skymap

Moritz Huebner's avatar
Moritz Huebner committed
129
    - pytest test/gw/plot_test.py
Colm Talbot's avatar
Colm Talbot committed
130

Gregory Ashton's avatar
Gregory Ashton committed
131 132 133
pages:
  stage: deploy
  dependencies:
134
    - python-3.7
Gregory Ashton's avatar
Gregory Ashton committed
135
  script:
136
    - mkdir public/
Gregory Ashton's avatar
Gregory Ashton committed
137
    - mv htmlcov/ public/
138
    - mv coverage_badge.svg public/
139
    - mv docs/_build/html/* public/
Gregory Ashton's avatar
Gregory Ashton committed
140 141 142 143
  artifacts:
    paths:
      - public
    expire_in: 30 days
144 145
  only:
    - master
146 147 148 149 150 151 152 153 154 155 156 157 158 159

deploy_release:
  stage: deploy
  image: bilbydev/v2-dockerfile-test-suite-python37
  variables:
    TWINE_USERNAME: $PYPI_USERNAME
    TWINE_PASSWORD: $PYPI_PASSWORD
  before_script:
    - pip install twine
    - python setup.py sdist
  script:
    - twine upload dist/*
  only:
  - tags
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174


precommits-py3.7:
  stage: test
  image: bilbydev/v2-dockerfile-test-suite-python37
  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