health_check.yml
Continuous integration workflow that validates code quality and runs tests.
Overview
File: .github/workflows/health_check.yml
Class: HealthCheckWorkflow in pyrig.dev.configs.workflows.health_check
Inherits: Workflow
The health check workflow is the first step in the CI/CD pipeline. It runs on every pull request, push to main, and daily on a staggered schedule. It validates code quality through linting, type checking, security scanning (code + dependencies), and comprehensive testing across multiple OS and Python versions.
Triggers
Pull Request
- Events:
opened,synchronize,reopened - Purpose: Validate changes before merging
Push
- Branches:
main - Purpose: Validate main branch after merge
Schedule
- Cron:
0 {hour} * * *(daily at staggered hour) - Staggering: Hour offset based on dependency depth to pyrig
- Purpose: Catch issues from dependency updates
Why staggered? If your package depends on pyrig, and pyrig releases at midnight, your package runs at 1 AM. This prevents failures when dependencies release right before your scheduled run and keeps all packages up to date at the same time if you have lots of packages depending in a line.
Workflow Dispatch
- Purpose: Manual trigger for testing
Job Flow
Jobs
1. health_checks
Runs on: Ubuntu latest Purpose: Runs quality checks and applies branch protection rules
This job runs independently from the test matrix to run quality checks that only need to run once (not per OS/Python version). It sets up the environment, runs pre-commit hooks, dependency audit, and applies the branch protection ruleset.
Step Flow:
Steps:
- Checkout Repository (
actions/checkout@main) -
Clones the repository code
-
Setup Version Control
- Configures git user as
github-actions[bot] -
Standardizes git identity for any future automated commits
-
Setup Package Manager (
astral-sh/setup-uv@main) - Installs uv package manager
-
Sets up the default Python version (latest supported)
-
Update Dependencies
-
Updates lock file:
uv lock --upgrade -
Install Dependencies
-
Installs dependencies:
uv sync -
Add Dependency Updates To Version Control
-
Stages
pyproject.tomlanduv.lock -
Run Pre Commit Hooks
- Runs
uv run pre-commit run --all-files - Executes: ruff (linting), ty (type checking), bandit (security), rumdl (markdown linting)
-
Fails if any hook fails
-
Run Dependency Audit
- Runs
uv run pip-audit -
Scans installed dependencies for known vulnerabilities
-
Protect Repository
- Runs
uv run pyrig protect-repo - Loads configuration from
branch-protection.json - Creates or updates branch protection ruleset on GitHub
- Requires
REPO_TOKENsecret
Why separate? Running quality checks as a separate job means they only run
once instead of per matrix combination. The health_check aggregator job (which
waits for both this job and the matrix) is the required status check for PRs.
2. matrix_health_checks
Runs on: Matrix of OS × Python versions
Strategy: fail-fast: true (stop all jobs if one fails)
Matrix:
- OS: Ubuntu, Windows, macOS (latest)
- Python: All versions from
pyproject.tomlrequires-python(e.g., 3.12, 3.13, 3.14)
Step Flow:
Steps:
- Checkout Repository (
actions/checkout@main) -
Clones the repository code
-
Setup Version Control
- Configures git user as
github-actions[bot] -
Required for commits in later workflows
-
Setup Package Manager (
astral-sh/setup-uv@main) - Installs uv package manager
-
Sets up Python from matrix version
-
Update Dependencies
- Updates lock file:
uv lock --upgrade -
Tests against the latest dependency versions resolved at workflow time
-
Install Dependencies
-
Installs dependencies:
uv sync -
Add Dependency Updates To Version Control
- Stages
pyproject.tomlanduv.lock -
Prepares for potential commit in release workflow
-
Run Tests
- Runs
uv run pytest --log-cli-level=INFO --cov-report=xml - Executes all tests with coverage measurement
- Generates
coverage.xmlreport -
Requires 90% coverage (from
pyproject.toml) -
Upload Coverage Report (
codecov/codecov-action@main) - Uploads
coverage.xmlto Codecov - Uses
CODECOV_TOKENsecret - Only fails CI if token is configured
Why matrix? Testing across OS and Python versions catches platform-specific bugs and ensures compatibility.
3. health_check
Runs on: Ubuntu latest
Needs: matrix_health_checks, health_checks (waits for both to complete)
Purpose: Aggregates job results into single job for branch protection
rules, you will see the purpose of this once you make a Pull Request and wait
for the checks to complete.
Steps:
- Aggregate Jobs
- Echoes aggregation message
- Provides single job status for GitHub branch protection
Why aggregate? GitHub branch protection can require this single job instead of tracking all matrix combinations and the health_checks job individually.
Environment Variables
- PYTHONDONTWRITEBYTECODE:
1(prevents.pycfiles) - UV_NO_SYNC:
1(prevents automatic sync on uv commands)
Required Secrets
- REPO_TOKEN: Fine-grained PAT with administration, contents, pages permissions
- CODECOV_TOKEN: Codecov upload token (recommended, required for private repos)
- See Getting Started - Codecov setup for details
Usage
Automatic Creation
uv run pyrig mkroot
Manual Trigger
GitHub Actions tab → Health Check → Run workflow
Best Practices
- Fix failures immediately: Health check blocks the entire pipeline
- Monitor coverage: Maintain 90% minimum coverage
- Check all matrix jobs: Don't ignore platform-specific failures
- Update dependencies regularly: Scheduled runs catch breaking changes early