stages:
  - test
  - tag

test:
  stage: test
  image: python:3.12-slim
  before_script:
    - pip install uv
  script:
    - uv sync
    - uv run pytest web/tests/ -x -q -p no:faulthandler
    - uv run ruff check web/src/ web/tests/
  rules:
    - if: $CI_COMMIT_BRANCH == "master"
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"

tag:
  stage: tag
  image:
    name: alpine/git
    entrypoint: [""]
  script:
    - git tag "v${CI_PIPELINE_IID}"
    - git push "https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git" "v${CI_PIPELINE_IID}"
  rules:
    - if: $CI_COMMIT_BRANCH == "master"

# Deployment is handled by the on-server supervisor (src/padelnomics/supervisor.py).
# It polls git every 60s, fetches tags, and deploys only when a new passing tag exists.
# No CI secrets needed — zero SSH keys, zero deploy credentials.
