DevOps
CI/CD for a small team: the first pipeline worth building
You do not need a platform team to release safely. Five steps that take a small team from manual deploys to routine ones.
Codexan
5 min read
A lot of DevOps advice is written for companies with hundreds of engineers. A team of three does not need a service mesh. It needs to be able to release on a Friday afternoon without anyone feeling nervous. This is the order we build things in.
1. One command to build, one to test
Before any automation, the project must build and test the same way on every machine. If a new developer needs a page of instructions to run it, the pipeline will inherit every one of those problems.
Write the commands down in the repository. Everything after this simply runs them somewhere else.
2. Run the checks on every change
Set up continuous integration so that every pull request runs, at minimum:
- formatting and lint checks
- type checks, if the language has them
- the automated tests
- a production build
Keep it fast. A pipeline that takes twenty minutes gets worked around; one that takes three gets trusted. Cache dependencies and run independent jobs in parallel.
3. Deploy from the main branch, automatically
The deployable version is whatever is on the main branch, and a merge is what deploys it. No copying files, no logging in to servers, no "who deployed last?".
This one change removes the most common source of outages we see in small teams: a manual step that somebody did slightly differently this time.
4. Give every change a preview
A preview environment is a temporary copy of the application built from a pull request. Reviewers click a link and see the change running, instead of imagining it from a diff.
Most managed platforms do this for you. On your own infrastructure it takes more effort, and it is still worth it: problems found in a preview cost minutes, and the same problems found in production cost a day.
5. Make going back easy
Every release should be reversible in one step. That means keeping the previous build available, and treating database changes with care:
- add new columns before the code that uses them
- remove old columns only after nothing reads them
- never combine a risky schema change with a large feature release
When rolling back is easy, releasing stops being frightening, and teams start shipping smaller changes more often. Smaller changes break less.
What to leave for later
You can add these when a real problem calls for them, and not before:
- Kubernetes
- multiple staging environments
- complex branching strategies
- a dedicated release manager
How to know it is working
Four questions, asked once a month:
- How long does a change take to go from merged to live?
- How often do we release?
- How often does a release cause a problem?
- How long does it take to recover when one does?
If the first and last numbers are falling and the second is rising, the pipeline is doing its job.
- devops
- ci-cd
- automation
- testing