Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 29, 2025

Adds code coverage validation as the final step in the pre-commit workflow. The check uses the existing cargo cov-check alias which validates 85% line coverage threshold.

Changes:

  • Added coverage check as 6th step in scripts/pre-commit.sh STEPS array
  • Follows existing step format: "description|success_message|special_note|env_vars|command"
  • Runs after all other checks (linting, tests, E2E tests, documentation)

Implementation:

"Running code coverage check|Coverage meets 85% threshold|(Informational only - does not block commits)||cargo cov-check"

The step integrates with existing error handling (set -euo pipefail) and timing infrastructure, requiring no additional script logic.

Related: Parent Epic #85

Original prompt

This section details on the original issue you should resolve

<issue_title>Add coverage check to pre-commit script</issue_title>
<issue_description>Parent Epic: #85

Overview

Add code coverage validation to the pre-commit script (scripts/pre-commit.sh) as the last check in the steps array. The check uses the cargo cov-check alias which validates that coverage meets the 85% threshold and will fail the pre-commit if coverage drops below this level.

Goals

  • Make coverage validation part of the pre-commit process
  • Provide developers immediate feedback about coverage impact
  • Run coverage check last to ensure all other checks pass first (saves time)
  • Use existing step infrastructure for consistency

Specifications

Current Pre-commit Structure

The scripts/pre-commit.sh script uses a step-based execution model with an array of checks. Each step follows the format:
"description|success_message|optional_pre_message|optional_env_var|command"

Proposed Change

Add coverage check as the last step in the STEPS array:

"Running code coverage check|Coverage meets 85% threshold|(Informational only - does not block commits)||cargo cov-check"

Why This Approach?

Advantages:

  • Consistent: Follows existing script patterns
  • Simple: Just one line added to the array
  • Maintainable: No special-case logic needed
  • Clear: Uses same messaging format as other steps
  • Automatic timing: Built-in timing display like other steps

Behavior:

  • Runs last after all other checks pass
  • Still fails fast if coverage is below 85% (exits with non-zero code)
  • Shows clear error message from cargo cov-check
  • Uses existing error handling and timing infrastructure

Implementation Plan

Phase 1: Add Coverage Step (5 minutes)

  • Open scripts/pre-commit.sh
  • Locate the declare -a STEPS=() array
  • Add new line at the end of the array (before the closing parenthesis)
  • The new line should be:
"Running code coverage check|Coverage meets 85% threshold|(Informational only - does not block commits)||cargo cov-check"
  • Save the file

Phase 2: Testing (10 minutes)

  • Run ./scripts/pre-commit.sh on current codebase (coverage should pass at 85.75%)
  • Verify coverage check runs last (after E2E tests)
  • Verify timing is displayed correctly (uses existing timing infrastructure)
  • Verify success message appears when coverage passes
  • Verify script shows clear output from cargo cov-check

Acceptance Criteria

  • Coverage check added as last step in STEPS array in scripts/pre-commit.sh
  • Uses cargo cov-check alias (already exists in .cargo/config.toml)
  • Success message reads: "Coverage meets 85% threshold"
  • Pre-message reads: "(Informational only - does not block commits)"
  • Script exits with non-zero code if coverage is below 85%
  • Timing information is automatically displayed (inherited from step infrastructure)
  • All existing checks still work correctly

Notes

  • Running coverage last ensures developers don't waste time waiting for coverage if linting fails
  • The coverage check will fail fast and block commits if coverage drops below 85%</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add coverage check to pre-commit script Add coverage check to pre-commit script Oct 29, 2025
Copilot AI requested a review from josecelano October 29, 2025 17:59
Copy link
Member

@josecelano josecelano left a comment

Choose a reason for hiding this comment

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

ACK d225208

@josecelano josecelano marked this pull request as ready for review October 29, 2025 18:01
@josecelano josecelano merged commit bd8bdee into main Oct 29, 2025
48 checks passed
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.

Add coverage check to pre-commit script

2 participants