Skip to content

fix(checks): run Windows command shims through cmd - #6870

Merged
cv merged 2 commits into
NVIDIA:mainfrom
HwangJohn:codex/windows-check-runner-shims
Jul 14, 2026
Merged

fix(checks): run Windows command shims through cmd#6870
cv merged 2 commits into
NVIDIA:mainfrom
HwangJohn:codex/windows-check-runner-shims

Conversation

@HwangJohn

@HwangJohn HwangJohn commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Repository checks now invoke Windows .cmd shims through cmd.exe instead of spawning the shim directly. This keeps npm run checks usable on Windows where direct spawnSync('*.cmd') returns EINVAL, while leaving POSIX execution direct.

Changes

  • Split scripts/checks/run.ts into testable invocation helpers while preserving the existing check list and script entry point.
  • Route Windows check commands as cmd.exe /d /s /c <shim> ...args so tsx.cmd can run under Node on Windows.
  • Add integration coverage for Windows shim invocation, POSIX direct invocation, and null-status failure handling.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Docs updated for user-facing behavior changes
  • Docs not applicable — justification: contributor validation tooling behavior changed, but no command syntax, documented workflow, or user-facing CLI behavior changed.
  • Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging)
  • Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification:
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

Verification

  • PR description includes the DCO sign-off declaration and every commit appears as Verified in GitHub
  • Normal pre-commit, commit-msg, and pre-push hooks passed, or npm run check:diff passed when hooks were skipped or unavailable
  • Targeted behavior tests pass for the current change set, or tests are marked not applicable above — command/result or justification: DGX Spark/Linux: npx vitest run --project integration test/checks-runner.test.ts passed; Windows local mechanism check showed direct spawnSync('npm.cmd') returns EINVAL while cmd.exe /d /s /c npm.cmd --version exits 0.
  • Applicable broad gate passed — npm test for broad runtime/test-harness changes; npm run check for repo-wide validation/coverage changes — command/result: DGX Spark/Linux npm run checks, npm run typecheck:cli, and npm run check:diff passed. npm run check was attempted but the host lacks hadolint, and the separate all-files manual coverage stage exceeded the 10-minute local timeout; no broad-gate success is claimed.
  • Quality Gates section completed with required justifications or waivers
  • No secrets, API keys, or credentials committed
  • npm run docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: HwangJohn angelic805@gmail.com

Summary by CodeRabbit

  • Bug Fixes

    • Improved cross-platform execution of project checks, including reliable Windows command handling via ComSpec/cmd.exe routing.
    • Ensured failed or incomplete checks correctly trigger error exit codes.
  • Refactor

    • Check execution was reworked into reusable, exported runner utilities with injectable spawn/exit behavior while preserving CLI behavior.
  • Tests

    • Added coverage for Windows and POSIX invocation building, environment handling, output forwarding, and failure-path exit behavior.

Signed-off-by: HwangJohn <angelic805@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 43279f45-fcca-49ac-a271-57d9fa8cda26

📥 Commits

Reviewing files that changed from the base of the PR and between 45ae418 and 422a12f.

📒 Files selected for processing (2)
  • scripts/checks/run.ts
  • test/checks-runner.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/checks-runner.test.ts
  • scripts/checks/run.ts

📝 Walkthrough

Walkthrough

The checks script now exposes reusable, injectable runner APIs, builds platform-specific spawn invocations, preserves direct execution behavior, and adds tests for Windows, POSIX, and failure paths.

Changes

Checks runner refactor

Layer / File(s) Summary
Runner APIs and platform invocation
scripts/checks/run.ts
Typed spawn abstractions and configurable options support injected checks, platform, environment, spawn, and exit behavior. Windows commands use ComSpec or cmd.exe, while other platforms execute directly.
Runner behavior tests
test/checks-runner.test.ts
Tests cover Windows and POSIX invocations, inherited stdio, omitted shell settings, and exit handling for null and non-null failure statuses.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant runChecks
  participant buildCheckSpawnInvocation
  participant spawn
  participant exit
  runChecks->>buildCheckSpawnInvocation: build command and arguments
  runChecks->>spawn: execute check with inherited stdio
  spawn-->>runChecks: return status and error
  runChecks->>exit: exit with returned status or 1
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: executing Windows check shims through cmd.exe.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — Informational

Advisor assessment: Informational / high confidence
Next action: No advisor follow-up needed.
Findings: 0 blockers · 0 warnings · 0 suggestions
Status: No actionable findings remain in the canonical review ledger.

Model lanes

  • GPT-5.6 Terra (primary): Completed · high confidence · 0 blockers · 0 warnings · 0 suggestions
  • Nemotron 3 Ultra (second opinion): Completed · high confidence · 0 blockers · 1 warning · 0 suggestions
  • Model comparison: normalized findings differ; normalized E2E selections differ; Nemotron reported the same number of blockers, 1 more warning, the same number of suggestions.

Nemotron output stays in workflow artifacts and does not change the assessment above.

E2E guidance

Advisory only. E2E / PR Gate selects and runs jobs independently.

Recommended E2E: None

Workflow run details

This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
test/checks-runner.test.ts (1)

80-93: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add coverage for a non-null failing status code.

The only failure-path test uses status: null, which always collapses to exit(1) via result.status ?? 1. This can't catch a regression where the actual status code (e.g., 2) is dropped and exit(1) is hardcoded instead of passed through.

✅ Suggested additional test
+  it("exits with the check's status code on failure", () => {
+    const spawn = vi.fn((_command: string, _args: string[], _options: SpawnSyncOptions) => ({
+      status: 2,
+    }));
+    const exit = vi.fn((code?: number): never => {
+      throw new Error(`exit ${code}`);
+    });
+
+    expect(() => runChecks({ checks: [sampleCheck], platform: "linux", spawn, exit })).toThrow(
+      "exit 2",
+    );
+    expect(exit).toHaveBeenCalledWith(2);
+  });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/checks-runner.test.ts` around lines 80 - 93, Add a test alongside the
existing no-status case that configures the mocked spawn result with a non-null
failing status such as 2, invokes runChecks with the same sampleCheck setup, and
asserts exit is called with 2 while preserving the thrown-exit assertion. This
should verify the actual status code is propagated rather than replaced with the
default 1.
scripts/checks/run.ts (1)

122-141: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Spawn failures without a status code are logged with no diagnostic detail.

When spawn fails to even start (e.g., cmd.exe/shim not found → ENOENT), spawnSync-style results typically carry an error field with status: null. The loop only logs Check failed: ${check.name} and exits — the actual cause (result.error?.message) is discarded, making CI failures harder to diagnose.

🩹 Proposed fix to surface the underlying error
     if (result.status !== 0) {
-      console.error(`Check failed: ${check.name}`);
+      console.error(`Check failed: ${check.name}`, "error" in result ? result.error : "");
       exit(result.status ?? 1);
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/checks/run.ts` around lines 122 - 141, Update the failure handling in
runChecks to include result.error?.message when a check has no status code,
while preserving the existing check name and exit behavior. Ensure spawn
failures such as ENOENT surface their underlying diagnostic in the console.error
output.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@scripts/checks/run.ts`:
- Around line 122-141: Update the failure handling in runChecks to include
result.error?.message when a check has no status code, while preserving the
existing check name and exit behavior. Ensure spawn failures such as ENOENT
surface their underlying diagnostic in the console.error output.

In `@test/checks-runner.test.ts`:
- Around line 80-93: Add a test alongside the existing no-status case that
configures the mocked spawn result with a non-null failing status such as 2,
invokes runChecks with the same sampleCheck setup, and asserts exit is called
with 2 while preserving the thrown-exit assertion. This should verify the actual
status code is propagated rather than replaced with the default 1.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: e74e5e1c-0b90-486d-a412-c349d1defbd7

📥 Commits

Reviewing files that changed from the base of the PR and between 20130dd and 45ae418.

📒 Files selected for processing (2)
  • scripts/checks/run.ts
  • test/checks-runner.test.ts

Signed-off-by: HwangJohn <angelic805@gmail.com>
@wscurran wscurran added area: ci CI workflows, checks, release automation, or GitHub Actions bug-fix PR fixes a bug or regression platform: windows Affects native Windows environments labels Jul 14, 2026
@wscurran

Copy link
Copy Markdown
Contributor

✨ Thanks for the fix, @HwangJohn. Routing Windows command shims through cmd.exe should resolve the EINVAL issue on Windows. Ready for maintainer review.

@cv cv self-assigned this Jul 14, 2026
@cv
cv merged commit 87c8960 into NVIDIA:main Jul 14, 2026
73 of 75 checks passed
@cv

cv commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

CI is green and the current revision is approved. main has advanced since this head was tested, and maintainer edits are disabled for this fork, so I cannot update the branch safely. Please update this branch from current main; I will re-check the new head and its gates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci CI workflows, checks, release automation, or GitHub Actions bug-fix PR fixes a bug or regression platform: windows Affects native Windows environments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants