CI and Test Infrastructure
Eight operational guides for fast, isolated, observable, and secure test pipelines across GitHub Actions, containers, and Kubernetes.
Series Chapters (8)
Place CI Tests by Feedback Time, Cost and Solo Catches
The test pyramid says how many tests to write, not which CI stage should run them. Measure each layer's job time, billed minutes and the defects it caught alone, then move layers between pull request, merge queue and nightly in one GitHub Actions workflow.
Eliminate CI Test Data Collisions Across Jobs, Shards and Re-runs
Playwright's workerIndex, xdist's gw0 and JEST_WORKER_ID restart in every CI job, so matrix legs sharing a database collide. Build namespaces from run ID, attempt, job and worker, stay under PostgreSQL's 63-byte limit, claim each with an advisory lock, and sweep leaks.
Debug CI-Only Test Failures with Environment Evidence
A date test passed in India and failed on ubuntu-latest because the code asked the host what day it was. Record a fingerprint on both machines, diff it, and replay each CI value locally until one flips the result. Covers time zone, locale, the CI variable, shallow clones, case sensitivity and CPU count.
Cache CI Dependencies Without Hiding Lockfile Drift
A cache keyed on an unchanged lockfile can keep CI green while package.json drifts away from it. Cache the package store instead of node_modules, run npm ci or a frozen pnpm install on every hit, limit writes to trusted runs, and schedule a cache-mode: none job to prove the cold build.
Size CI Parallelism From Dependency Capacity, Not Runners
Four shards against a 24-connection PostgreSQL failed 43 of 48 tests in 0.4 seconds, the fastest run of the day. This guide sizes fan-out from the dependency's budget, shows why max-parallel bounds only one run, turns concurrency groups into queued slots, fences the database role, and tests where Playwright locks stop.
Retain CI Artifacts That Explain a Failure on Their Own
A red CI run should name the failing request and the server's reason from its artifacts alone. Upload JUnit XML on every non-cancelled run, a small bundle only on failure, set retention per artifact now that the repository setting also deletes run history, and scan traces for secrets that log masking never sees.
Secure CI with OIDC: Exact Trust Conditions and Job-Scoped Tokens
A trust policy of repo:acme/shop:* lets any branch or pull request in the repository assume the role. Sign GitHub-shaped tokens against a local JWKS to see which subjects each condition admits, why an environment subject still needs a branch rule, and how to keep id-token: write and fork code apart.
Measure CI Pipeline Reliability from First Attempts
A workflow that ends green 89% of the time can still fail 8.6% of runs for no code reason and queue for eight minutes in a bad week. Export runs and jobs with gh api, classify each run by its first attempt, and turn percentile and red-main thresholds into owned work items.