refactor(e2e): centralize and validate the common live-Vitest invocation - #6984
refactor(e2e): centralize and validate the common live-Vitest invocation#6984souvikDevloper wants to merge 2 commits into
Conversation
e2e.yaml repeats the same `npx vitest run --project e2e-live … --reporter=default --reporter=test/e2e/risk-signal-reporter.ts` shape across many jobs. Add a trusted helper that owns that shape so a job supplies only a test path and selector, and adopt it in the canonical registry-targets live job. - Add tools/e2e/live-vitest-invocation.mts: validates the project (must be e2e-live), the test path (under test/e2e/live/, no traversal, no shell metacharacters, real .test.ts), and the selector (no shell metacharacters in the expanded value), then builds the fixed argv. Fails closed; nothing is quoted-away and run. - Adopt it in the live job's "Run live E2E tests" step; the NVIDIA_INFERENCE_API_KEY and TARGET_ID env flow is unchanged. - Update the workflow-boundary validator for the live job to assert the helper invocation and inputs instead of the raw command. Tests in test/e2e/support/live-vitest-invocation.test.ts cover the project, path-traversal, shell-metacharacter, and selector rejections plus argv building. Scope: this is a focused first slice. The ~70 other live-Vitest sites are not adopted because they do not share the exact contract — most prepend PATH and OPENSHELL_BIN setup or run different files — and would need helper inputs this slice deliberately omits. The Docker Hub auth setup is left inline on purpose: it is a single YAML anchor on the trusted workflow revision, and moving the secret-bearing login into a checkout-loaded script would make it branch- controllable, which the issue's own trust boundary forbids. Both are follow-ups. Refs NVIDIA#6961 Signed-off-by: Souvik Ghosh <138186578+souvikDevloper@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughAdds a validated live Vitest invocation helper, tests its input and argument handling, and updates the E2E workflow and boundary validator to use the helper. ChangesLive Vitest invocation
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant E2EWorkflow
participant LiveVitestInvocation
participant Npx
participant Vitest
E2EWorkflow->>LiveVitestInvocation: pass test path and target selector
LiveVitestInvocation->>LiveVitestInvocation: validate inputs and build argv
LiveVitestInvocation->>Npx: spawn Vitest without shell
Npx->>Vitest: run live E2E test with configured reporters
Possibly related issues
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
PR Review Advisor — InformationalAdvisor assessment: Informational / medium confidence Model lanes
Nemotron output stays in workflow artifacts and does not change the assessment above. E2E guidanceAdvisory only. E2E / PR Gate selects and runs jobs independently. Recommended E2E: 1 optional E2E recommendation
1 warning · 0 suggestionsWarningsWarnings do not block.
|
cv
left a comment
There was a problem hiding this comment.
Thanks for taking on this consolidation. The pure argument validation is a useful foundation, but the current CLI can silently skip E2E, so I don't think this is safe to merge yet.
-
Blocking: unsupported or misspelled subcommands exit successfully without running tests. The direct-entry guard calls
runCli()only whenprocess.argv[2] === "run"; every other value falls through and exits 0. I reproducednode --experimental-strip-types tools/e2e/live-vitest-invocation.mts runxreturning 0. The workflow boundary check also uses a substring match for...mts run, sorunxsatisfies it. Please make missing/unsupported subcommands fail and add direct CLI plus boundary regression tests. -
Termination behavior is not preserved. When the child is terminated by a signal or spawning fails,
spawnSynchas no numeric status and the wrapper converts that to exit 1. The linked issue requires exit behavior to remain unchanged; please preserve or deliberately map the original termination and test it. -
The linked issue's delivery scope is not met by this PR as submitted. It asks for a pinned first-party helper, adoption across compatible jobs, and the paired Docker-auth treatment. This changes one invocation while leaving the other repeated sites and auth work untouched. A preparatory slice can be reasonable, but it needs explicit maintainer agreement on the smaller scope rather than presenting this as the consolidation outcome. Please also coordinate with the contributor currently assigned to #6961.
Once the silent-success path and behavior-preservation gaps are fixed, the validation core should be in much better shape for reuse.
Addresses the blocking review on NVIDIA#6984. The direct-entry guard only ran the CLI when argv[2] was exactly "run"; every other value fell through and exited 0. `live-vitest-invocation.mts runx` returned success without running any test, and the workflow-boundary check matched `...mts run` as a substring, so `runx` satisfied it too. A typo could silently skip live E2E while the job reported success. - Reject a missing or unsupported subcommand with a usage message and a non-zero exit. - Match the subcommand as a whole word in the workflow-boundary validator so a typo cannot pass the boundary check either. - Preserve the termination behavior of the `npx vitest` call this replaced: a signal death maps to 128+signo rather than collapsing to 1, so a killed or OOM-reaped run stays distinguishable from an ordinary test failure. A spawn failure remains a generic failure. Tests cover each rejected subcommand shape through the real CLI, the missing subcommand, CLI-level input rejection, and the exit-code mapping. Refs NVIDIA#6961 Signed-off-by: Souvik Ghosh <138186578+souvikDevloper@users.noreply.github.com>
|
Thanks @cv — the silent-success path was a real bug and a bad one. Fixed in Blocking: unsupported subcommands exited 0. Confirmed exactly as you reproduced: Termination behavior. Also right — Scope + coordination with #6961's assignee. Agreed, and worth laying out the timeline so it's clear this wasn't a land-grab: I opened this PR on 2026-07-16, and @Shaurya2k06 was assigned #6961 on 2026-07-17. So this predates the assignment rather than cutting across it. Usefully, the work turns out to be complementary, not duplicate:
@Shaurya2k06 — no conflict from my side; our diffs don't overlap (yours is the auth anchor, mine is On the smaller scope: I'm not presenting this as the full consolidation outcome — you're right to push back on that framing. It's a preparatory slice, and it needs your explicit agreement rather than my assertion. If you'd prefer it not land as a partial, I'm equally happy to close it in favour of @Shaurya2k06's assigned work. Signed-off-by: Souvik Ghosh 138186578+souvikDevloper@users.noreply.github.com |
|
✨ Thanks for the refactor. Centralizing and validating the live-Vitest invocation improves maintainability and security posture. Ready for maintainer review. Related open issues: |
|
Thanks for confirming the Docker-auth piece, agreed, #7082 and this PR don't overlap. On the live-Vitest half though: #6996 (merged 2026-07-16T15:22:59Z) already added tools/e2e/live-vitest-invocation.mts and adopted it across all ~70 qualifying jobs in e2e.yaml, not just the one job here. This PR is now showing CONFLICTING/DIRTY against main, which lines up with that — it's colliding with #6996's version of the same file rather than complementing it. Given that, the live-Vitest half of #6961's Work list is already done via #6996. Worth closing this one rather than rebasing it, unless a rebase turns up something #6996 didn't cover, @cv, curious if you see anything #6984 still adds on top of #6996. |
|
Closing as superseded by merged #6996. That PR delivered the validated live-Vitest helper, adopted it across the 70 compatible jobs, preserved process exit/signal behavior, and added stricter malformed/repeated-option coverage. Merged #7079 separately delivered the trusted Docker-auth action portion of #6961. Current main therefore contains the intended behavior and a broader completed migration. Thank you for the focused initial implementation and tests. |
Refs #6961 (parent epic #6952).
This is the focused first slice the issue invites ("adopt only in jobs that share the exact current contract; report which jobs were left explicit and why"). It delivers the testable, security-relevant core — a validated live-Vitest invocation helper — and adopts it in the one job that shares the pure common contract.
What this does
e2e.yamlrepeats thenpx vitest run --project e2e-live … --reporter=default --reporter=test/e2e/risk-signal-reporter.tsshape across many jobs.tools/e2e/live-vitest-invocation.mtsowns that shape. A job supplies only a test path and-tselector; the project, reporters, and silence flag are fixed. Inputs cross a trust boundary (matrix-derived), so they are validated before any command is built:e2e-livetest/e2e/live/,..traversal, absolute, shell metacharacters, non-.test.tsRejection is fail-closed — nothing is quoted-away and run. The built argv is returned as an array (never a shell string).
Adopted in the canonical
live(registry-targets) job. TheNVIDIA_INFERENCE_API_KEY/TARGET_IDenv flow is unchanged; theworkflow-boundaryvalidator for that job now asserts the helper invocation and inputs instead of the raw command.Tests
test/e2e/support/live-vitest-invocation.test.ts(14) covers the project, path-traversal, absolute-path, shell-metacharacter,.test.ts, and selector rejections, plus argv building and fail-closed behavior on invalid input.typecheck:cliand biome are clean; I verified no newvalidateE2eWorkflowBoundaryerrors and no new test failures against a cleanmainbaseline (tools/**/*.mtsis covered bytsconfig.cli.json).Intentionally left explicit (and why)
Per the acceptance criteria, here's what this slice does not change:
export PATH=…andOPENSHELL_BIN=…setup, or run different files (skill-agent.test.ts, etc.). Adopting them needs helper inputs this slice deliberately omits; each also has its ownworkflow-boundaryassertions to migrate. Better as follow-up increments than a 70-site sweep on the most critical CI workflow.&dockerhub-auth, aliased ~69×) that lives on the trusted workflow revision. Moving the secret-bearing login into a.github/scripts/file would make it load from the tested checkout — branch-controllable — which the issue's own boundary explicitly forbids ("authentication … execute only from an immutable trusted action revision, never from the tested checkout"). The paireddocker-auth-cleanup.shis safe to keep as a script because it handles no secrets and validates paths. A trusted setup extraction would need an immutable-action mechanism; flagging for design rather than weakening the boundary here.expecthost installs — the issue itself says keep inline if the immutable-action rollout would weaken auditability; unchanged.Coordination
Behavior-preserving and touches only the one job's invocation body, so it composes with #6145's trigger changes rather than conflicting.
Signed-off-by: Souvik Ghosh 138186578+souvikDevloper@users.noreply.github.com
Summary by CodeRabbit
Improvements
Tests