-
Notifications
You must be signed in to change notification settings - Fork 15
406 lines (368 loc) · 11.7 KB
/
Copy pathtest.yaml
File metadata and controls
406 lines (368 loc) · 11.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
name: Test Action
on:
pull_request:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
jobs:
smoke:
# Direct binary download + pnpm on PATH across OSes and architectures.
name: 'Smoke (${{ matrix.os }} / pnpm ${{ matrix.version }})'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
version: '12.0.0-alpha.19'
- os: ubuntu-24.04-arm
version: '12.0.0-alpha.19'
- os: macos-latest
version: '12.0.0-alpha.19'
- os: windows-latest
version: '12.0.0-alpha.19'
steps:
- uses: actions/checkout@v6
- id: pnpm
uses: ./
with:
version: ${{ matrix.version }}
- name: 'Test: pnpm version on PATH matches request'
env:
BIN_DEST: ${{ steps.pnpm.outputs.bin-dest }}
REQUIRED: ${{ matrix.version }}
run: |
set -e
which pnpm
actual="$(pnpm --version)"
echo "pnpm --version: ${actual}"
if [ "${actual}" != "${REQUIRED}" ]; then
echo "Expected pnpm ${REQUIRED}, got ${actual}"
exit 1
fi
bin_dest_version="$("$BIN_DEST/pnpm" --version)"
if [ "${bin_dest_version}" != "${REQUIRED}" ]; then
echo "Expected ${REQUIRED} via bin_dest, got ${bin_dest_version}"
exit 1
fi
shell: bash
version-from-dist-tag:
# `version` may be an npm dist-tag; it is resolved against the main
# `pnpm` package's dist-tags.
name: 'Version from dist-tag (next-12)'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: ./
with:
version: next-12
install: false
- name: 'Test: dist-tag resolves to a 12.x version'
run: |
set -e
which pnpm
actual="$(pnpm --version)"
echo "pnpm --version: ${actual}"
case "${actual}" in
12.*) echo "ok" ;;
*) echo "Expected pnpm 12.x, got ${actual}"; exit 1 ;;
esac
shell: bash
version-range:
# `version` may be a semver range. While v12 only has prereleases the
# range resolution falls back to prerelease versions.
name: 'Version from semver range (^12.0.0-0)'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: ./
with:
version: '^12.0.0-0'
install: false
- name: 'Test: range resolves to a 12.x version'
run: |
set -e
actual="$(pnpm --version)"
echo "pnpm --version: ${actual}"
case "${actual}" in
12.*) echo "ok" ;;
*) echo "Expected pnpm 12.x, got ${actual}"; exit 1 ;;
esac
shell: bash
runtime-node:
# Explicit runtime input across OSes. Asserts node binary is on PATH and
# the action's outputs reflect what was installed.
name: 'Runtime node@${{ matrix.major }} (${{ matrix.os }})'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
major: '22'
- os: macos-latest
major: '22'
- os: windows-latest
major: '22'
steps:
- uses: actions/checkout@v6
- id: pnpm
uses: ./
with:
version: '12.0.0-alpha.19'
runtime: node@${{ matrix.major }}
- name: 'Test: node binary on PATH'
env:
MAJOR: ${{ matrix.major }}
run: |
set -e
which node
actual="$(node --version)"
echo "node --version: ${actual}"
case "${actual}" in
v${MAJOR}.*) echo "ok" ;;
*) echo "Expected node v${MAJOR}.x, got ${actual}"; exit 1 ;;
esac
shell: bash
- name: 'Test: outputs.runtime-name and outputs.runtime-version'
env:
OUT_NAME: ${{ steps.pnpm.outputs.runtime-name }}
OUT_VERSION: ${{ steps.pnpm.outputs.runtime-version }}
EXPECTED_VERSION: ${{ matrix.major }}
run: |
set -e
if [ "${OUT_NAME}" != "node" ]; then
echo "Expected outputs.runtime-name=node, got ${OUT_NAME}"
exit 1
fi
if [ "${OUT_VERSION}" != "${EXPECTED_VERSION}" ]; then
echo "Expected outputs.runtime-version=${EXPECTED_VERSION}, got ${OUT_VERSION}"
exit 1
fi
shell: bash
runtime-bun:
name: Runtime bun
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: ./
with:
version: '12.0.0-alpha.19'
runtime: bun@latest
- name: 'Test: bun on PATH'
run: |
set -e
which bun
bun --version
shell: bash
runtime-deno:
name: Runtime deno
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: ./
with:
version: '12.0.0-alpha.19'
runtime: deno@2
- name: 'Test: deno on PATH'
run: |
set -e
which deno
deno --version
shell: bash
runtime-from-devengines:
# No `runtime` input — the action should pick up devEngines.runtime from
# package.json and install it. Also asserts that `pnpm install` runs by
# default when a manifest is present.
name: 'Runtime from devEngines.runtime'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up package.json with devEngines.runtime
# Remove the action's own pnpm-lock.yaml so `pnpm install` doesn't
# hit a frozen-lockfile mismatch against the synthetic manifest.
run: |
rm -f pnpm-lock.yaml
cat > package.json <<'EOF'
{
"packageManager": "pnpm@12.0.0-alpha.19",
"devEngines": {
"runtime": { "name": "node", "version": "^22.0.0", "onFail": "download" }
},
"dependencies": {
"is-odd": "3.0.1"
}
}
EOF
shell: bash
- id: pnpm
uses: ./
- name: 'Test: node 22 is installed and dependencies are resolved'
env:
OUT_NAME: ${{ steps.pnpm.outputs.runtime-name }}
OUT_VERSION: ${{ steps.pnpm.outputs.runtime-version }}
run: |
set -e
which node
actual="$(node --version)"
echo "node --version: ${actual}"
case "${actual}" in
v22.*) ;;
*) echo "Expected node v22.x, got ${actual}"; exit 1 ;;
esac
if [ "${OUT_NAME}" != "node" ]; then
echo "Expected outputs.runtime-name=node, got ${OUT_NAME}"
exit 1
fi
if [ "${OUT_VERSION}" != "^22.0.0" ]; then
echo "Expected outputs.runtime-version=^22.0.0, got ${OUT_VERSION}"
exit 1
fi
# `pnpm install` should have run automatically — node_modules must exist.
if [ ! -d node_modules/is-odd ]; then
echo "Expected pnpm install to have populated node_modules/is-odd"
exit 1
fi
shell: bash
runtime-overrides-devengines:
# Explicit `runtime` input conflicts with `devEngines.runtime` in
# package.json. The action should install the explicit version AND pass
# `--no-runtime` to pnpm install so the devEngines runtime doesn't shadow
# the matrix one.
name: 'Explicit runtime overrides devEngines.runtime'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up package.json with conflicting devEngines.runtime
run: |
rm -f pnpm-lock.yaml
cat > package.json <<'EOF'
{
"packageManager": "pnpm@12.0.0-alpha.19",
"devEngines": {
"runtime": { "name": "node", "version": "^20.0.0", "onFail": "download" }
},
"dependencies": {
"is-odd": "3.0.1"
}
}
EOF
shell: bash
- id: pnpm
uses: ./
with:
runtime: node@22
- name: 'Test: node 22 stays active after pnpm install'
run: |
set -e
actual="$(node --version)"
echo "node --version: ${actual}"
case "${actual}" in
v22.*) ;;
*) echo "Expected node v22.x after install (--no-runtime should have suppressed the devEngines runtime fetch), got ${actual}"; exit 1 ;;
esac
# pnpm install should still have run.
if [ ! -d node_modules/is-odd ]; then
echo "Expected pnpm install to have populated node_modules/is-odd"
exit 1
fi
shell: bash
runtime-version-fallback:
# `runtime: node` without an `@<version>` suffix should fall back to the
# version declared in devEngines.runtime.
name: 'runtime version falls back to devEngines'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up package.json with devEngines.runtime version
run: |
rm -f pnpm-lock.yaml
cat > package.json <<'EOF'
{
"packageManager": "pnpm@12.0.0-alpha.19",
"devEngines": {
"runtime": { "name": "node", "version": "^20.0.0", "onFail": "download" }
}
}
EOF
shell: bash
- id: pnpm
uses: ./
with:
runtime: node
- name: 'Test: node 20 via fallback'
run: |
set -e
actual="$(node --version)"
echo "node --version: ${actual}"
case "${actual}" in
v20.*) ;;
*) echo "Expected node v20.x, got ${actual}"; exit 1 ;;
esac
shell: bash
install-false:
# `install: false` skips the auto-install step even though a manifest is
# present.
name: 'install: false skips pnpm install'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up package.json with a dependency
run: |
rm -f pnpm-lock.yaml
cat > package.json <<'EOF'
{
"packageManager": "pnpm@12.0.0-alpha.19",
"dependencies": {
"is-odd": "3.0.1"
}
}
EOF
shell: bash
- uses: ./
with:
version: '12.0.0-alpha.19'
install: false
- name: 'Test: node_modules was not populated'
run: |
set -e
if [ -d node_modules/is-odd ]; then
echo "Expected install: false to skip pnpm install, but node_modules/is-odd exists"
exit 1
fi
# pnpm itself should still be on PATH.
which pnpm
pnpm --version
shell: bash
no-runtime:
# No runtime input, no devEngines.runtime. Action installs pnpm only and
# leaves the runtime outputs empty. With no package.json, `pnpm install`
# is also skipped.
name: 'No runtime, no manifest'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- id: pnpm
uses: ./
with:
version: '12.0.0-alpha.19'
- name: 'Test: pnpm works, runtime outputs are empty'
env:
OUT_NAME: ${{ steps.pnpm.outputs.runtime-name }}
OUT_VERSION: ${{ steps.pnpm.outputs.runtime-version }}
run: |
set -e
which pnpm
pnpm --version
if [ -n "${OUT_NAME}" ]; then
echo "Expected outputs.runtime-name to be empty, got '${OUT_NAME}'"
exit 1
fi
if [ -n "${OUT_VERSION}" ]; then
echo "Expected outputs.runtime-version to be empty, got '${OUT_VERSION}'"
exit 1
fi
shell: bash