Skip to content

docs: modular backend and serializer documentation #184

docs: modular backend and serializer documentation

docs: modular backend and serializer documentation #184

Workflow file for this run

name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
permissions:
contents: read
pull-requests: read
checks: write
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
REDIS_DISABLE_HIREDIS: true
DEFAULT_PYTHON_VERSION: "3.12"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# Lint, format, type check (runs on all events)
quick-check:
name: Format & Lint
runs-on: cachekit
timeout-minutes: 10
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
with:
workspaces: rust
- name: Cache Python virtual environment
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
path: .venv
key: venv-${{ runner.os }}-py${{ env.DEFAULT_PYTHON_VERSION }}-${{ hashFiles('**/pyproject.toml', '**/uv.lock', 'rust/**/*.rs', 'rust/**/Cargo.toml') }}
restore-keys: |
venv-${{ runner.os }}-py${{ env.DEFAULT_PYTHON_VERSION }}-
- name: Install dependencies (if not cached)
run: uv sync --python ${{ env.DEFAULT_PYTHON_VERSION }} --group dev
- name: Check Python formatting
run: uv run ruff format --check .
- name: Lint Python
if: success() || failure()
run: uv run ruff check .
- name: Type check Python
if: success() || failure()
run: uv run basedpyright --level error
- name: Check Rust formatting
if: success() || failure()
run: cd rust && cargo fmt --check
- name: Lint Rust
if: success() || failure()
run: cd rust && cargo clippy -- -D warnings
# PR: single Python version, critical tests only
# Push: full matrix, full test suite
test:
name: Tests (Python ${{ matrix.python-version }})
runs-on: cachekit
timeout-minutes: 15
permissions:
contents: read
id-token: write # Required for Codecov OIDC
strategy:
fail-fast: false
matrix:
python-version: ${{ github.event_name == 'push' && fromJSON('["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]') || fromJSON('["3.12"]') }}
services:
redis:
image: redis@sha256:4bfd9eca23339865dc14fe75f6d9ae643f714924623978dd2798f1a673b08f43 # redis:7-alpine amd64
credentials:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
with:
workspaces: rust
- name: Cache Python virtual environment
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
path: .venv
key: venv-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml', '**/uv.lock', 'rust/**/*.rs', 'rust/**/Cargo.toml') }}
restore-keys: |
venv-${{ runner.os }}-py${{ matrix.python-version }}-
- name: Install dependencies (if not cached)
run: uv sync --python ${{ matrix.python-version }} --group dev
- name: Run critical tests (PRs)
if: github.event_name == 'pull_request'
env:
REDIS_URL: redis://localhost:6379
run: |
uv run pytest tests/critical/ -m "not slow" \
--cov=src/cachekit \
--cov-report=xml \
--cov-report=term \
--junitxml=junit.xml \
-o junit_family=legacy
- name: Run full test suite (main)
if: github.event_name == 'push'
env:
REDIS_URL: redis://localhost:6379
run: |
uv run pytest tests/ -m "not slow" \
--ignore=tests/fuzzing \
--ignore=tests/integration/saas \
--cov=src/cachekit \
--cov-report=xml \
--cov-report=term \
--junitxml=junit.xml \
-o junit_family=legacy
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # v5
with:
files: ./coverage.xml
use_oidc: true
fail_ci_if_error: false
flags: ${{ github.event_name == 'push' && 'full' || 'critical' }}-python-${{ matrix.python-version }}
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # v5
with:
files: ./junit.xml
report_type: test_results
use_oidc: true
flags: ${{ github.event_name == 'push' && 'full' || 'critical' }}-python-${{ matrix.python-version }}
fail_ci_if_error: false
# Version sync + doc tests (push to main only)
post-merge:
name: Post-Merge Checks
if: github.event_name == 'push'
runs-on: cachekit
timeout-minutes: 10
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Check Python ↔ Rust version consistency
run: |
PYTHON_VERSION=$(grep -E "^version = " pyproject.toml | head -1 | cut -d'"' -f2)
RUST_VERSION=$(grep -E "^version = " rust/Cargo.toml | head -1 | cut -d'"' -f2)
if [ "$PYTHON_VERSION" != "$RUST_VERSION" ]; then
echo "Version mismatch: Python=$PYTHON_VERSION Rust=$RUST_VERSION"
exit 1
fi
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
with:
workspaces: rust
- name: Install dependencies (if not cached)
run: uv sync --python ${{ env.DEFAULT_PYTHON_VERSION }} --group dev
- name: Scan Python dependencies for CVEs
run: uv run pip-audit --desc
- name: Run markdown documentation tests
run: make test-docs-examples
# Summary job (required for branch protection)
ci-success:
name: CI Success
runs-on: ubuntu-latest
needs: [quick-check, test]
if: always()
steps:
- name: Check all jobs succeeded
run: |
if [[ "${{ needs.quick-check.result }}" != "success" ]] || \
[[ "${{ needs.test.result }}" != "success" ]]; then
echo "One or more jobs failed"
exit 1
fi
echo "All CI checks passed"