diff --git a/docs/guide/ci.md b/docs/guide/ci.md index d6f035d709..0b58b99bcd 100644 --- a/docs/guide/ci.md +++ b/docs/guide/ci.md @@ -46,17 +46,21 @@ The GitHub Action sets up Vite+, the required Node.js version, and the package m with: node-version: '24' cache: true + task-cache: true - run: vp install - run: vp check - run: vp test - run: vp build ``` -With `cache: true`, `setup-vp` handles dependency caching for you automatically. +### Caching -::: tip -`setup-vp` caches package-manager data. To reuse Vite Task results across CI runs, add a separate [GitHub Actions cache for Vite Task](/guide/github-actions-cache). -::: +Vite+ offers two different caching functions which interact with GitHub Actions Cache. + +- With `cache: true`, `setup-vp` handles dependency caching for you automatically. + - You can manually choose the lockfile manifest with `cache-dependency-path`, leaving it blank will auto-infer it for you. +- With `task-cache: true`, `setup-vp` handles saving and restoring the Vite+ task cache between runs for you. + - Please read the [GitHub Actions Cache](/guide/github-actions-cache) page to learn more. ## GitLab CI/CD diff --git a/docs/guide/github-actions-cache.md b/docs/guide/github-actions-cache.md index ca2c0a24d1..e6104365be 100644 --- a/docs/guide/github-actions-cache.md +++ b/docs/guide/github-actions-cache.md @@ -4,6 +4,13 @@ Reusing Vite Task's cache across GitHub Actions runs is experimental. Test and measure it in your project before relying on it in CI. ::: +::: tip `setup-vp` support +The `setup-vp` action supports saving to GitHub Actions Cache with pre-wired defaults. +Continue reading to learn how to set up. + +In either case, you will still need to follow most instructions on this page. +::: + Vite Task stores task results in `node_modules/.vite/task-cache` at the workspace root. Restore that directory in later GitHub Actions runs so Vite Task can reuse previous task results. GitHub Actions cache and Vite Task make separate decisions: @@ -61,12 +68,39 @@ vp run lint # should print "cache hit" ## 2. Restore The Cache After Install -Restore `node_modules/.vite/task-cache` after `vp install`, because package installation can recreate or modify `node_modules`. +Use the `task-cache` toggle to enable saving the task cache to GitHub Actions Cache. +It will use the key configuration seen later on this page. -Set `` below to an exact version from the [`setup-vp` releases page](https://github.com/voidzero-dev/setup-vp/releases). You can use a commit SHA instead. +Set `` below to an exact version from the [`setup-vp` releases page](https://github.com/voidzero-dev/setup-vp/releases). You can also use a commit SHA instead, which can pin the action to a specific build. See [Automatic Version Updates](/guide/ci#automatic-version-updates) to configure Dependabot or Renovate. +```yaml +name: CI + +on: + pull_request: + push: + branches: [main] + +permissions: + contents: read + +jobs: + ci: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: voidzero-dev/setup-vp@ + with: + node-version: '24' + cache: true + task-cache: true +``` + +Otherwise, remember to restore `node_modules/.vite/task-cache` after `vp install`, because package installation can recreate or modify `node_modules`. + ```yaml [.github/workflows/ci.yml] name: CI