Repository navigation
Report and enforce code coverage - #10
Merged
Merged
Conversation
Adds c8, which reads V8's own coverage counters, so the source is measured as it runs rather than instrumented first. "npm run coverage" writes a table to the console, a browsable report to coverage/index.html and lcov.info for editors; none of it is checked in. The thresholds in .c8rc.json are set to what the suite reaches today - 93% statements and lines, 76% branches, 100% functions - and are enforced, so a change which adds a branch nothing exercises fails rather than passing quietly. They can only be raised from here. Every CI run prints the table in its job summary and keeps the HTML report as an artifact for a fortnight. The publish workflow runs the same gate, since it does not depend on CI having passed and would otherwise release code that never met it. The coverage step sets "shell: bash" on purpose. The default shell leaves pipefail off, so the step would exit with tee's status instead of c8's and a coverage failure would be reported green.
MaximBelov
force-pushed
the
feat/coverage-report
branch
from
August 13, 2026 05:44
e0854a4 to
77472f6
Compare
This was referenced Aug 13, 2026
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The suite covers a lot of ground now, and nothing measured it. This adds the measurement and turns it into a gate.
What it does
npm run coverageruns the suite under c8, which reads V8's own coverage counters — the source is measured as it runs, with no instrumentation step and nothing to keep in sync with the build.Where it lands today:
src/BarcodeParser.jsThe thresholds in
.c8rc.jsonare set just under those numbers and are enforced, so a change that adds a branch nothing exercises fails instead of passing quietly. They can only be raised from here.Output is a console table,
coverage/index.htmlfor reading line by line, andcoverage/lcov.infofor editors and other tools. None of it is checked in.In CI
Every run prints the table into the job summary, so the number is visible without downloading anything, and attaches the HTML report as an artifact for a fortnight.
publish.yamlgets the same gate. It does not depend on CI having passed — that is why it already repeats lint, test and build — so without this it could publish code that never met the threshold.One thing worth not undoing
The coverage step sets
shell: bashdeliberately. The default shell for arun:step leavespipefailoff, so piping throughteeto capture the log makes the step exit withtee's status rather than c8's. Verified both ways:Without that line the gate reports green on a coverage failure, which is worse than having no gate at all. There is a comment in the workflow saying so.
What is not covered, and why it is worth knowing
The report names two honest gaps:
switchthat turns an internal error code into its message — most arms are only reached when that specific error fires;]C1— it is the only one any spec uses.Both are reachable and both deserve specs. That is a separate change, not this one — this PR is the instrument, not the fix. The thresholds are pinned at today's numbers so that work shows up as a rise rather than being quietly absorbed.
Notes
masterafter Reject truncated fixed length elements instead of returning a short or wrong value #7 and Accept the parenthesised form of GS1 element strings #8 landed, and the thresholds are measured against that. Independent of Add the made-to-order, Italian NHRN and person identifiers (193 -> 205) #9, which touchessrc/andspec/only.actionlintis clean on both workflows.