stages:
  - test

variables:
  PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"

cache:
  paths:
    - .cache/pip
    - .venv/

test:
  stage: test
  tags:
    - build
  image: python:3.11
  before_script:
    - python3 -m venv .venv
    - source .venv/bin/activate
    - pip install --upgrade pip
    - pip install -r requirements.txt
    - pip install pytest pytest-asyncio
  script:
    - source .venv/bin/activate
    - python3 -m pytest tests/ -v --tb=short
  rules:
    - if: $CI_PIPELINE_SOURCE == "push"
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
