image: python:3.12

definitions:
  caches:
    poetry: ~/.cache/pypoetry

pipelines:
  default:
    - step:
        name: Test
        caches:
          - pip
          - poetry
        script:
          # Install Poetry
          - curl -sSL https://install.python-poetry.org | python3 -
          - export PATH="/root/.local/bin:$PATH"

          # Verify Poetry installation
          - poetry --version

          # Install dependencies
          - poetry install --with dev

          # Run tests
          - poetry run pytest -v --tb=short

          # Optional: Run linting/type checking if you add them later
          # - poetry run ruff check .
          # - poetry run mypy .

  branches:
    main:
      - step:
          name: Test on Main
          caches:
            - pip
            - poetry
          script:
            # Install Poetry
            - curl -sSL https://install.python-poetry.org | python3 -
            - export PATH="/root/.local/bin:$PATH"

            # Verify Poetry installation
            - poetry --version

            # Install dependencies
            - poetry install --with dev

            # Run tests with coverage
            - poetry run pytest -v --tb=short

            # Optional: Generate coverage report
            # - poetry run pytest --cov=. --cov-report=term-missing

      - step:
          name: Build Standalone Package
          script:
            # Build standalone distributable for Linux x86_64
            - chmod +x build_standalone_linux.sh
            - ./build_standalone_linux.sh
          artifacts:
            - dist/*.tar.gz

  pull-requests:
    '**':
      - step:
          name: Test PR
          caches:
            - pip
            - poetry
          script:
            # Install Poetry
            - curl -sSL https://install.python-poetry.org | python3 -
            - export PATH="/root/.local/bin:$PATH"

            # Verify Poetry installation
            - poetry --version

            # Install dependencies
            - poetry install --with dev

            # Run tests
            - poetry run pytest -v --tb=short
