-
Notifications
You must be signed in to change notification settings - Fork 0
630 lines (525 loc) · 21.6 KB
/
Copy pathtest-python-setup-pip.yml
File metadata and controls
630 lines (525 loc) · 21.6 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
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
name: Test python-setup/pip
on:
push:
jobs:
test-pip-basic:
name: Test pip action - defaults
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Test pip action with defaults (cache='')
uses: ./actions/python-setup/pip
- name: Verify Python installation
run: |
python --version
pip --version
pip list
test-pip-with-groups:
name: Test pip action - With optional dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Copy test fixture files
run: cp tests/data/pip/test-pip-with-groups/pyproject.toml .
- name: Test pip action with optional dependencies (extras)
uses: ./actions/python-setup/pip
with:
install-groups: 'extras: dev test'
- name: Verify installations
shell: bash
run: |
python --version
pip list
# Verify dev dependencies are installed
python -c "import pytest; import black; print('[OK] Dev dependencies installed')"
python -c "import pytest_cov; print('[OK] Test dependencies installed')"
test-pip-matrix:
name: Test pip action - Matrix
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.11', '3.12', '3.13', '3.14']
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Copy test fixture files
shell: bash
run: cp tests/data/pip/test-pip-matrix/pyproject.toml .
- name: Test pip action with Python ${{ matrix.python-version }}
uses: ./actions/python-setup/pip
with:
python-version: ${{ matrix.python-version }}
- name: Verify Python version
run: |
python --version
python -c "import sys; assert sys.version_info[:2] == tuple(map(int, '${{ matrix.python-version }}'.split('.')[:2]))"
pip list
- name: Test pip functionality
shell: bash
run: |
pip install requests
python -c "import requests; print(f'[OK] requests {requests.__version__} installed successfully')"
test-pip-cache:
name: Test pip action - Cache validation
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Copy test fixture files
run: cp tests/data/pip/test-pip-cache/pyproject.toml .
- name: First run - populate cache
uses: ./actions/python-setup/pip
with:
cache: 'pip'
- name: Verify cache is working
run: |
pip list
echo "Cache should be populated for subsequent runs"
test-pip-architecture:
name: Test pip action - Architecture
runs-on: windows-latest
strategy:
matrix:
architecture: [x64, x86]
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Copy test fixture files
shell: bash
run: cp tests/data/pip/test-pip-architecture/pyproject.toml .
- name: Test pip action with ${{ matrix.architecture }}
uses: ./actions/python-setup/pip
with:
architecture: ${{ matrix.architecture }}
- name: Verify architecture
run: |
python --version
python -c "import platform; print(f'Architecture: {platform.architecture()}')"
test-pip-cache-validation-error:
name: Test pip action - Cache validation error
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Test pip action with cache but no dependency file (should fail)
id: test-cache-error
continue-on-error: true
uses: ./actions/python-setup/pip
with:
cache: 'pip'
- name: Verify action failed as expected
shell: bash
run: |
if [ "${{ steps.test-cache-error.outcome }}" != "failure" ]; then
echo "::error::Expected action to fail when cache is enabled without pyproject.toml/requirements.txt"
exit 1
fi
echo "[OK] Action correctly failed when cache enabled without dependency files"
test-pip-cache-with-requirements:
name: Test pip action - Cache with requirements.txt
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Copy test fixture files
run: cp tests/data/pip/test-pip-cache-with-requirements/requirements.txt .
- name: Test pip action with cache and requirements.txt
uses: ./actions/python-setup/pip
with:
cache: 'pip'
- name: Verify cache validation passed
shell: bash
run: |
python --version
pip list
echo "[OK] Cache validation passed with requirements.txt"
test-pip-no-dependency-file:
name: Test pip action - No dependency files (no cache)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Test pip action without pyproject.toml or requirements.txt
uses: ./actions/python-setup/pip
- name: Verify Python still works
shell: bash
run: |
python --version
pip --version
pip install requests
python -c "import requests; print('[OK] Can still install packages without dependency files')"
test-pip-empty-sections:
name: Test pip action - Empty groups/extras sections
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Copy test fixture files
run: cp tests/data/pip/test-pip-empty-sections/pyproject.toml .
- name: Test pip action with empty groups section
uses: ./actions/python-setup/pip
with:
install-groups: 'groups: , extras: aws'
- name: Verify empty groups handling
shell: bash
run: |
pip list
python -c "import requests; print('[OK] Core dependencies installed')"
python -c "import boto3; print('[OK] AWS extra installed')"
test-pip-invalid-format:
name: Test pip action - Invalid format handling
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Copy test fixture files
run: cp tests/data/pip/test-pip-invalid-format/pyproject.toml .
- name: Test pip action with invalid format (should show warning)
uses: ./actions/python-setup/pip
with:
install-groups: 'invalid format without colons'
- name: Verify warning shown and core dependencies installed
shell: bash
run: |
pip list
python -c "import requests; print('[OK] Core dependencies installed despite invalid format')"
test-pip-optional-dependencies:
name: Test pip action - Optional dependencies (extras)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Copy test fixture files
run: cp tests/data/pip/test-pip-optional-dependencies/pyproject.toml .
- name: Test pip action with optional dependencies only
uses: ./actions/python-setup/pip
with:
install-groups: 'extras: aws viz'
- name: Verify optional dependencies installed
shell: bash
run: |
pip list
# Verify core dependencies are installed
python -c "import requests; print('[OK] Core dependencies installed')"
# Verify optional dependencies are installed
python -c "import boto3; print('[OK] AWS extra installed')"
python -c "import matplotlib; print('[OK] Viz extra installed')"
# Only extras were requested, so the dev dependency group (httpx) must NOT be installed
if python -c "import httpx" 2>/dev/null; then
echo "::error::httpx present but no dependency group was requested (extras-only install must not pull groups)"
exit 1
fi
echo "[OK] Dependency groups correctly not installed for extras-only request"
test-pip-mixed-groups-and-extras:
name: Test pip action - Mixed groups and extras
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Copy test fixture files
run: cp tests/data/pip/test-pip-mixed-groups-and-extras/pyproject.toml .
- name: Test pip action with mixed groups and extras
uses: ./actions/python-setup/pip
with:
install-groups: 'groups: dev, extras: aws'
- name: Verify mixed installation
shell: bash
run: |
pip list
# Verify all requested dependencies are installed
python -c "import requests; print('[OK] Core dependencies installed')"
python -c "import boto3; print('[OK] AWS extra installed')"
# Requested dev group must be installed; the action fails loudly otherwise
python -c "import httpx; print('[OK] Dev group installed')"
test-pip-dependency-groups-only:
name: Test pip action - Dependency groups only
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Copy test fixture files
run: cp tests/data/pip/test-pip-dependency-groups-only/pyproject.toml .
- name: Test pip action with dependency groups only
uses: ./actions/python-setup/pip
with:
install-groups: 'groups: dev test'
- name: Verify dependency groups installation
shell: bash
run: |
pip list
# Verify core dependencies are installed
python -c "import requests; print('[OK] Core dependencies installed')"
# Requested groups (dev, test) must be installed; the action fails loudly otherwise
python -c "import httpx; import pytest; print('[OK] Dependency groups (dev, test) installed')"
test-pip-groups-docs-only:
name: Test pip action - Single dependency group (docs)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Copy test fixture files
run: cp tests/data/pip/test-pip-groups-only-docs/pyproject.toml .
- name: Test pip action with docs dependency group
uses: ./actions/python-setup/pip
with:
install-groups: 'groups: docs'
- name: Verify docs group installed
shell: bash
run: |
pip list
python -c "import requests; print('[OK] Core dependencies installed')"
# Requested docs group must be installed; the action fails loudly otherwise
python -c "import mkdocs; print('[OK] Docs group installed')"
test-pip-all-combinations:
name: Test pip action - All combinations (groups + extras)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Copy test fixture files
run: cp tests/data/pip/test-pip-all-combinations/pyproject.toml .
- name: Test pip action with multiple groups and extras
uses: ./actions/python-setup/pip
with:
install-groups: 'groups: dev test docs, extras: aws azure gcp'
- name: Verify comprehensive installation
shell: bash
run: |
pip list
# Verify core dependencies
python -c "import requests; import click; print('[OK] Core dependencies installed')"
# Verify optional dependencies (extras)
python -c "import boto3; print('[OK] AWS extra installed')"
python -c "from azure.storage.blob import BlobServiceClient; print('[OK] Azure extra installed')"
python -c "from google.cloud import storage; print('[OK] GCP extra installed')"
# Requested groups (dev, test, docs) must be installed; the action fails loudly otherwise
python -c "import httpx; import pytest; import mkdocs; print('[OK] All dependency groups installed')"
test-pip-single-extra:
name: Test pip action - Single extra only
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Copy test fixture files
run: cp tests/data/pip/test-pip-single-extra/pyproject.toml .
- name: Test pip action with single extra
uses: ./actions/python-setup/pip
with:
install-groups: 'extras: dev'
- name: Verify single extra installation
shell: bash
run: |
pip list
python -c "import requests; print('[OK] Core dependencies installed')"
python -c "import pytest; import black; import ruff; print('[OK] Dev extra installed')"
test-pip-single-group:
name: Test pip action - Single group only
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Copy test fixture files
run: cp tests/data/pip/test-pip-single-group/pyproject.toml .
- name: Test pip action with single group
uses: ./actions/python-setup/pip
with:
install-groups: 'groups: dev'
- name: Verify single group installation
shell: bash
run: |
pip list
python -c "import requests; print('[OK] Core dependencies installed')"
# Requested dev group must be installed; the action fails loudly otherwise
python -c "import pytest; import black; import ruff; print('[OK] Dev group installed')"
test-pip-only-core-dependencies:
name: Test pip action - Only core dependencies (no groups/extras)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Copy test fixture files
run: cp tests/data/pip/test-pip-only-dependencies/pyproject.toml .
- name: Test pip action without install-groups parameter
uses: ./actions/python-setup/pip
- name: Verify only core dependencies installed
shell: bash
run: |
pip list
python -c "import requests; import click; import httpx; print('[OK] Core dependencies installed')"
echo "[OK] Only core dependencies installed as expected"
test-pip-whitespace-handling:
name: Test pip action - Whitespace handling in groups/extras
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Copy test fixture files
run: cp tests/data/pip/test-pip-whitespace-handling/pyproject.toml .
- name: Test pip action with extra whitespace
uses: ./actions/python-setup/pip
with:
install-groups: ' groups: lint format , extras: dev test '
- name: Verify whitespace handling
shell: bash
run: |
pip list
python -c "import requests; print('[OK] Core dependencies installed')"
python -c "import pytest; print('[OK] Dev extra installed')"
python -c "import pytest_cov; print('[OK] Test extra installed')"
# Requested groups (lint, format) must be installed; the action fails loudly otherwise
python -c "import ruff; import black; print('[OK] Groups (lint, format) installed with whitespace handling')"
test-pip-empty-groups-value:
name: Test pip action - Empty groups value
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Copy test fixture files
run: cp tests/data/pip/test-pip-empty-groups-only/pyproject.toml .
- name: Test pip action with empty groups value
uses: ./actions/python-setup/pip
with:
install-groups: 'groups: '
- name: Verify empty groups handling
shell: bash
run: |
pip list
python -c "import requests; print('[OK] Core dependencies installed')"
echo "[OK] Empty groups value handled correctly"
test-pip-empty-extras-value:
name: Test pip action - Empty extras value
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Copy test fixture files
run: cp tests/data/pip/test-pip-empty-extras-only/pyproject.toml .
- name: Test pip action with empty extras value
uses: ./actions/python-setup/pip
with:
install-groups: 'extras: '
- name: Verify empty extras handling
shell: bash
run: |
pip list
python -c "import requests; print('[OK] Core dependencies installed')"
echo "[OK] Empty extras value handled correctly"
test-pip-python-version-matrix:
name: Test pip action - Python version matrix with extras
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11', '3.12', '3.13']
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Copy test fixture files
run: cp tests/data/pip/test-pip-multiple-python-versions/pyproject.toml .
- name: Test pip action with Python ${{ matrix.python-version }}
uses: ./actions/python-setup/pip
with:
python-version: ${{ matrix.python-version }}
install-groups: 'extras: dev'
- name: Verify Python version and extras
shell: bash
run: |
python --version
pip list
python -c "import requests; print('[OK] Core dependencies installed')"
python -c "import pytest; print('[OK] Dev extra installed')"
test-pip-reverse-order:
name: Test pip action - Reverse order (extras before groups)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Copy test fixture files
run: cp tests/data/pip/test-pip-all-combinations/pyproject.toml .
- name: Test pip action with extras before groups
uses: ./actions/python-setup/pip
with:
install-groups: 'extras: aws, groups: dev'
- name: Verify reverse order handling
shell: bash
run: |
pip list
python -c "import requests; print('[OK] Core dependencies installed')"
python -c "import boto3; print('[OK] AWS extra installed')"
# Requested dev group must be installed; the action fails loudly otherwise
python -c "import httpx; print('[OK] Dev group installed')"
test-pip-cache-with-groups:
name: Test pip action - Cache with groups and extras
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Copy test fixture files
run: cp tests/data/pip/test-pip-all-combinations/pyproject.toml .
- name: Test pip action with cache and install-groups
uses: ./actions/python-setup/pip
with:
cache: 'pip'
install-groups: 'groups: dev, extras: aws'
- name: Verify cache and installation
shell: bash
run: |
pip list
python -c "import requests; print('[OK] Core dependencies installed')"
python -c "import boto3; print('[OK] AWS extra installed with cache')"
echo "[OK] Cache validation passed with groups and extras"
test-pip-groups-unsupported-pip:
name: Test pip action - Groups requested but pip too old for --group (negative)
# Python 3.8's newest pip (24.3.1) predates PEP 735 `pip install --group`
# (added in pip 25.1), so this deterministically exercises the fail-loud path.
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Python 3.8 (precondition environment)
uses: actions/setup-python@v6
with:
python-version: '3.8'
- name: Precondition - confirm pip on Python 3.8 lacks --group
shell: bash
run: |
python -m pip install --upgrade pip
python --version
pip --version
# Capture help text before grepping (matches the action) so pipefail
# cannot mask a --group match via a SIGPIPE-141 pipeline failure.
group_help="$(pip install --help)"
if grep -q -- "--group" <<<"$group_help"; then
echo "::error::Precondition failed: pip on Python 3.8 unexpectedly supports --group; this negative test is no longer valid"
exit 1
fi
echo "[OK] Precondition met: pip on Python 3.8 does not support --group"
- name: Copy test fixture files
run: cp tests/data/pip/test-pip-single-group/pyproject.toml .
- name: Precondition - core install (no groups) succeeds on this pip
shell: bash
run: |
# Prove the fixture installs cleanly on 3.8's pip, so the only thing
# left to fail in the action below is the --group step -- this
# attributes the expected failure to the missing --group support
# rather than to an unrelated build/install error.
python -m pip install .
echo "[OK] Core install works on pip $(pip --version | awk '{print $2}')"
- name: Action must FAIL when groups are requested but pip lacks --group
id: groups-unsupported
continue-on-error: true
uses: ./actions/python-setup/pip
with:
python-version: '3.8'
install-groups: 'groups: dev'
- name: Verify the action failed instead of silently skipping the group
shell: bash
run: |
if [ "${{ steps.groups-unsupported.outcome }}" != "failure" ]; then
echo "::error::Expected the pip action to fail (exit 1) when dependency groups are requested but pip < 25.1 lacks --group"
exit 1
fi
echo "[OK] Action correctly failed instead of silently skipping the requested dependency group"