Skip to content

test: run the real code instead of hand-copied mirrors (sable-1drb) - #228

Closed
Rome-1 wants to merge 2 commits into
mainfrom
fix/sable-1drb-tests-run-the-real-code
Closed

test: run the real code instead of hand-copied mirrors (sable-1drb)#228
Rome-1 wants to merge 2 commits into
mainfrom
fix/sable-1drb-tests-run-the-real-code

Conversation

@Rome-1

@Rome-1 Rome-1 commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Replaces #225, which I closed by accident: I merged #224 with --delete-branch, and deleting that branch closed the PR stacked on it. GitHub refuses to reopen a PR whose base ref is gone, so this is the same head branch retargeted onto main. No code changed.

What this does

Deletes the hand-copied test mirrors and runs the real implementations instead. The bash tests now source the same lib/severity.sh that action.yml sources, rather than asserting against a transcribed copy of it.

Coverage is provably unchanged

The diff removes 324 lines, which is exactly where coverage tends to vanish quietly, so it was checked rather than assumed. node/tests/issues.test.ts before vs after: it() 96 → 96, describe() 25 → 25, expect() 159 → 159, and a comm over the sorted test titles is empty on both sides — not one title added, dropped or renamed. Every deletion is a mirrored implementation of dedup, issue-builder, from-text or draftsFromLocalScan; all four imported symbols are real exports.

The gates were mutation-tested rather than read: breaking the high arm of severity.sh produced three named failures, and check 17 correctly failed when both source lines were stripped. test-threshold-gate-end-to-end supplies the wiring proof a unit test cannot.

Known follow-up, filed separately

rafter_threshold_fails treats an empty or non-numeric count as zero findings and passes the build — verified by execution for every threshold. That is pre-existing behavior this PR relocates rather than introduces, and it is tracked as its own bead along with retargeting the severity-gate if: from steps.poll.outputs.status to steps.results.outputs.status.

Follows #224.

The composite action's results step coerced every jq failure into
findings_count=0: a body that was not JSON, a 200 carrying an error object,
or a parseable payload with no vulnerabilities key passed every severity
threshold and rendered "No security findings detected". Validate the shape
first; on failure exit 1 with status=unreadable, an actionable message, and
no count outputs at all. Once the shape holds the counts cannot fail, so the
fallbacks are removed rather than moved.

rafter issues create from-scan (Node and Python) had the same shape:
data.vulnerabilities || [] turned a processing or failed scan, an error
object, or a keyless payload into "No findings to create issues for". Both
now refuse with exit 1 and name the scan status. An empty array is still a
clean result.

Regression coverage: two end-to-end CI jobs drive the real action against
the mock backend (a 3-way matrix of unreadable shapes asserting the build
fails with status=unreadable and an EMPTY findings-count, plus an exact
counts job asserting 3/1/1/0/1); three drift assertions; unit tests on the
real functions in both runtimes. Every new guard was mutation-verified by
hand: restoring the old behaviour fails the tests that exist to catch it.
The action's threshold-eval and PR-comment-tip tests each carried their
own transcription of the bash they tested, so they could pass in full while
action.yml was broken. The logic now lives once in
github-action/lib/severity.sh, sourced by both action.yml steps and by both
tests. Behaviour unchanged. A new end-to-end job runs the real action with
findings above the threshold and asserts status=completed AND
outcome=failure, which proves the counts reach the gate; drift check 17
asserts action.yml sources the library in both steps and carries no inline
copy, so the tests cannot be silently detached again.

node/tests/issues.test.ts mirrored four modules (dedup, issue-builder,
from-text, from-scan) and tested the mirrors; one had already drifted. The
copies are removed and every describe imports the shipped function. Three
source functions gained `export` for that.

Every guard was mutated by hand: each mutation fails named tests that were
untouched by the same mutation before this change.
@Rome-1

Rome-1 commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by a clean rebase onto main. The branch behind this PR still carried #224's commit, which was squash-merged, so it conflicted. Reopening was not possible because the original base ref was deleted. Same commit, rebased, continues in the replacement PR.

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