.gitlab-ci.yml 3.43 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
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

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

    - pytest
77

Gregory Ashton's avatar
Gregory Ashton committed
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
# test samplers on python 3.7
python-3.7-samplers:
  stage: test
  image: bilbydev/v2-dockerfile-test-suite-python37
  script:
    - python -m pip install .

    - pytest test/sampler_test.py --durations 10

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

    - pytest test/sampler_test.py

96 97 98
# Tests run at a fixed schedule rather than on push
scheduled-python-3.7:
  stage: test
Gregory Ashton's avatar
Gregory Ashton committed
99
  image: bilbydev/v2-dockerfile-test-suite-python37
100 101 102
  only:
    - schedules
  script:
103
    - python -m pip install .
104 105 106 107

    # Run tests which are only done on schedule
    - pytest test/example_test.py
    - pytest test/gw_example_test.py
Gregory Ashton's avatar
Gregory Ashton committed
108
    - pytest test/sample_from_the_prior_test.py
109

Colm Talbot's avatar
Colm Talbot committed
110 111 112 113 114 115 116 117 118 119 120
plotting:
  stage: test
  image: bilbydev/bilby-test-suite-python37
  only:
    - schedules
  script:
    - python -m pip install .
    - python -m pip install ligo.skymap

    - pytest test/gw_plot_test.py

Gregory Ashton's avatar
Gregory Ashton committed
121 122 123
pages:
  stage: deploy
  dependencies:
124
    - python-3.7
Gregory Ashton's avatar
Gregory Ashton committed
125
  script:
126
    - mkdir public/
Gregory Ashton's avatar
Gregory Ashton committed
127
    - mv htmlcov/ public/
128
    - mv coverage_badge.svg public/
129
    - mv docs/_build/html/* public/
Gregory Ashton's avatar
Gregory Ashton committed
130 131 132 133
  artifacts:
    paths:
      - public
    expire_in: 30 days
134 135
  only:
    - master
136 137 138 139 140 141 142 143 144 145 146 147 148 149

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