Skip to content

Add code coverage reporting and thresholds to CI #38

@jvcorredor

Description

@jvcorredor

Problem

The CI runs npm run test:run but does not collect or report code coverage. There is no visibility into how well the codebase is tested, and no mechanism to prevent coverage regression. The @vitest/coverage-v8 package is already installed but unused in CI.

Scope of Work

1. Switch CI test command to use coverage

In .github/workflows/ci.yml, change npm run test:run to npm run test:coverage.

2. Add coverage thresholds in vitest config

In vitest.config.ts (or the vitest section of astro.config.mjs), add coverage thresholds. Start conservatively and ratchet up over time:

coverage: {
  provider: 'v8',
  thresholds: {
    lines: 10,
    branches: 10,
    functions: 10,
    statements: 10,
  },
}

3. Upload coverage artifact

Add a step to upload the coverage report as a build artifact so it can be reviewed.

4. (Optional) PR coverage comment

Consider adding a step (e.g., via davelosert/vitest-coverage-report-action) to post a coverage summary as a PR comment.

Acceptance Criteria

  • CI runs test:coverage instead of test:run
  • Coverage thresholds are configured in vitest config
  • CI fails if coverage drops below thresholds
  • Coverage report is uploaded as a build artifact
  • Current codebase passes the initial thresholds

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions