Which order makes the most sense for a CI/CD pipeline?
Options
- Deploy to prod, then run the tests, then build the image
- Lint and unit tests, build, integration tests, staging, smoke tests, prod (Correct option)
- Build, deploy to prod, then lint the code afterwards
- Deploy to staging only on Fridays, then run all tests at once
Answer
Lint and unit tests → build image → integration tests → deploy staging → smoke tests → deploy prod
Why
Run the fastest, cheapest checks first so problems are found in seconds (fail fast): linting and unit tests.
Then build the artifact (Docker image) ONCE, run slower integration tests, deploy to staging and smoke-test it.
Finally promote that same image to production, so what you tested is exactly what you ship.
Remember
Cheap checks first; build once; promote the same artifact.