# Failing Fast — CI/CD Fundamentals: Pipelines, Testing and Deployment

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

> Order pipeline steps so cheap, fast checks like linting and unit tests run first and fail early.

## 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
- [ ] The manual approval email

*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.
