Skip to content
Snippets Groups Projects
.gitlab-ci.yml 5.68 KiB
Newer Older
Gregory Ashton's avatar
Gregory Ashton committed
# This script is an edited version of the example found at
# https://git.ligo.org/lscsoft/example-ci-project/blob/python/.gitlab-ci.yml
# Each 0th-indentation level is a job that will be run within GitLab CI
Gregory Ashton's avatar
Gregory Ashton committed
# 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
  - initial
Gregory Ashton's avatar
Gregory Ashton committed
  - test
Colm Talbot's avatar
Colm Talbot committed
  - docs
Gregory Ashton's avatar
Gregory Ashton committed
  - deploy

.test-python: &test-python
Colm Talbot's avatar
Colm Talbot committed
  stage: initial
  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"
    - python -c "import bilby.core.prior"
    - python -c "import bilby.core.sampler"
    - python -c "import bilby.gw"
    - python -c "import bilby.gw.detector"
    - python -c "import bilby.gw.sampler"
    - python -c "import bilby.hyper"
    - python -c "import cli_bilby"
    - for script in $(pip show -f bilby | grep "bin\/" | xargs -I {} basename {}); do
          ${script} --help;
      done

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

# test example on python 3.7
python-3.7:
Gregory Ashton's avatar
Gregory Ashton committed
  stage: test
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
  script:
    - python -m pip install .
Colm Talbot's avatar
Colm Talbot committed
    # temporary fix for broken astropy version
    - pip install pyerfa==1.7.1.1
Gregory Ashton's avatar
Gregory Ashton committed

    # Run pyflakes
    - flake8 .

Gregory Ashton's avatar
Gregory Ashton committed
    # Run tests and collect coverage data
    - pytest --cov=bilby --durations 10
    - coverage html
    - coverage-badge -o coverage_badge.svg -f
Colm Talbot's avatar
Colm Talbot committed
  artifacts:
    paths:
      - coverage_badge.svg
      - htmlcov/

docs:
Colm Talbot's avatar
Colm Talbot committed
  stage: docs
Colm Talbot's avatar
Colm Talbot committed
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
  script:
    # Make the documentation
Colm Talbot's avatar
Colm Talbot committed
    - apt-get -yqq install pandoc
    - python -m pip install .
Colm Talbot's avatar
Colm Talbot committed
    # temporary fix for broken astropy version
    - pip install pyerfa==1.7.1.1
Colm Talbot's avatar
Colm Talbot committed
    - 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
    - make clean
Gregory Ashton's avatar
Gregory Ashton committed
  artifacts:
    paths:
      - docs/_build/html/
Gregory Ashton's avatar
Gregory Ashton committed

Gregory Ashton's avatar
Gregory Ashton committed
# test example on python 3.8
python-3.8:
  stage: test
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python38
Gregory Ashton's avatar
Gregory Ashton committed
  script:
    - python -m pip install .
Colm Talbot's avatar
Colm Talbot committed
    # temporary fix for broken astropy version
    - pip install pyerfa==1.7.1.1
Gregory Ashton's avatar
Gregory Ashton committed

    - pytest

# test example on python 3.6
python-3.6:
  stage: test
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python36
  script:
    - python -m pip install .
Colm Talbot's avatar
Colm Talbot committed
    # temporary fix for broken astropy version
    - pip install pyerfa==1.7.1.1
# test samplers on python 3.7
python-3.7-samplers:
  stage: test
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
  script:
    - python -m pip install .
Colm Talbot's avatar
Colm Talbot committed
    # temporary fix for broken astropy version
    - pip install pyerfa==1.7.1.1
    - pytest test/integration/sampler_run_test.py --durations 10
    - pytest test/integration/sample_from_the_prior_test.py

# test samplers on python 3.6
python-3.6-samplers:
  stage: test
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python36
  script:
    - python -m pip install .
Colm Talbot's avatar
Colm Talbot committed
    # temporary fix for broken astropy version
    - pip install pyerfa==1.7.1.1
    - pytest test/integration/sampler_run_test.py
# Test containers are up to date
containers:
Colm Talbot's avatar
Colm Talbot committed
  stage: initial
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
  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

# Tests run at a fixed schedule rather than on push
scheduled-python-3.7:
  stage: test
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
    - python -m pip install .
Colm Talbot's avatar
Colm Talbot committed
    # temporary fix for broken astropy version
    - pip install pyerfa==1.7.1.1

    # Run tests which are only done on schedule
    - pytest test/integration/example_test.py
    - pytest test/integration/sample_from_the_prior_test.py
Colm Talbot's avatar
Colm Talbot committed
plotting:
  stage: test
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
Colm Talbot's avatar
Colm Talbot committed
  only:
    - schedules
  script:
    - python -m pip install .
    - python -m pip install ligo.skymap

Moritz Huebner's avatar
Moritz Huebner committed
    - pytest test/gw/plot_test.py
Colm Talbot's avatar
Colm Talbot committed
  stage: initial
  image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
  script:
    - python test/check_author_list.py
Gregory Ashton's avatar
Gregory Ashton committed
pages:
  stage: deploy
  dependencies:
Colm Talbot's avatar
Colm Talbot committed
    - docs
    - python-3.7
Gregory Ashton's avatar
Gregory Ashton committed
  script:
    - mkdir public/
Gregory Ashton's avatar
Gregory Ashton committed
    - mv htmlcov/ public/
    - mv coverage_badge.svg public/
    - mv docs/_build/html/* public/
Gregory Ashton's avatar
Gregory Ashton committed
  artifacts:
    paths:
      - public
    expire_in: 30 days

deploy_release:
  stage: deploy
  image: quay.io/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
Colm Talbot's avatar
Colm Talbot committed
  stage: initial
  image: quay.io/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