fix: stabilize CLI tests on Node 22#8
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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.
Inline comments:
In @.github/workflows/ci.yml:
- Line 29: The CI workflow currently installs npm using a floating major
version, which can still change unexpectedly. Update the npm install step in the
workflow to use an exact pinned version instead of npm@11, and keep the pin
deliberate when bumping it. Use the existing npm install global step in the CI
workflow as the target to locate and adjust.
In `@package.json`:
- Around line 85-86: Update the Node engine constraint in package.json to match
the requirements of `@commitlint/cli` and `@commitlint/config-conventional` 21.2.0.
Adjust the engines field so local installs don’t permit Node versions below
22.12.0, and verify any related install/runtime checks still align with the new
minimum.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 3cc9c78c-38ee-45b8-825c-aa21c9b5ce8e
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (5)
.github/workflows/ci.yml.husky/commit-msgpackage.jsonsrc/gdsx-cli.jstest/gdsx-cli.test.js
Summary
Stabilize the CLI tests that were flaking on Node 22 in CI.
What Changed
maininsrc/gdsx-cli.jsto accept an optional injectedgenerateStatsdependency for testsWhy
The failing CI job was Node 22 only. The mocked-module CLI test sometimes fell through to the real
generateStatsimplementation, which then rangit diff HEAD~1..HEADin a repo state where that range was invalid for the test, causing the assertion to fail for the wrong reason.Impact
Validation
npm testnpx -y node@22 ./node_modules/vitest/vitest.mjs runSummary by CodeRabbit
Bug Fixes
Chores