Skip to content

ci: Added pre commit hooks

Bhaskar Battula requested to merge pre-commit-hooks into develop

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-commit with Husky, aligning with modern Node.js project standards.
  • Automated Quality Gates: Implemented a pre-commit hook 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.yml from a single deployment script to a professional 4-stage pipeline: install -> test -> build -> deploy.
  • Artifact Management: Introduced a formal build script that packages the static application into a public/ 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 .gitignore to exclude generated build artifacts (public/), test reports (coverage/), and Husky internals.
  • Synchronized package.json scripts to support the new quality-gate-driven workflow.
  • Standardized commitlint.config.js with project-specific rules for scope and type validation.

Impact

  • Consistency: Both voice-app and ehrs now 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

  1. Run npm install to initialize the new dependencies.
  2. Run npm run lint to verify formatting and linting.
  3. Attempt a commit with a non-semantic message to verify commitlint enforcement.
  4. Run npm run build to verify the generated public/ directory structure.

Merge request reports

Loading