CI/CD: Continuous Integration
Continuous integration is the habit of merging small changes often and testing each one. Each push is built and tested before it can merge.
One big merge
A week of work merged at once hides the broken change.
Monday: add login
Tuesday: fix login
Friday: merge 200 lines
Result: tests failMany small merges
Small merges point straight at the broken change.
Monday: merge 20 lines, tests pass
Tuesday: merge 15 lines, tests pass
Wednesday: merge 10 lines, tests failThe test step
The workflow runs the tests on every push.
- run: npm testExample
steps:
- run: npm test
- run: npm run buildKey points
- Continuous integration: small merges, tested at once.
- Use short-lived branches to keep merges small.
- A failing test tells the team the change is not ready.
- CI runs the same tests for every change, so results can be compared.
- Frequent merges mean smaller conflicts.
- Continuous integration catches breakage early, while the change is still small.
In this example, the job has two steps. The first step runs the tests. The second step builds the app. The build step runs after the tests pass. A failed test stops the job, so a broken change never reaches the build.
Note
Integration means merging code together, not shipping it to users.
Try it Yourself
Edit the code, then press Run.
Running is simulated · Rust Playground
Exercise
Why merge small changes often?