stages:
  - test

variables:
  PYTHONDONTWRITEBYTECODE: 1
  PYTHONPATH: "./:./UntappdUniques:./tests"
  TZ: Australia/Sydney
  
  # UV
  UV_VERSION: 0.6.3
  PYTHON_VERSION: 3.13
  BASE_LAYER: bookworm-slim
  # GitLab CI creates a separate mountpoint for the build directory,
  # so we need to copy instead of using hard links.
  UV_LINK_MODE: copy

before_script:
  - uname -a
  - python --version
  - uv --version
  - set -u
  - export UV_INDEX="https://__token__:${GITLAB_PYPI_PAT}@gitlab.com/api/v4/projects/23576087/packages/pypi/simple"

test-with-uv:
  image: ghcr.io/astral-sh/uv:$UV_VERSION-python$PYTHON_VERSION-$BASE_LAYER
  variables:
    UV_CACHE_DIR: .uv-cache
  cache:
    - key:
        files:
          - uv.lock
          - .venv
      paths:
        - $UV_CACHE_DIR

  stage: test
  script:
    # - env | sort
    # Your `uv` commands
    - uv sync --group test
    # - uv pip list
    - uv run coverage run -m pytest # Run all tests
    - uv run coverage xml
    - uv run coverage report
    # recommended to reduce cache size
    - uv cache prune --ci
  coverage: '/TOTAL.*\s+(\d+%)/'