Skip to content

test(cli): cover runtime utility helpers - #2944

Merged
cv merged 56 commits into
mainfrom
refactor/coverage-runtime-utility-helpers
May 5, 2026
Merged

cv merged 56 commits into
mainfrom
refactor/coverage-runtime-utility-helpers

Conversation

@cv

@cv cv commented May 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Remove broad coverage ignores from small runtime utility modules that already have or can have direct tests.

Stack Navigation

Changes

  • Removed the file-level V8 ignore from the oclif runner, which is already directly tested.
  • Removed the file-level V8 ignore from terminal style constants.
  • Added a small terminal style export test to keep the presentation constants covered.

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)

Verification

  • npx prek run --all-files passes
  • npm test passes
  • Tests added or updated for new or changed behavior
  • No secrets, API keys, or credentials committed
  • Docs updated for user-facing behavior changes
  • make 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: Carlos Villela [email protected]

Summary by CodeRabbit

  • New Features

    • Extended CLI actions with optional runtime hook configuration for sandbox upgrades, enabling customizable upgrade handling.
  • Chores

    • Cleaned up obsolete code annotations.

cv added 30 commits May 2, 2026 13:36
@cv
cv requested a review from cjagwani May 5, 2026 00:27
@cv cv added v0.0.35 and removed v0.0.34 labels May 5, 2026
@prekshivyas prekshivyas self-assigned this May 5, 2026
@cv
cv marked this pull request as ready for review May 5, 2026 22:14
@cv
cv changed the base branch from refactor/coverage-credentials-oclif-adapter to main May 5, 2026 22:14
@cv
cv enabled auto-merge (squash) May 5, 2026 22:14

@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 (1)
src/lib/global-cli-actions.test.ts (1)

95-101: ⚡ Quick win

Add an explicit fallback test for runUpgradeSandboxesAction with no hook injected.

This PR changes upgrade hook routing; covering the no-hook branch here would close the main regression gap in this suite.

Suggested test extension
 const mocks = vi.hoisted(() => ({
   backupAll: vi.fn(),
   garbageCollectImages: vi.fn().mockResolvedValue(undefined),
   help: vi.fn(),
   recoverNamedGatewayRuntime: vi.fn().mockResolvedValue({ recovered: true }),
   runDeployAction: vi.fn().mockResolvedValue(undefined),
   runOnboardAction: vi.fn().mockResolvedValue(undefined),
   runOpenshell: vi.fn(() => ({ status: 0 })),
   runSetupAction: vi.fn().mockResolvedValue(undefined),
   runSetupSparkAction: vi.fn().mockResolvedValue(undefined),
+  upgradeSandboxes: vi.fn().mockResolvedValue(undefined),
   version: vi.fn(),
 }));
@@
 vi.mock("./root-help-action", () => ({ help: mocks.help, version: mocks.version }));
+vi.mock("./upgrade-sandboxes-action", () => ({
+  upgradeSandboxes: mocks.upgradeSandboxes,
+}));
@@
   it("falls back to default runtime hooks", async () => {
     await expect(recoverNamedGatewayRuntime()).resolves.toEqual({ recovered: true });
     runOpenshellProviderCommand(["provider", "list"]);
+    await runUpgradeSandboxesAction({ check: true });

     expect(mocks.recoverNamedGatewayRuntime).toHaveBeenCalledWith();
     expect(mocks.runOpenshell).toHaveBeenCalledWith(["provider", "list"], undefined);
+    expect(mocks.upgradeSandboxes).toHaveBeenCalledWith({ check: true });
   });
🤖 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 `@src/lib/global-cli-actions.test.ts` around lines 95 - 101, Add a test that
covers the no-hook fallback for runUpgradeSandboxesAction: mirror the existing
"falls back to default runtime hooks" test pattern by invoking
runUpgradeSandboxesAction() (ensuring any necessary setup like
recoverNamedGatewayRuntime() is awaited if used elsewhere), assert the call
resolves to the expected default result, and verify the upgrade hook passthrough
by asserting mocks.runUpgradeSandboxes was called with no injected hook (or
undefined) and any expected default args; use the same mocking/verification
style as the existing tests to locate the code paths in
runUpgradeSandboxesAction and mocks.runUpgradeSandboxes.
🤖 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 `@src/lib/global-cli-actions.test.ts`:
- Around line 95-101: Add a test that covers the no-hook fallback for
runUpgradeSandboxesAction: mirror the existing "falls back to default runtime
hooks" test pattern by invoking runUpgradeSandboxesAction() (ensuring any
necessary setup like recoverNamedGatewayRuntime() is awaited if used elsewhere),
assert the call resolves to the expected default result, and verify the upgrade
hook passthrough by asserting mocks.runUpgradeSandboxes was called with no
injected hook (or undefined) and any expected default args; use the same
mocking/verification style as the existing tests to locate the code paths in
runUpgradeSandboxesAction and mocks.runUpgradeSandboxes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a35ecbaa-8417-45a1-a33b-2caeac64a861

📥 Commits

Reviewing files that changed from the base of the PR and between 15ffc33 and 5ac6369.

📒 Files selected for processing (5)
  • src/lib/global-cli-actions.test.ts
  • src/lib/global-cli-actions.ts
  • src/lib/oclif-runner.ts
  • src/lib/terminal-style.test.ts
  • src/lib/terminal-style.ts
💤 Files with no reviewable changes (2)
  • src/lib/oclif-runner.ts
  • src/lib/terminal-style.ts

@cv
cv requested review from ericksoa and prekshivyas May 5, 2026 22:33

@prekshivyas prekshivyas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Test-coverage PR with one description-completeness nit.

What landed:

  • global-cli-actions.test.ts (+102): new tests for the facade — action forwarding, hook injection, default fallback paths.
  • terminal-style.test.ts (+14): existence check on color constants.
  • oclif-runner.ts and terminal-style.ts: remove /* v8 ignore start */ so coverage counts these.
  • global-cli-actions.ts (+5/-2): adds upgradeSandboxes to GlobalCliActionRuntimeHooks with a fall-through in runUpgradeSandboxesAction — a new test-injection seam mirroring the existing recoverNamedGatewayRuntime/runOpenshell hooks. Production impact zero.

Nit (non-blocking): the PR description only mentions removing v8-ignores from oclif-runner + terminal-style; it doesn't mention the global-cli-actions.test.ts (102 of 121 added lines) or the new upgradeSandboxes hook. CodeRabbit's auto-summary did surface it. Worth pulling that into the body before squash-merge so the commit message reflects what landed.

CI: pr.yaml mostly green (lint/dco/check-hash/legacy-path-guard/changes PASS); CodeRabbit SUCCESS; macos-e2e/checks + pr-self-hosted builds still in flight at review time. No failures.

@cv
cv merged commit 8741a50 into main May 5, 2026
12 checks passed
cv added a commit that referenced this pull request May 5, 2026
## Summary
Stabilize CLI coverage runs by cleaning compiled CLI output before
coverage builds and validating that generated JavaScript sourcemaps
point at existing sources. This makes coverage use a clean `dist/`
baseline instead of stale generated files.

## Stack Navigation
- Position: 46 of 60
- Previous PR: [#2944 — test(cli): cover runtime utility
helpers](#2944)
- Next PR: [#2962 — refactor(cli): extract maintenance image
helpers](#2962)

## Changes
- Added `npm run clean:cli` for removing stale `dist/` artifacts without
changing the normal `build:cli` ordering.
- Added `scripts/check-dist-sourcemaps.ts` and `npm run
dist:sourcemaps:check` to fail fast on stale generated sourcemaps.
- Updated the CLI coverage pre-push hook to clean `dist/`, rebuild, and
validate sourcemaps before running coverage.
- Rebaselined CLI function coverage to the clean-dist value exposed by
the stabilized run.
- Added unit coverage for the sourcemap checker.

## Type of Change
- [x] 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)

## Verification
- [x] `npx prek run --all-files` passes
- [x] `npm test` passes
- [x] Tests added or updated for new or changed behavior
- [x] No secrets, API keys, or credentials committed
- [ ] Docs updated for user-facing behavior changes
- [ ] `make docs` builds without warnings (doc changes only)
- [ ] Doc pages follow the [style
guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md)
(doc changes only)
- [ ] New doc pages include SPDX header and frontmatter (new pages only)

---
Signed-off-by: Carlos Villela <[email protected]>

---------

Signed-off-by: Carlos Villela <[email protected]>
Co-authored-by: Prekshi Vyas <[email protected]>
@cv
cv deleted the refactor/coverage-runtime-utility-helpers branch May 27, 2026 21:17
@wscurran wscurran added area: ci CI workflows, checks, release automation, or GitHub Actions area: cli Command line interface, flags, terminal UX, or output area: e2e End-to-end tests, nightly failures, or validation infrastructure chore Build, CI, dependency, or tooling maintenance feature PR adds or expands user-visible functionality and removed CI/CD feature PR adds or expands user-visible functionality labels Jun 3, 2026
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 area: cli Command line interface, flags, terminal UX, or output area: e2e End-to-end tests, nightly failures, or validation infrastructure chore Build, CI, dependency, or tooling maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants