.gitlab-ci.yml 2.58 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.sampler"
28
    - python -c "import bilby.gw"
29 30
    - python -c "import bilby.gw.detector"
    - python -c "import bilby.gw.sampler"
31 32
    - python -c "import bilby.hyper"
    - python -c "import cli_bilby"
33 34 35
    - for script in $(pip show -f bilby | grep "bin\/" | xargs -I {} basename {}); do
          ${script} --help;
      done
36 37 38 39 40 41 42 43 44 45 46

# test basic setup on python2
basic-2.7:
  <<: *test-python
  image: python:2.7

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

47
# test example on python 3.7
48
python-3.7:
Gregory Ashton's avatar
Gregory Ashton committed
49
  stage: test
50
  image: 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
Colm Talbot's avatar
Colm Talbot committed
58
    - pytest --cov=bilby
59 60
    - coverage html
    - coverage-badge -o coverage_badge.svg -f
61 62 63

    # Make the documentation
    - cd docs
Gregory Ashton's avatar
Gregory Ashton committed
64
    - make clean
65 66
    - make html

Gregory Ashton's avatar
Gregory Ashton committed
67 68 69
  artifacts:
    paths:
      - htmlcov/
70
      - coverage_badge.svg
71
      - docs/_build/html/
Gregory Ashton's avatar
Gregory Ashton committed
72

73
# test example on python 3.6
74 75 76 77 78 79 80
#python-3.6:
#  stage: test
#  image: bilbydev/v2-dockerfile-test-suite-python36
#  script:
#    - python -m pip install .
#
#    - pytest
81

82 83 84 85 86 87 88
# Tests run at a fixed schedule rather than on push
scheduled-python-3.7:
  stage: test
  image: bilbydev/bilby-test-suite-python37
  only:
    - schedules
  script:
89
    - python -m pip install .
90 91 92 93

    # 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
94
    - pytest test/sample_from_the_prior_test.py
95

Gregory Ashton's avatar
Gregory Ashton committed
96 97 98
pages:
  stage: deploy
  dependencies:
99
    - python-3.7
Gregory Ashton's avatar
Gregory Ashton committed
100
  script:
101
    - mkdir public/
Gregory Ashton's avatar
Gregory Ashton committed
102
    - mv htmlcov/ public/
103
    - mv coverage_badge.svg public/
104
    - mv docs/_build/html/* public/
Gregory Ashton's avatar
Gregory Ashton committed
105 106 107 108
  artifacts:
    paths:
      - public
    expire_in: 30 days
109 110
  only:
    - master