Skip to content

test: harden smoke script dependency detection & install SQLAlchemy/a… #4

test: harden smoke script dependency detection & install SQLAlchemy/a…

test: harden smoke script dependency detection & install SQLAlchemy/a… #4

Workflow file for this run

name: Full Tests & Pre-commit Cache
on:
workflow_dispatch:
pull_request:
branches: [ main, master ]
push:
branches: [ main ]
concurrency:
group: full-tests-${{ github.ref }}
cancel-in-progress: true
jobs:
precommit-cache-and-smoke:
name: Pre-commit (cached) + Smoke
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Restore pre-commit cache
id: pc-cache
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
pre-commit-${{ runner.os }}-
- name: Install project minimal (dev tools for mypy/ruff only)
run: |
python -m pip install --upgrade pip
pip install -e .[dev-tools]
- name: Run pre-commit (all files)
run: pre-commit run --show-diff-on-failure --color=always --all-files
- name: Save updated pre-commit cache
if: always()
uses: actions/cache/save@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Smoke tests (pytest-quick script)
env:
DATABASE_URL: "sqlite+aiosqlite:///:memory:"
run: bash scripts/pytest_quick.sh
full-test:
name: Full Test Matrix
runs-on: ubuntu-latest
needs: precommit-cache-and-smoke
strategy:
fail-fast: false
matrix:
python-version: [ '3.12' ]
db-backend: [ sqlite, postgres ]
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: testdb
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U postgres" --health-interval=5s --health-timeout=5s --health-retries=6
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies (full)
run: |
python -m pip install --upgrade pip
pip install -e .[dev-tools]
pip install coverage pytest-asyncio asyncpg aiosqlite
- name: Wait for Postgres (if needed)
if: matrix.db-backend == 'postgres'
run: |
for i in {1..40}; do pg_isready -h localhost -p 5432 -U postgres && break || sleep 1; done
- name: Run tests with coverage
env:
DATABASE_URL: ${{ matrix.db-backend == 'postgres' && 'postgresql+asyncpg://postgres:postgres@localhost:5432/testdb' || 'sqlite+aiosqlite:///:memory:' }}
run: |
coverage run -m pytest -q
coverage xml -i
coverage report -m
- name: Upload coverage (matrix)
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.db-backend }}
path: coverage.xml
if-no-files-found: error
aggregate-coverage:
name: Aggregate Coverage
runs-on: ubuntu-latest
needs: full-test
steps:
- name: Download coverage artifacts
uses: actions/download-artifact@v4
with:
pattern: coverage-*
path: coverages
merge-multiple: true
- name: Combine coverage (placeholder)
run: |
echo "(Optional) combine coverage reports here if multi-python in future"
- name: List artifacts
run: ls -R coverages