Overview
This project uses GitHub Actions to automate continuous integration, testing, and security scanning. All workflows are located in.github/workflows/ and trigger automatically on relevant events.
Workflows run automatically on push and pull request events to ensure code quality and security before merging.
Available Workflows
CI Workflow
The primary CI workflow (ci.yml) runs on every push to main and on all pull requests. It handles installation, linting, testing, and security checks for Python projects.
Triggers:
- Push to
mainbranch - Pull requests targeting
mainbranch
Install Dependencies
Upgrades pip and wheel, then installs project dependencies from
pyproject.toml with dev extrasSecurity Workflow
The security workflow (security.yml) provides additional security scanning using Trivy to detect vulnerabilities in Docker images.
Triggers:
- Pull requests targeting
mainbranch
The security workflow only runs if a
Dockerfile exists in your repository. It’s automatically skipped for non-containerized projects.Customizing Workflows
Adding New Jobs
To add a new job to the CI workflow, extend thejobs section:
Changing Python Version
Update the Python version in.github/workflows/ci.yml:12:
Adding More Security Scans
Extend the security workflow with additional scanners:Configuring Branch Protection
To require workflows to pass before merging:Troubleshooting
CI workflow fails on mypy
CI workflow fails on mypy
The mypy static type checker may fail if type hints are missing or incorrect. To fix:
- Add type hints to your functions
- Configure mypy in
pyproject.toml:
Trivy scan finds vulnerabilities
Trivy scan finds vulnerabilities
When Trivy detects vulnerabilities:
- Review the scan output in the Actions tab
- Update base images in your Dockerfile
- Update vulnerable dependencies
- For unfixed vulnerabilities, document accepted risks
ignore-unfixed: true skips vulnerabilities without available patches.Workflow times out
Workflow times out
If workflows exceed the timeout limit:
- Add caching for dependencies:
- Parallelize jobs using matrix strategies
- Optimize test execution time
Workflow Badges
Add status badges to your README to display workflow status:YOUR_ORG and YOUR_REPO with your repository details.
Best Practices
Fast Feedback
Run fastest checks first (linting) before slower ones (tests)
Fail Fast
Remove
|| true from checks to catch issues earlyCache Dependencies
Use actions/cache to speed up subsequent runs
Secure Secrets
Store sensitive data in GitHub Secrets, never in code
Related Resources
- Pre-commit Hooks - Local checks before commits
- Templates - Issue and PR templates
- GitHub Actions Documentation