| name: Tests | |
| on: [push, pull_request] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:15 | |
| env: | |
| POSTGRES_DB: fair_dispatch_test | |
| POSTGRES_USER: test | |
| POSTGRES_PASSWORD: test | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| pip install -r requirements.txt | |
| pip install pytest pytest-asyncio pytest-xdist pytest-cov httpx faker factory-boy | |
| - name: Run tests | |
| env: | |
| TEST_DATABASE_URL: postgresql+asyncpg://test:test@localhost:5432/fair_dispatch_test | |
| run: | | |
| pytest tests/ -n auto --cov=app --cov-report=xml --cov-fail-under=90 | |
| - name: Upload coverage | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| file: coverage.xml | |