Skip to content

feat: re-enable vp CLI caching#15

Closed
fengmk2 wants to merge 1 commit intomainfrom
enable-vp-cli-cache
Closed

feat: re-enable vp CLI caching#15
fengmk2 wants to merge 1 commit intomainfrom
enable-vp-cli-cache

Conversation

@fengmk2
Copy link
Member

@fengmk2 fengmk2 commented Mar 20, 2026

Summary

  • Re-enable vp CLI caching that was temporarily disabled due to Windows Cannot find module 'which' issue (Windows runner failures with latest action version #10)
  • Wire up SETUP_VP_FORCE_INSTALL env var to bypass cache restore, enabling CI to test both cached and fresh install paths
  • Re-enable skipped unit tests for restoreVpCache and saveVpCache

Test plan

  • CI passes on all platforms (ubuntu, macos, windows) with force-install: false (cached path)
  • CI passes on all platforms with force-install: true (fresh install path)
  • All 89 unit tests pass including previously-skipped cache tests

🤖 Generated with Claude Code

Re-enable the vp CLI cache that was temporarily disabled due to the
Windows `Cannot find module 'which'` issue (#10). Add
SETUP_VP_FORCE_INSTALL env var check to bypass cache in CI testing.
Copilot AI review requested due to automatic review settings March 20, 2026 06:11
@fengmk2 fengmk2 marked this pull request as draft March 20, 2026 06:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR re-enables caching for the Vite+ (vp) CLI in the setup-vp GitHub Action, adding a CI-controlled bypass to validate both cached and fresh install flows, and re-enabling the previously skipped cache unit tests.

Changes:

  • Re-enable vp CLI cache restore/save logic, with an opt-out via SETUP_VP_FORCE_INSTALL=true.
  • Wire SETUP_VP_FORCE_INSTALL to skip cache restore.
  • Re-enable unit tests for restoreVpCache and saveVpCache.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/cache-vp.ts Restores vp cache restore/save behavior and adds SETUP_VP_FORCE_INSTALL restore bypass.
src/cache-vp.test.ts Un-skips and runs cache-related unit tests again.
Comments suppressed due to low confidence (1)

src/cache-vp.test.ts:90

  • The new SETUP_VP_FORCE_INSTALL branch in restoreVpCache isn’t covered by unit tests, and these tests don’t explicitly clear/stub that env var. If a developer (or CI) runs tests with SETUP_VP_FORCE_INSTALL=true set, these cases will fail unexpectedly. Consider stubbing it to "false" in beforeEach, and add a test asserting that restoreVpCache skips the restore when SETUP_VP_FORCE_INSTALL is "true" (and that no cache restore call is made).
describe("restoreVpCache", () => {
  beforeEach(() => {
    vi.stubEnv("RUNNER_OS", "Linux");
    vi.stubEnv("HOME", "/home/runner");
  });

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 34 to +38
export async function restoreVpCache(version: string, nodeVersion: string): Promise<boolean> {
// FIXME: Re-enable vp CLI caching after the new version of vite-plus is released
// that fixes the Windows `Cannot find module 'which'` issue (#10).
info("Vp CLI caching is temporarily disabled");
return false;
if (process.env.SETUP_VP_FORCE_INSTALL === "true") {
info("Skipping vp cache restore (SETUP_VP_FORCE_INSTALL=true)");
return false;
}
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

When SETUP_VP_FORCE_INSTALL is "true", this early return happens before computing/saving VpCachePrimaryKey. As a result, the post step’s saveVpCache() will always see an empty primary key and skip saving, so the “fresh install” path can never populate/warm the vp cache. If the intent is to bypass only the restore, consider still generating the cache key and calling saveState(State.VpCachePrimaryKey, ...) (and logging) while skipping just the restoreCache(...) call.

Copilot uses AI. Check for mistakes.
@fengmk2
Copy link
Member Author

fengmk2 commented Mar 20, 2026

Files extracted from the cache cannot be used directly, let's wait for voidzero-dev/vite-plus#744

Error: Cannot find module 'which'
Require stack:
- C:\Users\runneradmin\.vite-plus\0.1.13\node_modules\.pnpm\cross-spawn@7.0.6\node_modules\cross-spawn\lib\util\resolveCommand.js
- C:\Users\runneradmin\.vite-plus\0.1.13\node_modules\.pnpm\cross-spawn@7.0.6\node_modules\cross-spawn\lib\parse.js
- C:\Users\runneradmin\.vite-plus\0.1.13\node_modules\.pnpm\cross-spawn@7.0.6\node_modules\cross-spawn\index.js

@fengmk2 fengmk2 closed this Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants