Skip to content

feat: cache vp CLI installation to speed up setup - #8

Merged
fengmk2 merged 8 commits into
mainfrom
cache-vp-itself
Mar 19, 2026
Merged

feat: cache vp CLI installation to speed up setup#8
fengmk2 merged 8 commits into
mainfrom
cache-vp-itself

Conversation

@fengmk2

@fengmk2fengmk2 commented Mar 18, 2026

Copy link
Copy Markdown
Member

Summary

  • Cache the ~/.vite-plus/ directory using @actions/cache, keyed by OS + arch + resolved version
  • On cache hit, skip the install script entirely (~60s → ~2-3s)
  • For version: "latest", resolve actual semver from npm registry so the cache key updates when new versions are released
  • Update install URLs from staging.viteplus.dev to viteplus.dev

Test plan

  • All 73 existing + new tests pass (vp run test)
  • Lint/format clean (vp run check:fix)
  • Build succeeds (vp run build)
  • First CI run: installs vp fresh, saves cache in post phase
  • Second CI run: restores vp from cache, skips install (should be ~2-3s)

🤖 Generated with Claude Code

The vp CLI was re-downloaded from viteplus.dev on every CI run (~60s).
Now the ~/.vite-plus/ directory is cached using @actions/cache, keyed by
OS, arch, and resolved version. On cache hit the install script is
skipped entirely, reducing setup to a few seconds.
Also updates install URLs from staging.viteplus.dev to viteplus.dev.
CopilotAI review requested due to automatic review settings March 18, 2026 16:21

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

Pull request overview

Adds a dedicated GitHub Actions cache for the Vite+ (vp) installation directory, enabling faster runs by restoring ~/.vite-plus (or Windows equivalent) when possible, and saving it in the post step.

Changes:

  • Introduces cache-vp module to resolve latest, restore the Vite+ home directory from cache, and save it on cache misses.
  • Integrates Vite+ cache restore into the install flow and saves the Vite+ cache during the post step.
  • Adds getVitePlusHome() utility and new action state keys to support the cache flow.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
FileDescription
src/utils.tsAdds getVitePlusHome() helper used by install/cache code.
src/types.tsAdds new State enum entries for vp cache keys.
src/install-viteplus.tsRestores vp from cache before installing; uses Vite+ home helper for PATH setup.
src/index.tsCalls saveVpCache() during the post step.
src/cache-vp.tsNew module implementing version resolution + cache restore/save for vp home.
src/cache-vp.test.tsNew tests covering version resolution and vp cache restore/save behavior.

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

Comment threadsrc/utils.ts Outdated
Comment threadsrc/cache-vp.ts Outdated
Comment threadsrc/install-viteplus.ts
Avoids throwing when HOME/USERPROFILE env vars are unset (e.g.
self-hosted runners), keeping cache and PATH setup best-effort.
Previously cached the whole ~/.vite-plus/ directory, which could include
Node.js state from `vp env use` and mutations from later workflow steps.
Now caches only ~/.vite-plus/{version}/ and recreates the current/bin
symlinks after restore. This prevents cross-contamination in multi-Node
matrix builds and avoids baking unrelated state into the cache.
CopilotAI review requested due to automatic review settings March 18, 2026 16:37
@fengmk2
fengmk2 marked this pull request as draft March 18, 2026 16:42

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

Pull request overview

Adds a dedicated GitHub Actions cache for the Vite+ (vp) binary installation to speed up runs by restoring a versioned ~/.vite-plus/<version> directory and recreating expected symlinks.

Changes:

  • Introduce cache-vp module to resolve versions, restore/save the vp binary cache, and rebuild current/bin links.
  • Update installer flow to attempt cache restore before downloading/installing, and always attempt to save the vp cache in post.
  • Centralize ~/.vite-plus path computation via getVitePlusHome() and add new State keys for vp cache metadata.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
FileDescription
src/utils.tsAdds getVitePlusHome() helper to standardize vp home directory resolution.
src/types.tsAdds new State entries to persist vp cache key/version across main/post.
src/install-viteplus.tsAttempts version resolution + vp cache restore before fresh install; updates install URLs.
src/index.tsSaves the vp binary cache during the post step (in addition to optional dependency cache).
src/cache-vp.tsImplements vp version resolution, cache restore/save, and symlink recreation.
src/cache-vp.test.tsAdds unit tests covering resolve/restore/save vp cache behavior.

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

Comment threadsrc/cache-vp.ts Outdated
Comment threadsrc/cache-vp.ts Outdated
Comment threadsrc/cache-vp.ts Outdated
Include the resolved node-version in the cache key so multi-Node matrix
builds each get their own cache entry. Revert the version-specific
directory + symlink approach in favor of caching the entire ~/.vite-plus/
as a black box — avoids coupling to vp's internal installation layout.
Node version is now resolved before installVitePlus() so it can be
included in the cache key.
@fengmk2

Copy link
Copy Markdown
MemberAuthor

@codex review

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:2d17a079b2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadsrc/utils.ts
Comment threadsrc/cache-vp.ts
@fengmk2
fengmk2 marked this pull request as ready for review March 19, 2026 01:08
CopilotAI review requested due to automatic review settings March 19, 2026 01:08
fengmk2 added a commit to node-modules/urllib that referenced this pull request Mar 19, 2026

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

Pull request overview

This PR speeds up the GitHub Action’s setup by caching the Vite+ (vp) installation directory (~/.vite-plus) using @actions/cache, so subsequent runs can skip the install script when a matching cache entry is restored.

Changes:

  • Add vp-specific cache restore/save logic keyed by OS + arch + resolved vp version + node version.
  • Resolve version: "latest" to an actual semver from the npm registry to avoid stale cache keys when new versions are released.
  • Update install script URLs from staging.viteplus.dev to viteplus.dev and refactor home-dir handling.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
src/utils.tsAdds getVitePlusHome() helper for consistent ~/.vite-plus path resolution.
src/types.tsAdds new action state keys for vp cache primary/matched keys.
src/install-viteplus.tsRestores vp from cache when available; otherwise installs and ensures vp bin is on PATH.
src/index.tsReorders setup to resolve node version first (for vp cache key) and saves vp cache in post step.
src/cache-vp.tsImplements vp version resolution + cache restore/save using @actions/cache.
src/cache-vp.test.tsAdds unit tests for version resolution and vp cache restore/save behaviors.
Comments suppressed due to low confidence (1)

src/index.ts:33

  • The step numbering comments are now inconsistent: after introducing the new Node-version resolution step, there are two “Step 3” comments (Node setup and cache restore). Update the numbering (or switch to non-numbered headings) so the execution order remains clear.
 // Step 3: Set up Node.js version if specified
if (nodeVersion) {
info(`Setting up Node.js ${nodeVersion} via vp env use...`);
await exec("vp", ["env", "use", nodeVersion]);
}
// Step 3: Restore cache if enabled
if (inputs.cache) {

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

Comment threadsrc/cache-vp.test.ts Outdated
Comment threadsrc/cache-vp.ts Outdated
…caching
resolveVersion() now uses a semver regex to detect precise versions
(e.g. "0.1.8", "1.0.0-beta.1") and passes them through. Any other
input (e.g. "latest", "alpha", "canary") is treated as a dist-tag
and resolved to a precise version via the npm registry.
CopilotAI review requested due to automatic review settings March 19, 2026 02:15

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

Pull request overview

This PR adds a dedicated cache for the Vite+ (vp) CLI installation to significantly speed up GitHub Action setup by avoiding re-downloading/re-installing the CLI on subsequent runs.

Changes:

  • Add @actions/cache-backed caching of ~/.vite-plus/, keyed by OS + arch + resolved Vite+ version (+ Node version).
  • Resolve dist-tag versions (e.g. latest, alpha) to a concrete semver via the npm registry for stable cache keying.
  • Update install script URLs to viteplus.dev and wire cache save into the post step.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
src/utils.tsAdd getVitePlusHome() helper for consistent ~/.vite-plus pathing.
src/types.tsAdd new post-state keys for vp cache primary/matched keys.
src/install-viteplus.tsRestore from vp cache before running install script; update install URLs.
src/index.tsResolve Node version earlier for cache keying; save vp cache in post step.
src/cache-vp.tsImplement version resolution + restore/save logic for vp installation cache.
src/cache-vp.test.tsAdd unit tests for version resolution and vp cache restore/save behavior.
README.mdDocument the new Vite+ installation cache behavior and key structure.

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

Comment threadsrc/cache-vp.ts
Comment threadREADME.md Outdated
@fengmk2

Copy link
Copy Markdown
MemberAuthor

good enough fengmk2/npmx.dev#2

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: MK (fengmk2) <fengmk2@gmail.com>
CopilotAI review requested due to automatic review settings March 19, 2026 07:01
@fengmk2
fengmk2 merged commit e1609b4 into mainMar 19, 2026
11 checks passed
@fengmk2
fengmk2 deleted the cache-vp-itself branch March 19, 2026 07:02

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

Pull request overview

This PR adds a best-effort GitHub Actions cache for the Vite+ CLI installation to reduce setup time by restoring ~/.vite-plus/ when a matching cache entry exists, and updates install script URLs to the production domain.

Changes:

  • Add src/cache-vp.ts to resolve Vite+ versions (including dist-tags) and restore/save a cache for ~/.vite-plus/.
  • Integrate the Vite+ cache into the main/post action flow, and add a getVitePlusHome() helper.
  • Document the new installation cache behavior in the README and add unit tests.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
FileDescription
src/utils.tsAdds getVitePlusHome() to centralize the ~/.vite-plus path logic.
src/types.tsAdds new State keys to support vp cache restore/save across main/post.
src/install-viteplus.tsAttempts cache restore before running install scripts; uses shared home helper.
src/index.tsReorders steps to resolve Node version early for cache keying; saves vp cache in post.
src/cache-vp.tsImplements version resolution + @actions/cache restore/save for ~/.vite-plus/.
src/cache-vp.test.tsAdds test coverage for version resolution and vp cache restore/save behaviors.
README.mdDocuments automatic Vite+ installation caching and key format.

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

Comment threadsrc/cache-vp.ts
Comment on lines +34 to +39
export async function restoreVpCache(version: string, nodeVersion: string): Promise<boolean> {
const vpHome = getVitePlusHome();
const runnerOS = process.env.RUNNER_OS || platform();
const runnerArch = arch();
const primaryKey = `setup-vp-${runnerOS}-${runnerArch}-${version}-node${nodeVersion}`;

Comment threadsrc/index.ts
Comment on lines 63 to +68
async function runPost(inputs: Inputs): Promise<void> {
// Save cache if enabled
const saves: Promise<void>[] = [saveVpCache()];
if (inputs.cache) {
await saveCache();
saves.push(saveCache());
}
await Promise.all(saves);
Comment threadsrc/index.ts
Comment on lines 5 to 9
import { runViteInstall } from "./run-install.js";
import { restoreCache } from "./cache-restore.js";
import { saveCache } from "./cache-save.js";
import { saveVpCache } from "./cache-vp.js";
import { State, Outputs } from "./types.js";
Comment threadREADME.md
Comment on lines +125 to +127
The cache key includes OS, architecture, Vite+ version, and Node.js version:
`setup-vp-{OS}-{arch}-{vp-version}-node{node-version}`

Sign up for freeto 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

@fengmk2