Skip to content

apps/me coverage discrepancy: local vs CI branch % (35.41 vs 35.03) causes false-negative CI failures #481

@taterhead247

Description

@taterhead247

Summary

apps/me branch coverage differs between local and GitHub Actions for the same test target, causing threshold failures in CI.

Observed values:

  • Local (pnpm test -F f3-me): branch coverage reports 35.41%.
  • CI (test-coverage job on GitHub Actions): branch coverage reports 35.03%.

This discrepancy is enough to fail when the threshold is calibrated from local runs.

Impact

  • CI can fail even when local runs pass.
  • autoUpdate-driven thresholds recorded locally can become incompatible with CI.
  • Developers lose confidence in local reproducibility for coverage gates.

Evidence

From failing Actions logs:

  • ERROR: Coverage for branches (35.03%) does not meet global threshold (35.41%)

Local CI-mode repro:

  • Running with CI=true locally reproduces the lower CI number (35.03%) and failure against 35.41.

Reproduction

  1. Ensure Node version from .nvmrc.
  2. Run locally:
    • pnpm test -F f3-me
    • Note branch coverage (commonly 35.41% in non-CI env).
  3. Run with CI flag:
    • CI=true pnpm test -F f3-me
    • Branch coverage drops to 35.03% (matches GitHub Actions).
  4. Compare against configured threshold in apps/me/vitest.config.ts.

Likely Root Cause

Coverage denominator/branch map differs when CI=true.

apps/me/src/env.ts has CI-sensitive logic:

  • skipValidation: !!process.env.CI || ...

This introduces different branch execution/coverage behavior between local default runs and CI runs.

Suggested Resolution

  • Calibrate apps/me thresholds using CI-mode runs (CI=true) rather than default local runs.
  • Prefer stable thresholds for this package (avoid auto drift), e.g. set autoUpdate: false once CI-aligned values are chosen.
  • Optionally document a repo convention: coverage threshold updates must be generated under CI-equivalent env.

Follow-ups (optional)

  • Add a small script/target for standardized coverage recalibration under CI=true.
  • Add a short testing guide note explaining why CI-mode coverage can differ.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions