Catalog My learning Blog
CI/CD and DevOps Tutorial: Build a Delivery Pipeline · Phase 1 · Lesson 3 · 3 min read

What Is Continuous Integration? CI Explained

On this page
  1. Why continuous integration exists
  2. Words you'll see all course
  3. The principles of continuous integration
  4. What a CI pipeline runs, in order
  5. A GitHub Actions CI workflow
  6. Making CI matter: required checks and flaky tests
  7. Check yourself

Why continuous integration exists

A developer's change passes on their laptop. Merged, it breaks the build for everyone: a missing dependency, a test that depended on their local database, a conflict with a change merged an hour earlier. Continuous integration (CI) catches this before the merge, every time, by building and testing each change in a clean, shared environment.

Words you'll see all course

TermIn plain words
PipelineThe automated series of checks and steps that runs for every change
WorkflowGitHub Actions' name for a pipeline, defined in a YAML file
JobA group of steps that runs on one machine; separate jobs can run side by side
StepOne command or action inside a job
RunnerThe machine, usually a fresh virtual machine, that runs a job and is thrown away afterwards
Green / redThe pipeline passed / failed
ArtifactThe packaged output of a build, such as a container image (Day 5)

The principles of continuous integration

CI is a practice first and a tool second:

  1. Integrate often: merge into main at least daily (Day 2).
  2. Every change triggers an automated build and test run.
  3. Keep the build fast: feedback in minutes, not hours.
  4. A broken main is everyone's top priority: fix or revert immediately.
  5. Test in a clean, production-like environment, not on someone's laptop.

What a CI pipeline runs, in order

A change triggers the pipeline: install, lint, test and build, with a red result blocking the merge.
A change triggers the pipeline: install, lint, test and build, with a red result blocking the merge.

A typical order, cheapest and fastest checks first so failures arrive early:

  1. Check out the exact commit.
  2. Install dependencies from a lockfile (npm ci, not npm install, so versions can't drift).
  3. Lint and format checks.
  4. Unit tests.
  5. Build the application or artifact.
  6. Later stages: integration tests, security scans, packaging (Days 5, 6, 25).

A GitHub Actions CI workflow

YAML
name: CI
on:
  push:
    branches: [main]
  pull_request:

concurrency:
  group: ci-${{ github.ref }}
  cancel-in-progress: true

permissions:
  contents: read

jobs:
  build-and-test:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-node@v7
        with:
          node-version: 24
          cache: npm
      - run: npm ci
      - run: npm run lint
      - run: npm test
      - run: npm run build

Details that matter:

  • Triggers: every pull request, and every push to main (to confirm the merged result).
  • concurrency: a new push to the same branch cancels the previous run, saving runner time.
  • permissions: contents: read: the job's token can only read the repository, limiting damage if a step is compromised.
  • timeout-minutes: a hung test fails in 15 minutes instead of the 6-hour default.
  • cache: npm reuses downloaded packages between runs (Day 12).
  • Pinned major versions of actions (@v7); pin to a full commit SHA for stricter supply-chain safety (Day 25).

This workflow passes actionlint, which catches typos in keys, invalid expressions and unsafe patterns before you push.

Making CI matter: required checks and flaky tests

  • Required status checks: branch protection on main blocks merging until CI passes.
  • Don't tolerate flaky tests. A test that fails randomly trains people to rerun and ignore red builds. Quarantine and fix it.
  • Keep it under about 10 minutes. Slow CI pushes people toward bigger, rarer merges, which defeats the purpose.
  • Treat a red main as an incident: revert first, investigate after.

Check yourself

npm ci deletes node_modules and installs exactly the versions in the lockfile, failing if package.json and the lockfile disagree. Builds are reproducible, whereas npm install can resolve newer versions and rewrite the lockfile.

Cheap checks catch most problems in seconds, so developers get fast feedback and slow stages like E2E tests don't waste minutes running on code that was already broken.

Stop merging and fix or revert the breaking change immediately. Merging on top of a broken main hides new failures behind the existing one and makes the culprit harder to find; reverting first is usually fastest.

So nothing left over from earlier runs or from someone's setup can make a build pass by accident; every change is built and tested in the same clean environment.