Skip to content
AITroveRead. Build. Understand.
Make this comfortable

Continuous integration: test the merge candidate

Last updated: 5 Oct 20266 min read
tutorial
BeginnerBy AITrove Editorial

Continuous integration is the practice of combining changes frequently and verifying the combined result. A CI pipeline should fail on a broken build, test failure, or violated policy, then report which check failed. It is not a production health monitor and cannot validate behavior that only appears after traffic reaches the service.

Operational decision

A dispatch API pipeline first checks formatting and types, then unit tests, then an integration test against a temporary database. Parallelize independent checks, but do not promote an image before every required result is known. Pin tool versions and dependency resolution so rerunning the same commit has interpretable results. The shell block shows the order within one job; a real runner needs isolated services, timeouts, cache keys, and explicit permissions. A flaky test should be repaired or quarantined with an owner and expiry rather than retried until it passes. Save a test report and the exact source commit for later diagnosis. A merge gate is effective only if the protected branch actually requires the job.

bash
set -euo pipefail
python -m ruff check src tests
python -m mypy src
python -m pytest -q tests/unit
python -m pytest -q tests/integration

Cost and verification

A full integration suite on every edit may increase queue time and discourage small changes. Keep a fast mandatory layer and schedule longer checks where they still block release when relevant. Caches lower compute cost but can hide stale dependencies; key them by lockfile and toolchain. Do not interpret a green unit suite as proof that migrations, deployment configuration, or external contracts are correct. Test reports should identify skipped tests as well as passed ones.

Common Mistakes

  • Do not let a flaky test pass by unlimited retry.
  • Do not package before required gates complete.
  • Do not forget to require the CI job in branch protection.

Connected lessons

Advanced follow-up

Advanced follow-up

Advanced follow-up

Related Prompt Engineering lesson: Prompt changes in CI: test the merge candidate.

devops
operations
Storage details