Skip to content

What a CI pipeline does with your push

BasicsConcept

You push, and a minute later a tick or a cross appears next to your commit. Here is what ran in between, step by step, and why it ran on a machine that has never seen your code.

01 What happens after git push

You push a commit and, a minute later, a green tick or a red cross appears next to it. In between, a CI (continuous integration) service took your commit, built it on a machine of its own, ran your tests, and reported back.

The recipe lives in your repository. On GitHub it is a YAML file in .github/workflows/, called a workflow. It says when to run (on: push), where (runs-on), and the steps, each one a command or a ready-made action.

.github/workflows/ci.yml
name: CI
on: push # when: every push
jobs:
test:
runs-on: ubuntu-latest # where: a fresh Ubuntu machine
steps:
- uses: actions/checkout@v5 # checkout
- uses: actions/setup-node@v5 # setup
with:
node-version: 24
- run: npm ci # install
- run: npm test # test
- run: npm run build # build

02 Checkout, install, test, build

Here is one push going through that file. Watch the disk on the right: it starts with nothing of yours, and everything on it comes from the commit or from a step in the file.

One push, one clean machine
Step 1 of 8
Status queued
Job steps in ci.yml
checkout
setup
install
test
build
On the runner's disk (yours)
Empty
  • running now
  • passed
  • waiting
  • just arrived

You run git push. GitHub sees a workflow that listens for push, queues its job, and starts a fresh virtual machine from the Ubuntu image. Nothing of yours is on it.

a1b2c3d commit

03 Why a clean machine

Your laptop has years of leftovers: tools installed globally, environment variables, files you never committed, a Node version you picked once. Tests can pass there because of those leftovers. The runner has none of them, so a pass there means the repository alone is enough.

Your laptopWhatever piled upA pass may lean on a global tool, a .env file or an uncommitted change that nobody else has.
A GitHub-hosted runnerOnly what the file saysA fresh machine per job. If the build needs something, the workflow has to install it.
Things that differ between your laptop and the runner
ThingYour laptopThe runner
Fileseverything in the folderonly what was committed and pushed
Node versionwhatever you installedwhat `setup-node` names
Packages`node_modules` from months agofresh from `package-lock.json`
File namesmacOS ignores case by defaultLinux does not: `Cart.js` is not `cart.js`
Secrets and env varsyour shell and `.env`only the secrets you add to the workflow
Time zoneyoursUTC

04 When a step fails

Each step is a command, and CI judges it the way your shell does: exit code 0 is success, anything else is failure. Test runners exit non-zero when a test fails, which is how CI knows.

Text
Run npm test
> shop@1.0.0 test
> node --test
✖ adds VAT to the total
AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
1200 !== 1000
…
Error: Process completed with exit code 1.
The same job, with one failing test
StepResult
checkoutpassed
setuppassed
installpassed
testfailed, exit code 1
buildskipped
commit a1b2c3dred cross

By default, the steps after a failure are skipped and the job fails. A pull request with a red cross is easy to spot, and the repository can be set to block merging until it is green.

05 Green on your laptop, red in CI

CI tests the commit you pushed, not your working folder. A new file you forgot to git add exists on your laptop and nowhere else, so the runner fails with Cannot find module.

import './Cart.js'Wrong case in a file nameThe file is cart.js. macOS finds it anyway; the Linux runner does not. Match the case exactly.
npm installInstalling without the lockfilenpm install may pick newer versions than you tested with. Commit package-lock.json and use npm ci, which refuses to run without it.
process.env.API_KEYA value only your shell hasIt is set in your .env or shell profile, which are not in the repository. Add it as a repository secret and pass it to the step.
new Date().getHours()Tests that depend on the clockRunners use UTC, so a test written in your time zone can fail by hours. Fix the time in the test instead of reading the real clock.
runs-on: self-hostedSelf-hosted runners are not cleanYour own runner machine keeps files between jobs unless you clean it. The clean-machine guarantee is for GitHub-hosted runners.

06 Check yourself

Question

Tests pass on your laptop but CI fails with Cannot find module './utils/format'. The file is on your disk. What is the most likely cause?

Question

Why does CI start each job on a fresh machine instead of reusing yesterday's?

Question

The test step fails. What happens to the build step after it, by default?

07 Practise this

Was this tutorial useful?Your vote tells us what to improve next.
Spotted a mistake, or something unclear?