Skip to content

fix(ci): migrate coverage to c8 and fix non-TTY progressBar crash#179

Merged
jung-thomas merged 1 commit into
mainfrom
fix/coverage-c8-and-nontty-progressbar
Jul 13, 2026
Merged

fix(ci): migrate coverage to c8 and fix non-TTY progressBar crash#179
jung-thomas merged 1 commit into
mainfrom
fix/coverage-c8-and-nontty-progressbar

Conversation

@jung-thomas

Copy link
Copy Markdown
Contributor

Problem

Cross-Platform Tests have been failing on main since PR #177 ("refactor: ESM modernization — retire CommonJS-interop shims"). The last green run was #167; every run since — the dependabot bumps and PR #178 — inherited the failure.

The failing step is "Generate coverage report" (npm run coverage:ci), and it fails for two independent reasons:

1. nyc reports 0% coverage under ESM

nyc's instrumenter relied on the CommonJS-interop shims that #177 removed. With native ESM it captures nothing — 0% across all 14k+ statements.

2. The actual exit-1 cause: non-TTY progressBar crash

1) terminal lazy access
     progressBar returns a controller with startItem/itemDone/stop:
   RangeError: Invalid count value: Infinity
     at String.repeat (<anonymous>)
     at redraw (node_modules/terminal-kit/lib/progressBar.js:261:18)

terminal-kit queries the cursor location, which returns Infinity when stdout is not an interactive TTY (CI, piped, redirected), then calls String.repeat(Infinity). Since .nycrc.json had check-coverage: false, this failing test — not the 0% coverage — is what actually exited the step with code 1.

Fix

  • Migrate coverage nyc → c8 (V8-native, ESM-aware). .nycrc.json.c8rc.json with the same include/exclude/thresholds; adds the json reporter so codecov still receives coverage/coverage-final.json. Drops nyc devDependency, adds c8.
  • Guard loadRealTerminalSync() in utils/base.js to fall back to the console stub when stdout is not a TTY. This fixes the CI crash and real piped CLI usage (e.g. hana-cli ... > out.log).

Verification (local)

  • npm run coverage:ci runs clean — exit 0.
  • 555 passing / 0 failing (was 1 failing) — the progressBar test now passes.
  • c8 reports real coverage (Statements 15%+) where nyc reported 0%.
  • Reproduced the crash directly in NODE_ENV=production non-TTY (piped) — throws before the fix, uses the stub after.
  • coverage/coverage-final.json is produced for the codecov upload step.

Notes

Cross-Platform Tests have failed on main since the ESM modernization in
#177. The coverage step ("Generate coverage report") failed for two
independent reasons:

1. nyc reported 0% coverage across all files. nyc's instrumenter relied on
   the CommonJS-interop shims that #177 removed; with native ESM it captures
   nothing. Migrate coverage from nyc to c8 (V8-native, ESM-aware), which
   captures real coverage. .nycrc.json -> .c8rc.json (same include/exclude/
   thresholds); the json reporter is added so codecov still gets
   coverage/coverage-final.json.

2. The actual exit-1 cause: the terminal-kit progressBar test threw
   "RangeError: Invalid count value: Infinity". terminal-kit queries the
   cursor location, which returns Infinity when stdout is not an interactive
   TTY (CI, piped, redirected), then calls String.repeat(Infinity). Guard
   loadRealTerminalSync() to fall back to the console stub in non-TTY
   contexts. This also fixes real piped CLI usage (e.g. hana-cli ... > log).

Verified locally: coverage:ci runs clean (exit 0), 555 passing / 0 failing
(progressBar test now passes), c8 reports real coverage (was 0%), and
coverage/coverage-final.json is produced for the codecov upload.
@jung-thomas
jung-thomas merged commit 611b385 into main Jul 13, 2026
10 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.

1 participant