---
# Add plugins by changing INSTALL_PYTEST_PLUGINS.
# See https://docs.pytest.org/en/latest/reference/plugin_list.html for available plugins
include:
  - remote: https://jobs.just-ci.dev/v9.0.1/python/generic.yml

variables:
  PYTEST_COVERAGE_THRESHOLD: "25"
  PYTEST_INSTALL_PLUGINS: "" # See https://docs.pytest.org/en/latest/reference/plugin_list.html
  PYTEST_DEFAULT_ARGS:
    -vvv --capture=tee-sys -o log_cli=true -o log_cli_level=DEBUG --color=yes
  PYTEST_EXTRA_ARGS: ""
  PYTEST_INVOCATION: python3 -m pytest # Can be changed to "pytest"
  PYTEST_TARGET: .

python:pytest:
  extends: .python:pre-install
  variables:
    JOB_PACKAGE: pytest pytest-cov ${PYTEST_INSTALL_PLUGINS}
  script:
    - !reference [".python:pre", script]
    - !reference [".python:pre-install", script]
    - ${PYTEST_INVOCATION} --version
    - ${PYTEST_INVOCATION} --cov=${PYTEST_COVERAGE_PATH:-${PYTHON_PACKAGE:-.}}
      --cov-fail-under=${PYTEST_COVERAGE_THRESHOLD}
      --junitxml=${CI_PROJECT_DIR}/pytest-report.xml --cov-report
      xml:${CI_PROJECT_DIR}/pytest-coverage.xml -p no:cacheprovider
      ${PYTEST_DEFAULT_ARGS} ${PYTEST_EXTRA_ARGS} ${PYTEST_TARGET:-.}
  coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
  artifacts:
    reports:
      junit: pytest-report.xml
      coverage_report:
        coverage_format: cobertura
        path: pytest-coverage.xml
