iDevelop Solutions
ci

A CI Pipeline That Earns Its Keep

A pipeline nobody trusts is worse than none at all: it costs minutes on every push and teaches the team to press retry. Four reliable steps beat twenty flaky ones.

What continuous integration actually means

Continuous integration is the practice of merging everyone's work into a shared mainline frequently, and checking each merge with an automated build and test run. The automation is the visible half, but the frequency is the half doing the real work: a branch that lives for an afternoon rarely conflicts with anyone, and one that lives for a month usually conflicts with everyone.

It is worth separating the idea from the product. A hosted pipeline is a convenience; the discipline is small changes, integrated often, verified by something other than the author's memory. Build automation, meaning compiling, packaging and checking by machine rather than by hand, is what makes that verification cheap enough to repeat on every push.

Run the same command the pipeline runs

If the only way to learn whether a change passes is to push it and wait, your feedback loop now includes a queue, a network and somebody else's capacity. Put the real sequence in a script in the repository, and have the pipeline call that script instead of listing ten steps in its own configuration.

#!/bin/sh
set -eu

./scripts/install-deps   # from the lockfile
./scripts/lint           # check mode, no rewriting
./scripts/test           # the fast suite only

Two things follow from that. You can reproduce a pipeline failure on your own machine, which is the difference between a five-minute fix and an afternoon of push-and-pray. And the steps are version-controlled beside the code they check, so a change that needs a new step carries it along.

What the first pipeline should do

  1. Install dependencies from the lockfile, not from the manifest.
  2. Run the formatter and linter in check mode, so they fail rather than quietly rewrite.
  3. Run the fast test suite.
  4. Build the deployable artefact, even if nothing is deployed yet.

Resist adding anything else until those four pass reliably on every branch. A pipeline that does four things people believe is worth far more than one that does fifteen things nobody reads the output of.

Pipeline time is a tax on every change

Every minute the pipeline takes is paid again on each push, by whoever is waiting. For illustration only: ten pushes a day through a twenty-minute pipeline is more than three hours of waiting a day across a team, which is the sort of number that quietly changes behaviour. People start batching changes to avoid the wait, and batched changes are exactly what continuous integration exists to prevent.

  • Run independent jobs, such as linting and tests, at the same time rather than in sequence.
  • Cache dependencies, keyed on the hash of the lockfile so the cache invalidates when it should.
  • Keep slow integration tests in a separate job, and let the fast feedback arrive without waiting for them.
  • Measure before optimising; pipeline slowness is usually one step, not all of them.

A red mainline is everyone's problem

When the mainline is broken, nobody else can tell whether their own change broke something, so the cost of one failure multiplies across everyone working that day. Treat it as the current priority: either revert the change that caused it or fix it forward quickly, but do not push new work on top of a failing build and hope.

This is also an argument against branch protection that people route around. If the checks are slow or unreliable, the pressure to skip them becomes irresistible, and a rule that gets bypassed under deadline was never really a rule.

Fix flaky tests or delete them

A test that fails one run in twenty is worse than a test that always fails, because it teaches the team that red means "press retry". Once retrying is the habit, a genuine regression gets retried too, and the suite has stopped protecting anything.

The usual causes are mundane: a real clock, a real network, shared state between tests, or an order dependency that only shows up when tests run in parallel. Quarantine the offender out of the blocking job immediately so the signal stays clean, then fix it or remove it. A quarantine with no expiry date is just a slower deletion.

Build once, then promote

Continuous delivery extends the idea to keeping the mainline in a state that could be released at any time. The habit that matters most there is building the artefact once and moving that same artefact through environments, rather than rebuilding per environment and hoping the results match. Reproducible builds, where the same source reliably produces the same output, are the stricter version of the same instinct: pin versions, avoid embedding timestamps, and keep the build free of anything that varies by machine.

The pipeline holds credentials

A pipeline that can publish packages or deploy to production is a high-value target with write access to your infrastructure. Scope its credentials to exactly what each job needs, keep deployment secrets out of jobs that run code from forks, and make sure nothing echoes a secret into a build log that anyone can read.

If a failing build sends people looking for the retry button instead of the diff, the pipeline has stopped being a check and become a toll.

last updated 2026-12-03