# Failing Fast — CI/CD

Source: https://www.geekswithgeeks.com/en/cicd/cicd-testing-fail-fast

> Give developers bad news as early and as cheaply as possible.

## The principle

**Fail fast** means ordering pipeline steps so the cheapest, quickest checks (linting, unit tests) run first. If those fail, the pipeline stops before wasting minutes on a slow deploy step.

## Order: cheap to expensive

A good ordering is: lint → unit tests → build → integration tests → deploy. Each stage should only run once the cheaper stage before it has passed.

## Checking the easy things first

A doctor checks your temperature before ordering an MRI. Cheap, fast checks first rule out the obvious problems before you spend time and money on expensive ones.

**Quiz:** In a fail-fast pipeline, which should typically run first?

- [ ] The production deploy
- [x] Fast, cheap checks like linting and unit tests
- [ ] Slow end-to-end integration tests

*Answer:* Fast, cheap checks like linting and unit tests. Running the cheapest checks first surfaces most bugs quickly, before time is spent on slower stages.
