before_script:
  - export GIT_SSL_NO_VERIFY=1
  - export PATH="$HOME/miniconda2/bin:$PATH"

stages:
  - prepare
  - docs
  - test
  - report
  - clean

cache:
  paths:
    - test/coverage.xml
    - test/unit/files

prepare:
  stage: prepare
  script:
    - git submodule sync --recursive
    - git submodule update --init --recursive
    - conda update -n base -c defaults conda
    - conda update conda
    - conda install -n autosubmit3 coverage=6
    - conda env update -f environment.yml -n autosubmit3 python=3.7.3

test_python3:
  stage: test
  script:
    - conda activate autosubmit3
    - python3 -m 'nose' --exclude=regression  --verbosity=3 test/unit --with-coverage --cover-package=autosubmit --cover-inclusive --cover-xml --cover-xml-file=test/coverage.xml
  coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
  # These artifacts are saved with every build in GitLab and can be reviewed later. If
  # we have a folder with HTML files, as in this example, users can navigate with their
  # browser.
  artifacts:
    reports:
      coverage_report:
        coverage_format: cobertura
        path: test/coverage.xml

# FIXME: Our GitLab worker has 3.7, but pydata-sphinx-theme requires 3.8+
# docs:
#   stage: docs
#   script:
#     - conda activate autosubmit3
#     - pip install -e .
#     - cd docs
#     - pip install -r requirements.txt
#     - make html


clean:
  stage: clean
  script:
    - conda clean --all --yes
