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

test(cli): cover runtime utility helpers#2944
cv merged 56 commits into
mainfrom
refactor/coverage-runtime-utility-helpers

Conversation

@cv
Copy link
Copy Markdown
Collaborator

@cv cv commented May 3, 2026

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
@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented May 3, 2026

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 3, 2026

📝 Walkthrough

Walkthrough

This PR adds test coverage for global CLI actions, introduces an optional runtime hook for sandbox upgrades, and removes obsolete v8 ignore comments from utility modules.

Changes

Global CLI Actions - Runtime Hooks

Layer / File(s) Summary
Type Definition
src/lib/global-cli-actions.ts
GlobalCliActionRuntimeHooks type adds optional upgradeSandboxes hook property.
Core Implementation
src/lib/global-cli-actions.ts
runUpgradeSandboxesAction checks for injected upgradeSandboxes hook; if present, invokes it; otherwise delegates to default module.
Test Suite
src/lib/global-cli-actions.test.ts
Hoisted mocks and module wiring test three scenarios: (1) action forwarding (onboard, setup, deploy, etc.), (2) injected runtime hooks (gateway recovery, OpenShell, upgrades), (3) fallback to defaults when hooks omitted.

Test Coverage & Code Cleanup

Layer / File(s) Summary
Comment Removal
src/lib/oclif-runner.ts, src/lib/terminal-style.ts
v8 ignore comment markers removed from non-test utility modules.
Terminal Style Tests
src/lib/terminal-style.test.ts
New test suite verifies exported color constants (B, D, G, R, RD, YW) are strings.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A hook for upgrades hops into place,
Tests spring forth with mocking grace,
v8 comments fade away,
Colors tested bright and gay,
The CLI now runs at quickened pace!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main objective of the PR: adding test coverage for runtime utility helpers by removing V8 ignore comments and introducing new tests.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/coverage-runtime-utility-helpers

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

@cv cv added the v0.0.34 Release target label May 4, 2026
@wscurran wscurran added CI/CD Use this label to identify issues with NemoClaw CI/CD pipeline or GitHub Actions. NemoClaw CLI Use this label to identify issues with the NemoClaw command-line interface (CLI). enhancement: testing Use this label to identify requests to improve NemoClaw test coverage. labels May 4, 2026
@cv cv requested a review from cjagwani May 5, 2026 00:27
@cv cv added v0.0.35 Release target and removed v0.0.34 Release target 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
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

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
Copy link
Copy Markdown
Contributor

@prekshivyas prekshivyas left a comment

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI/CD Use this label to identify issues with NemoClaw CI/CD pipeline or GitHub Actions. enhancement: testing Use this label to identify requests to improve NemoClaw test coverage. NemoClaw CLI Use this label to identify issues with the NemoClaw command-line interface (CLI). v0.0.35 Release target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants