1. The discipline of continuous integration #
More than a build server.
The rules #
- Everyone integrates into the main branch at least once a day.
- Every integration triggers an automatic build and tests.
- The build is fast: less than 10 minutes for the commit stage.
- A broken build is fixed immediately, taking priority over everything else.
- Everyone can see the build status and get the latest artifact.
Key takeaway: Having Jenkins or GitHub Actions is not enough: branches that live three weeks without integration are not continuous integration, even with a pipeline.
2. Tests #
The safety net of CI/CD.
The pyramid #
| Type | Checks | Tools (examples) |
|---|---|---|
| Unit | an isolated function or class | pytest, JUnit, Jest, go test |
| Integration | the code with a real database, a real queue | Testcontainers, docker compose |
| Contract | that an API provider meets what its consumers expect | Pact, OpenAPI schemas |
| End-to-end | a complete user journey | Playwright, Cypress |
| Performance | response times and behavior under load | k6, Gatling |
| Security | code, dependencies, images | Semgrep, Trivy, OWASP ZAP |
Realistic integration tests #
# pytest + Testcontainers : une vraie base PostgreSQL éphémère pour chaque exécution
from testcontainers.postgres import PostgresContainer
import psycopg
def test_insertion_commande():
with PostgresContainer("postgres:16") as pg:
with psycopg.connect(pg.get_connection_url().replace("+psycopg2", "")) as conn:
conn.execute("CREATE TABLE commandes (id serial, total numeric)")
conn.execute("INSERT INTO commandes (total) VALUES (42)")
assert conn.execute("SELECT count(*) FROM commandes").fetchone()[0] == 1Flaky tests #
A test that fails « sometimes » destroys trust: the team reruns the pipeline without reading the error, and ends up ignoring a real problem.
Good practice: Quarantine a flaky test (marked, non-blocking) with a ticket, fix it quickly (explicit waits, isolated data, mocked clock) and track the pipeline rerun rate.
3. Quality and quality gates #
Automatic rules, not debates in review.
Static analysis #
ruff check . && ruff format --check . # Python : lint et formatage
mypy src/ # typage
eslint . && prettier --check . # JavaScript
hadolint Dockerfile # bonnes pratiques Dockerfile
shellcheck scripts/*.sh
gitleaks detect --source . # secrets commitésQuality gate #
A quality gate is a set of blocking conditions (SonarQube, branch protection rules). Measure coverage of new code rather than a global percentage: requiring 80% on a codebase at 30% blocks everything and pushes people to write hollow tests.
Common mistake: Coverage measures the code executed by tests, not the quality of the assertions: a test without assertions « covers » code without checking anything.
4. A fast pipeline #
Keeping feedback under 10 minutes.
Techniques #
| Technique | Effect |
|---|---|
| Dependency cache | avoids re-downloading at each build |
| Parallelizing and splitting tests | divides duration by the number of runners |
| Matrix | tests several versions (language, OS) in parallel |
| Selective execution | run only what is affected (monorepo: changed paths) |
| Docker layer cache | rebuilds only changed layers |
| Cancelling obsolete builds | a new push cancels the previous pipeline of the same branch |
jobs:
test:
strategy:
matrix:
python: ["3.11", "3.12", "3.13"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with: { python-version: "${{ matrix.python }}", cache: pip }
- run: pip install -r requirements.txt && pytest -q -n auto # pytest-xdist
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: trueMy progress
Sign in to track your progress and take notes. Sign in
💬 Questions about this lesson
No questions yet: be the first to ask for help or share your configuration.
Recommended Articles
DevSecOps: securing the software supply chain end to end
Integrate security into the DevOps pipeline: shift-left, threat modeling, secret detection, SAST,...
Infrastructure as Code and GitOps: Terraform, Ansible and Argo CD
Manage infrastructure as code: declarative or imperative, Terraform (providers, state, plan, modu...
Git for DevOps: branches, code reviews and versions
Organize work with Git in a DevOps approach: trunk-based development or GitFlow, short-lived bran...
Load testing with Grafana k6: why, and which types of tests
Why test performance before production, the types of tests (smoke, load, stress, spike, soak, bre...
Observability, SRE and incident management for DevOps teams
Operate what you ship: metrics, logs and traces, golden signals, SLIs, SLOs and error budgets, ac...
Ansible best practices: structure, idempotence, security and quality
Ansible best practices: project organization, naming, FQCN, idempotence, modules rather than shel...
Platform engineering, FinOps and AI: the new frontiers of DevOps
Understand how DevOps is evolving: platform engineering and internal developer platforms (IDP), g...
DevOps variants: understanding how engineering culture has evolved
Discover the different flavors of DevOps: DevSecOps, AIOps, NoOps, GitOps and FinOps. Understand ...
Organizing DevOps: value streams, teams and a blameless culture
Set up a DevOps organization: value chain and value stream mapping, Team Topologies, « you build ...