Module 7: CI Integration with GitHub Actions
Module 7: CI Integration with GitHub Actions
Module 7: CI Integration with GitHub Actions
Capsule overview
You have a complete test suite. Unit tests, integration tests, E2E tests, mocks, fixtures, coverage ≥90%. But if those tests only run when you execute pytest manually on your laptop, eventually you stop running them. A deadline squeezes you, "just this one push without tests", and suddenly you have bugs in production that your tests would have caught.
CI (Continuous Integration) solves this. The tests run automatically on every push, on every PR, without exception. If a test fails, the pipeline blocks the merge — no broken code reaches main. It's the guarantee that your tests matter.
This module connects everything you built in the previous modules with GitHub Actions. Claude Code generates the workflow YAML, you configure triggers, matrix testing, and caching. By the end, your repository has professional CI: automatic tests, coverage reports, and protection against unsafe merges.
Module Context
Where are we?
This is Module 7 — the first of Phase 3 (Final Project).
What you already know (Phases 1 and 2):
- ✅ Spec-first, unit tests, the test pyramid (Phase 1)
- ✅ The TDD workflow, coverage, mocking, validation loops (Phase 2)
What's missing: Automating the test execution and preparing the final project.
Where are we headed?
Phase 1: TDD Fundamentals with AI ✅
Phase 2: Testing Workflows ✅
Phase 3: Final Project
├── Module 7: ← YOU ARE HERE — CI with GitHub Actions
└── Module 8: → A TDD-complete capstone project
After this module, all that's left is the final project where you integrate absolutely everything.
Professional Objective
Configure a CI pipeline with GitHub Actions that automatically runs your whole test suite on every push and PR.
By the end of this module you'll be able to:
- ✅ Write a GitHub Actions YAML workflow for pytest
- ✅ Configure triggers: push, pull_request, workflow_dispatch
- ✅ Use matrix testing for multiple Python versions
- ✅ Publish coverage reports as artifacts
- ✅ Implement caching of pip dependencies
- ✅ Configure fail-fast to block unsafe merges
- ✅ Generate the workflow YAML with Claude Code
Module Progression
Module Map
| Capsule | Topic | What you'll learn |
|---|---|---|
| 02 | GitHub Actions fundamentals | Workflows, jobs, steps, runners, YAML syntax |
| 03 | pytest in CI | Running pytest in GitHub Actions, reporting, artifacts |
| 04 | Matrix testing and caching | Multiple Python versions, pip caching, optimization |
| 05 | Coverage in CI and protections | Coverage reports, branch protection, fail-fast |
| 06 | Project: A working CI pipeline | A complete pipeline with tests, coverage, matrix, caching |
Learning flow
First you'll understand the fundamentals of GitHub Actions (capsule 02): how workflows work, what a job is, what steps are, and the YAML syntax.
Then you'll integrate pytest (capsule 03): running your existing tests in CI, seeing the results, publishing reports.
Next you'll optimize (capsule 04): matrix testing to validate on multiple Python versions and caching for fast builds.
Capsule 05 adds coverage and protections: coverage reports in CI, branch protection rules, and fail-fast.
In the project (capsule 06) you'll build a complete, working pipeline for a real repository.
Project Connection
This module's project: A working CI pipeline
You'll configure GitHub Actions for a repository with the test suite you built in the previous modules. The pipeline includes:
- Automatic tests on push and PR
- Matrix testing (Python 3.10, 3.11, 3.12)
- A coverage report published as an artifact
- pip caching for fast builds
- Branch protection that blocks the merge if the tests fail
Connection with the final project (Module 8)
The final project requires a working CI as part of the delivery. The pipeline you configure here is the one you'll use for Module 8's application.
Boundaries: What This Module Will NOT Do
- ❌ CD (Continuous Deployment) — CI only: automatic tests, not deployment
- ❌ Docker in CI — We don't use containers for tests
- ❌ Other CI providers — GitHub Actions only
- ❌ Advanced infrastructure — No Kubernetes, no cloud deployment
- ❌ Deep pre-commit hooks — We mention them but don't go deep
Evidence of Success
By the end of this module, you'll know you succeeded if:
- ✅ Your repository has a workflow that runs on every push
- ✅ The tests run on at least 2 Python versions
- ✅ The coverage report is generated automatically
- ✅ A PR with failing tests is blocked
- ✅ The pipeline uses caching and takes <3 minutes
Summary
- ✅ CI guarantees that your tests run on every push — without exception
- ✅ GitHub Actions is the standard for CI in GitHub projects
- ✅ Matrix testing validates on multiple Python versions
- ✅ Coverage in CI makes your test suite's quality visible
- ✅ Claude Code can generate the workflow YAML based on your project
- ✅ This module prepares the final project's CI
Next capsule: GitHub Actions Fundamentals — workflows, jobs, steps, YAML.
Additional Resources
- GitHub Actions Documentation - Official documentation
- GitHub Actions for Python - CI for Python
- pytest with GitHub Actions - pytest + CI integration
- GitHub Branch Protection - Branch protection
Module 7 — Testing with Claude Code Guide From local tests to professional automation