name: Test
on:
- push
- pull_request
jobs:
  check:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: actions/cache@v3
      with:
        path: ~/.cache/pip
        key: pip-${{ hashFiles('requirements/check.txt') }}
    - uses: actions/setup-python@v4
      with:
        python-version: "3.7"
    - run: pip3 install -r requirements/check.txt
    - run: pip3 install -e .
    - run: make proto
    - run: flake8
    - run: mypy grpclib examples
  test:
    needs: check
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
    steps:
    - uses: actions/checkout@v4
    - uses: actions/cache@v3
      with:
        path: ~/.cache/pip
        key: pip-${{ matrix.python-version }}-${{ hashFiles('requirements/test.txt') }}
    - uses: actions/setup-python@v4
      with:
        python-version: ${{ matrix.python-version }}
    - run: pip3 install -r requirements/test.txt
    - run: pip3 install -e .
    - run: pytest
