Skip to content

feat(ts): add coverage_threshold input for quality gate#68

Merged
emmanuelm41 merged 1 commit intomainfrom
feat/ts-coverage-threshold
Dec 26, 2025
Merged

feat(ts): add coverage_threshold input for quality gate#68
emmanuelm41 merged 1 commit intomainfrom
feat/ts-coverage-threshold

Conversation

@emmanuelm41
Copy link
Copy Markdown
Member

@emmanuelm41 emmanuelm41 commented Dec 26, 2025

Summary

  • Adds coverage threshold inputs to _checks-ts.yaml workflow for all four metrics:
    • coverage_threshold_lines
    • coverage_threshold_statements
    • coverage_threshold_functions
    • coverage_threshold_branches
  • Quality gate step reads coverage/coverage-summary.json and fails if any enabled threshold is not met
  • All default to 0 (disabled) for backwards compatibility

Usage

uses: zondax/_workflows/.github/workflows/_checks-ts.yaml@v5
with:
  enable_coverage: true
  coverage_threshold_lines: 36
  coverage_threshold_statements: 35
  coverage_threshold_functions: 32
  coverage_threshold_branches: 31

Test plan

  • Test with kunobi-frontend using current coverage values as thresholds

@emmanuelm41 emmanuelm41 force-pushed the feat/ts-coverage-threshold branch 2 times, most recently from e6e6744 to 0df68d3 Compare December 26, 2025 13:06
@emmanuelm41 emmanuelm41 requested a review from Copilot December 26, 2025 13:12
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds quality gate functionality to the TypeScript checks workflow by introducing configurable coverage thresholds for four metrics (lines, statements, functions, branches). The implementation parses the coverage-summary.json file generated by the test coverage command and fails the workflow if any enabled threshold is not met.

Key Changes:

  • Added four input parameters for coverage thresholds (lines, statements, functions, branches), all defaulting to 0 for backwards compatibility
  • Implemented a new quality gate step that validates coverage metrics against configured thresholds using bash and jq
  • Positioned the quality gate after the Vitest Coverage Report step to ensure coverage data is available

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/_checks-ts.yaml Outdated
Comment thread .github/workflows/_checks-ts.yaml Outdated
Comment thread .github/workflows/_checks-ts.yaml Outdated
Comment thread .github/workflows/_checks-ts.yaml Outdated
@emmanuelm41
Copy link
Copy Markdown
Member Author

Suggested threshold values for kunobi-frontend

Based on current coverage:

Metric Current Suggested Threshold
Lines 36.71% coverage_threshold_lines: 36
Statements 35.32% coverage_threshold_statements: 35
Functions 32.06% coverage_threshold_functions: 32
Branches 31.16% coverage_threshold_branches: 31
ts-checks-linux:
  uses: zondax/_workflows/.github/workflows/_checks-ts.yaml@v5
  with:
    enable_coverage: true
    coverage_threshold_lines: 36
    coverage_threshold_statements: 35
    coverage_threshold_functions: 32
    coverage_threshold_branches: 31

Add coverage enforcement to TypeScript checks workflow with separate thresholds:
- `coverage_threshold_lines` - Minimum line coverage %
- `coverage_threshold_statements` - Minimum statement coverage %
- `coverage_threshold_functions` - Minimum function coverage %
- `coverage_threshold_branches` - Minimum branch coverage %

All default to 0 (disabled). Quality gate reads coverage/coverage-summary.json
and fails CI if any enabled threshold is not met.
@emmanuelm41 emmanuelm41 force-pushed the feat/ts-coverage-threshold branch from 0df68d3 to b3dddea Compare December 26, 2025 13:22
@emmanuelm41
Copy link
Copy Markdown
Member Author

Addressed all Copilot review comments:

  1. Added error handling for jq extraction - New get_coverage_value() helper validates JSON parsing, checks for null/empty values, and verifies numeric format
  2. Use numeric comparison - Now using awk for threshold > 0 check instead of string comparison
  3. Removed hardcoded 'pnpm' - Changed to generic "Run your test:coverage script locally"
  4. Use awk instead of bc - Replaced bc with awk for portable floating point comparison

@emmanuelm41 emmanuelm41 merged commit 1836ea3 into main Dec 26, 2025
1 check passed
@emmanuelm41 emmanuelm41 deleted the feat/ts-coverage-threshold branch December 26, 2025 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants