name: Lint and Test

on:
  pull_request:
    branches: [main]
  push:
    branches: [main]

jobs:
  lint_and_typecheck:
    name: lint and typecheck
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: install poetry and dependencies
        run: |
          python3 -m pip install --user pipx
          python3 -m pipx ensurepath
          pipx install poetry==1.7
          poetry install
      - name: lint
        run: poetry run ruff check .
      - name: typecheck
        run: poetry run mypy snap_http/

  unit_test:
    name: tox unit test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: install poetry and dependencies
        run: |
          python3 -m pip install --user pipx
          python3 -m pipx ensurepath
          pipx install poetry==1.7
          poetry install
      - name: install additional python versions
        run: |
          sudo add-apt-repository ppa:deadsnakes/ppa
          sudo apt install -y python3.8 python3.9 python3.10 python3.11 python3.12
          sudo apt install -y python3.8-distutils python3.9-distutils
      - name: tox unit test
        run: poetry run tox

  integration_test:
    uses: ./.github/workflows/integration-test.yml
