image: ligo/software:stretch

stages:
- test
- deploy

test:
  stage: test
  before_script:
  - echo $CI_COMMIT_SHA | cut -b1-8 > gitID.txt
  script:
  - apt-get update -qq
  - apt-get install -y -qq python3-yaml python3-scipy python3-matplotlib python3-ipython lalsimulation-python3 python3-pypdf2
  - git clone https://gitlab-ci-token:ci_token@git.ligo.org/gwinc/inspiral_range.git
  - export PYTHONPATH=inspiral_range
  - export MPLBACKEND=agg
  - for ifo in aLIGO Aplus Voyager CE1 CE2; do
  -     python3 -m gwinc $ifo -s $ifo.png
  - done
  - python3 -m gwinc.test -r gwinc_test_report.pdf
  after_script:
  - rm gitID.txt
  cache:
    key: "$CI_PROJECT_NAMESPACE:$CI_PROJECT_NAME:$CI_JOB_NAME"
    untracked: true
  artifacts:
    when: always
    expire_in: 4w
    paths:
    - aLIGO.png
    - Aplus.png
    - Voyager.png
    - CE1.png
    - CE2.png
    - gwinc_test_report.pdf

pages:
  stage: deploy
  dependencies:
  - test
  script:
  - mkdir public
  - for ifo in aLIGO Aplus Voyager CE1 CE2; do
  -     mv $ifo.png public/
  - done
  - mv gwinc_test_report.pdf public/ || true
  - apt-get install -y -qq python3-pip python3-dev make
  - pip3 install sphinx sphinx-rtd-theme
  - cd docs
  - make html
  - cd ..
  - mv ./build/sphinx/html/* public/

  artifacts:
    paths:
    - public
    expire_in: 4w
  only:
  - master