ci: Added pre commit hooks
Overview
This MR modernizes the developer workflow and CI/CD architecture for the voice-app-frontend project. The changes synchronize this repository by introducing robust quality gates, automated linting, and a modular pipeline structure.
Key Changes
1. Enhanced Developer Workflow (Husky & lint-staged)
-
Migrated Hook System: Replaced the legacy Python-based
pre-commitwith Husky, aligning with modern Node.js project standards. -
Automated Quality Gates: Implemented a
pre-commithook that enforces linting (ESLint), formatting (Prettier), test coverage, and project build integrity before any code is committed. -
Semantic Commits: Integrated Commitlint to enforce conventional commit messages (e.g.,
feat:,fix:,chore:), ensuring a clean and machine-readable project history.
2. Testing Framework & Coverage Enforcement
- Vitest Integration: Installed Vitest and jsdom as the primary testing engine to provide high-performance unit testing in a browser-like environment.
- Coverage Thresholds: Configured a 60% global coverage minimum. The build will now fail if test coverage drops below this threshold, ensuring long-term code maintainability.
- Automated Reports: Configured V8 coverage reporting to generate local HTML/LCOV reports (automatically excluded from version control).
3. CI/CD Pipeline Modernization
-
Multi-Stage Pipeline: Refactored
.gitlab-ci.ymlfrom a single deployment script to a professional 4-stage pipeline:install->test->build->deploy. -
Artifact Management: Introduced a formal
buildscript that packages the static application into apublic/directory, which is then utilized by GitLab Pages for deployment. - Dependency Caching: Optimized pipeline execution time by implementing Node.js module caching across stages.
4. Configuration & Cleanup
- Updated
.gitignoreto exclude generated build artifacts (public/), test reports (coverage/), and Husky internals. - Synchronized
package.jsonscripts to support the new quality-gate-driven workflow. - Standardized
commitlint.config.jswith project-specific rules for scope and type validation.
Impact
-
Consistency: Both
voice-appandehrsnow share identical quality standards, making it easier for developers to switch between projects. - Reliability: The enforced build and test steps prevent broken code or unformatted files from reaching the remote repository.
- Efficiency: The optimized GitLab CI pipeline reduces redundant tasks and provides clearer feedback on failure points.
Verification Steps
- Run
npm installto initialize the new dependencies. - Run
npm run lintto verify formatting and linting. - Attempt a commit with a non-semantic message to verify
commitlintenforcement. - Run
npm run buildto verify the generatedpublic/directory structure.