Skip to content

test(cli): stabilize coverage dist sourcemaps#2961

Merged
cv merged 61 commits into
mainfrom
test/stabilize-cli-coverage-dist
May 5, 2026
Merged

test(cli): stabilize coverage dist sourcemaps#2961
cv merged 61 commits into
mainfrom
test/stabilize-cli-coverage-dist

Conversation

@cv
Copy link
Copy Markdown
Collaborator

@cv cv commented May 4, 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

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

  • 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

  • Chores

    • Enhanced pre-commit checks with additional build and cleanup steps before testing
    • Added validation for sourcemap integrity in the distribution directory
    • Adjusted code coverage thresholds for CLI functions
  • Tests

    • Added tests for sourcemap validation

cv added 30 commits May 2, 2026 13:36
@cv cv self-assigned this May 4, 2026
@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented May 4, 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 4, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 3b05c242-58fe-4252-90e8-5611b51d5548

📥 Commits

Reviewing files that changed from the base of the PR and between 8741a50 and 26c85d7.

📒 Files selected for processing (5)
  • .pre-commit-config.yaml
  • ci/coverage-threshold-cli.json
  • package.json
  • scripts/check-dist-sourcemaps.ts
  • test/dist-sourcemaps.test.ts

📝 Walkthrough

Walkthrough

A new source map validation feature is introduced that scans the dist directory for .js.map files, verifies that all referenced sources exist, and integrates into the pre-commit test pipeline via npm scripts and configuration updates.

Changes

Source Map Validation Feature

Layer / File(s) Summary
Core Implementation
scripts/check-dist-sourcemaps.ts
New TypeScript script that defines source map types, directory traversal logic, and a public function findMissingDistSourcemapSources(distDir: string): string[] to scan .js.map files and verify referenced sources exist. Treats internal sources as relative to map file and external sources (node:, webpack://, node_modules, absolute paths) as valid.
NPM Script Integration
package.json
Two scripts added: clean:cli to recursively remove dist directory, and dist:sourcemaps:check to invoke the check script via tsx.
Pre-commit Hook Integration
.pre-commit-config.yaml
Updated test-cli hook to run npm run clean:cli && npm run build:cli && npm run dist:sourcemaps:check before Vitest, ensuring builds are clean and sourcemaps are validated prior to test execution.
Tests & Coverage Config
test/dist-sourcemaps.test.ts, ci/coverage-threshold-cli.json
New test file validates findMissingDistSourcemapSources against temporary sourcemap structures with present and missing sources. Coverage threshold for "functions" adjusted from 32 to 31.8 to accommodate new code.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A rabbit hops through dist with care,
Checking maps for sources fair,
Builds now clean before tests run,
Sourcemaps verified—our work is done! ✨

✨ 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 test/stabilize-cli-coverage-dist

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 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. CI/CD Use this label to identify issues with NemoClaw CI/CD pipeline or GitHub Actions. 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 requested a review from prekshivyas May 5, 2026 22:40
cv added a commit that referenced this pull request May 5, 2026
## Summary
Remove broad coverage ignores from small runtime utility modules that
already have or can have direct tests.

## Stack Navigation
- Position: 45 of 60
- Previous PR: [#2943 — test(cli): cover global action
facade](#2943)
- Next PR: [#2961 — test(cli): stabilize coverage dist
sourcemaps](#2961)

## 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
- [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]>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## 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.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Carlos Villela <[email protected]>
Co-authored-by: Prekshi Vyas <[email protected]>
@cv cv marked this pull request as ready for review May 5, 2026 22:46
@cv cv changed the base branch from refactor/coverage-runtime-utility-helpers to main May 5, 2026 22:46
@cv cv enabled auto-merge (squash) May 5, 2026 22:47
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 infrastructure / build hygiene PR — 5 files / +120 / -2, no src/ touched.

  • clean:cli + dist:sourcemaps:check npm scripts added.
  • New scripts/check-dist-sourcemaps.ts walks .js.map files and asserts every sources entry resolves on disk; correctly skips node:/webpack:///node_modules/absolute paths.
  • Pre-commit test-cli hook now runs clean:cli && build:cli && dist:sourcemaps:check before vitest coverage — defensive against stale dist/ polluting coverage.
  • Coverage function threshold rebaselined 32 → 31.8 to reflect the real value once stale dist files (which had been counting deleted code as "covered") are eliminated. Rationale clearly explained in the PR description.
  • +35 lines of fixture-based test for the sourcemap checker.

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

@cv cv merged commit e7e73c1 into main May 5, 2026
12 of 13 checks passed
cv added a commit that referenced this pull request May 5, 2026
## Summary
Extract pure Docker image parsing and orphan-selection logic from the
subprocess-heavy maintenance action module.

## Stack Navigation
- Position: 47 of 60
- Previous PR: [#2961 — test(cli): stabilize coverage dist
sourcemaps](#2961)
- Next PR: [#2963 — refactor(cli): extract upgrade sandbox
helpers](#2963)

## Changes
- Added `maintenance-image-helpers.ts` for Docker image row parsing and
registered image-tag comparison.
- Updated `garbageCollectImages` to use the extracted helpers while
keeping Docker/prompt orchestration in `maintenance-actions.ts`.
- Added direct helper coverage for image parsing, registered tag
collection, and orphan detection.

## 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]>
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