Skip to content

Commit e7fe859

Browse files
fengmk2claude
andcommitted
refactor: use vite pm cache dir and add cache tests for npm/yarn
- Use `vite pm cache dir` to get cache directory for pnpm, npm, and yarn instead of calling individual package manager commands - Add test-cache-pnpm, test-cache-npm, and test-cache-yarn jobs to verify cache functionality works with different lock file types Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent c5456e4 commit e7fe859

3 files changed

Lines changed: 73 additions & 28 deletions

File tree

.github/workflows/test.yml

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
vp --version
3535
vite --version
3636
37-
test-cache:
37+
test-cache-pnpm:
3838
runs-on: ubuntu-latest
3939
steps:
4040
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
@@ -43,21 +43,86 @@ jobs:
4343
with:
4444
node-version: '22'
4545

46-
- name: Create test project
46+
- name: Create test project with pnpm-lock.yaml
4747
run: |
4848
mkdir -p test-project
4949
cd test-project
5050
echo '{"name":"test-project","private":true}' > package.json
51+
touch pnpm-lock.yaml
5152
52-
- name: Setup Vite+ with cache
53+
- name: Setup Vite+ with pnpm cache
54+
uses: ./
55+
id: setup
56+
with:
57+
registry: github
58+
github-token: ${{ secrets.VP_TOKEN }}
59+
run-install: false
60+
cache: true
61+
cache-dependency-path: test-project/pnpm-lock.yaml
62+
63+
- name: Verify installation
64+
run: |
65+
vp --version
66+
echo "Installed version: ${{ steps.setup.outputs.version }}"
67+
echo "Cache hit: ${{ steps.setup.outputs.cache-hit }}"
68+
69+
test-cache-npm:
70+
runs-on: ubuntu-latest
71+
steps:
72+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
73+
74+
- uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6
75+
with:
76+
node-version: '22'
77+
78+
- name: Create test project with package-lock.json
79+
run: |
80+
mkdir -p test-project
81+
cd test-project
82+
echo '{"name":"test-project","private":true}' > package.json
83+
echo '{"name":"test-project","lockfileVersion":3}' > package-lock.json
84+
85+
- name: Setup Vite+ with npm cache
86+
uses: ./
87+
id: setup
88+
with:
89+
registry: github
90+
github-token: ${{ secrets.VP_TOKEN }}
91+
run-install: false
92+
cache: true
93+
cache-dependency-path: test-project/package-lock.json
94+
95+
- name: Verify installation
96+
run: |
97+
vp --version
98+
echo "Installed version: ${{ steps.setup.outputs.version }}"
99+
echo "Cache hit: ${{ steps.setup.outputs.cache-hit }}"
100+
101+
test-cache-yarn:
102+
runs-on: ubuntu-latest
103+
steps:
104+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
105+
106+
- uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6
107+
with:
108+
node-version: '22'
109+
110+
- name: Create test project with yarn.lock
111+
run: |
112+
mkdir -p test-project
113+
cd test-project
114+
echo '{"name":"test-project","private":true}' > package.json
115+
touch yarn.lock
116+
117+
- name: Setup Vite+ with yarn cache
53118
uses: ./
54119
id: setup
55120
with:
56121
registry: github
57122
github-token: ${{ secrets.VP_TOKEN }}
58123
run-install: false
59124
cache: true
60-
cache-dependency-path: pnpm-lock.yaml
125+
cache-dependency-path: test-project/yarn.lock
61126

62127
- name: Verify installation
63128
run: |

0 commit comments

Comments
 (0)