stages:
  - quality
  - test
  - build

ruff:
  stage: quality
  image: python:3.12
  script:
    - pip install ruff
    - ruff check

black:
  stage: quality
  image: python:3.12
  script:
    - pip install black
    - black .

test:
  stage: test
  image: python:3.12
  coverage: /TOTAL.+?(\d+%)/
  script:
    - pip install --no-cache -r requirements.txt -r requirements-test.txt
    - pytest --cov --cov-report term-missing

build:
  stage: build
  image: quay.io/podman/stable:v4
  rules:
    - if: $CI_COMMIT_TAG
  variables:
    CONTAINER_IMAGE_NAME: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
  script:
    - echo "$CI_REGISTRY_PASSWORD" | podman login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin
    - podman build -t $CONTAINER_IMAGE_NAME .
    - podman push $CONTAINER_IMAGE_NAME
