image: python:3.9

stages:
  - linting
  - testing

before_script:
  - pip install poetry
  - poetry config virtualenvs.in-project true  # used to cache packages
  - poetry install
  - sh pipeline_utils/check_for_gpu.sh  # check if runner is able to access CUDA


cache:
  paths:
    - $CI_PROJECT_DIR/.venv

black:
  stage: linting
  allow_failure: true
  script:
    - poetry run black --check --diff --color ./rt_search_based
    - poetry run black --check --diff --color ./tests

prospector:
  stage: linting
  allow_failure: true
  script:
    - poetry run prospector -w bandit -w mypy -s low -A -u flask -W mccabe

tests:
  stage: testing
  script:
    - poetry run coverage run -m pytest ./tests/
  after_script:
    - poetry run coverage report --include="rt_search_based/*"
    - poetry run coverage xml
  coverage: '/TOTAL.*\s+(\d+\%)/'
  artifacts:
    reports:
      coverage_report:
        coverage_format: cobertura
        path: coverage.xml

