CI quality gates
What you need to know
CI quality gates run repeatable checks before a Next.js artifact can be promoted. A production build is one gate, not a substitute for application tests or dependency review.
By the end, you can: sequence typecheck, tests and build; review untrusted contributions.
Ordered commands for a reviewed local CI project
npm cinpm run lintnpm run typegennpm run typechecknpm testnpm run buildExpected behavior: Requires a reviewed project and defined scripts; stop on first failure in the CI runner. Installation/build may execute code; none of these commands were run for this fixture.
How it works
CI should use a pinned supported Node/toolchain, reviewed lockfile and isolated environment. Generate Next.js route types before a standalone TypeScript check; next typegen loads framework config, so treat it as code execution. Run the chosen linter directly, since the modern Next.js CLI no longer supplies the old next lint workflow. Run deterministic tests, then a real production build and bounded HTTP/browser smoke tests. Review dependency provenance, current security advisories and artifact contents; lockfile reproducibility is not a safety guarantee. Untrusted pull requests must not receive deployment credentials or privileged tokens. Do not execute contributor-controlled code in privileged pull_request_target workflows. Use read-only permissions, reviewed pinned actions and a separate authorized promotion stage. Build output should be immutable, identified by digest, and linked to test results.
Record a gate result rather than hiding missing checks
{ "artifact": "candidate-release", "typecheck": "pass", "unit": "pass", "build": "pass", "browser": "not-run", "security": "not-run", "promotion": "blocked"}Expected behavior: Missing critical evidence blocks promotion even with successful compile and unit checks.
Common mistake
Never suppress TypeScript build errors or disable tests just to ship a green pipeline. Do not interpolate untrusted pull request metadata into shell code or expose credentials to unreviewed build steps.
Practice and verification
Use the staged CI plan and gate exercise. Inject a failed type check and a missing smoke test into the model, then describe which later jobs must not run. Review the trust boundary of each job.
Scope: Proposed Next.js 16.x / React 19, App Router with Cache Components disabled unless noted. Framework and browser examples are staged, not executed. Hypothetical costs are not actual provider rates.