Skip to content

Commit bdf0af2

Browse files
committed
test: add strict version-match jobs to reproduce #225 / #227
The existing version tests only check output format via regex, which is why the PATH-shadowing bug (#230) slipped through — the bootstrap pnpm's version string matched the regex just as well as the requested version. - test_version_respects_request: runs the action with `version: 9.15.5` and `version: 10.33.0` (both differ from the bootstrap) and asserts that `pnpm --version` matches exactly. Regression test for #225/#230. - test_package_manager_field: writes a `packageManager: pnpm@<v>` entry into package.json, runs the action with no `version:` input, and asserts exact match. Reproduces #227; currently expected to fail since `packageManager` extraction was intentionally not added.
1 parent 71c9247 commit bdf0af2

1 file changed

Lines changed: 76 additions & 0 deletions

File tree

.github/workflows/test.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,82 @@ jobs:
129129
pnpm add is-odd
130130
shell: bash
131131

132+
test_version_respects_request:
133+
name: 'Test version input is actually installed (${{ matrix.version }}, ${{ matrix.os }})'
134+
# Regression test for #225 / #230: the bootstrap pnpm on PATH was shadowing the self-updated binary,
135+
# so a user requesting e.g. `version: 9.15.5` would silently get the bootstrap version.
136+
137+
runs-on: ${{ matrix.os }}
138+
139+
strategy:
140+
fail-fast: false
141+
matrix:
142+
os:
143+
- ubuntu-latest
144+
- macos-latest
145+
- windows-latest
146+
version:
147+
- '9.15.5'
148+
- '10.33.0'
149+
150+
steps:
151+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
152+
153+
- name: Run the action
154+
uses: ./
155+
with:
156+
version: ${{ matrix.version }}
157+
158+
- name: 'Test: exact version installed'
159+
run: |
160+
required='${{ matrix.version }}'
161+
actual="$(pnpm --version)"
162+
echo "pnpm version: ${actual}"
163+
if [ "${actual}" != "${required}" ]; then
164+
echo "Expected pnpm version ${required}, but got ${actual}"
165+
exit 1
166+
fi
167+
shell: bash
168+
169+
test_package_manager_field:
170+
name: 'Test packageManager field is respected (${{ matrix.version }}, ${{ matrix.os }})'
171+
# Reproduces #227: when `packageManager` is set in package.json and no `version:` input is given,
172+
# the action should install the version specified there.
173+
174+
runs-on: ${{ matrix.os }}
175+
176+
strategy:
177+
fail-fast: false
178+
matrix:
179+
os:
180+
- ubuntu-latest
181+
- macos-latest
182+
- windows-latest
183+
version:
184+
- '9.15.5'
185+
- '10.33.0'
186+
187+
steps:
188+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
189+
190+
- name: Set up package.json with packageManager field
191+
run: echo '{"packageManager":"pnpm@${{ matrix.version }}"}' > package.json
192+
shell: bash
193+
194+
- name: Run the action
195+
uses: ./
196+
197+
- name: 'Test: exact version installed'
198+
run: |
199+
required='${{ matrix.version }}'
200+
actual="$(pnpm --version)"
201+
echo "pnpm version: ${actual}"
202+
if [ "${actual}" != "${required}" ]; then
203+
echo "Expected pnpm version ${required}, but got ${actual}"
204+
exit 1
205+
fi
206+
shell: bash
207+
132208
test_dev_engines:
133209
name: Test with devEngines.packageManager
134210

0 commit comments

Comments
 (0)