Quality Gates & CI/CD Pipeline
Context
To ensure the "Trust" in TrustVote AI, we need automated verification that prevents insecure, poorly formatted, or broken code from reaching the main branch.
Decision
Implement a multi-layered quality gate strategy:
- Pre-commit (Local): Use Husky and lint-staged to run ESLint and Prettier before every commit. This ensures consistent style and catches syntax errors instantly.
- Pre-push (Local): Automatically run unit tests (Jest) to ensure no regressions before code leaves the local machine.
- CI Pipeline (Remote): GitHub Actions will trigger on every Pull Request to:
- Verify the build (Compilation).
- Run security audits (
npm audit). - Perform deep static analysis via SonarQube.
Rationale
- Consistency: Every line of code follows the same style, making it easier for AI agents and future auditors to read.
- Fail Fast: Errors are caught in the developer's machine, reducing CI costs and feedback loops.
- Deep Security: SonarQube provides an extra layer of protection, detecting "Security Hotspots" and "Code Smells" that standard linters miss.
- Integrity: Prevents merging code that doesn't compile or lacks sufficient test coverage.
Consequences
- Commits may take a few seconds longer due to local checks.
- A
sonar-project.propertiesfile must be maintained in the backend package. - Merging to
mainwill be blocked if the SonarQube "Quality Gate" fails.