---
image: python

stages:
  - test
  - build
  - release

before_script:
  - apt update
  - env DEBIAN_FRONTEND=noninteractive apt install --yes --quiet python3-dev libldap2-dev libsasl2-dev libssl-dev slapd ldap-utils python3-poetry
  - poetry config virtualenvs.in-project true

cache:
  paths:
    - .venv

style:
  image: python:3.12
  stage: test
  script:
    - pip install pre-commit
    - pre-commit run --all-files --show-diff-on-failure

python39:
  image: python:3.9
  stage: test
  script:
    - poetry install --extras all
    - poetry run pytest

python310:
  image: python:3.10
  stage: test
  script:
    - poetry install --extras all
    - poetry run pytest

python311:
  image: python:3.11
  stage: test
  script:
    - poetry install --extras all
    - poetry run pytest

python312:
  image: python:3.12
  stage: test
  script:
    - poetry install --extras all
    - poetry run pytest

minversions:
  image: python:3.9
  stage: test
  script:
    - sed -i -E 's/"(\^|>=)([0-9\.]+)([^,]*)"/"==\2"/' pyproject.toml
    - sed -i -E 's/python = "==/python = "^/' pyproject.toml
    - poetry lock
    - poetry install --extras all
    - poetry run pytest

doc:
  image: python:3.12
  stage: test
  script:
    - poetry install --only doc
    - poetry run sphinx-build doc build/sphinx/html

coverage:
  image: python:3.12
  stage: test
  allow_failure: true
  script:
    - pip install coveralls pyyaml tomli
    - poetry install --extras all
    - poetry run pytest --cov --cov-fail-under=100 --cov-report term:skip-covered -n auto
    - coveralls