Skip to content

Commit 019918a

Browse files
hugovkAA-Turnerwebknjaz
authored
[3.13] Convert change detection to a Python script (GH-129627) (#130367)
Co-authored-by: Adam Turner <[email protected]> Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
1 parent 8ef8947 commit 019918a

File tree

4 files changed

+328
-209
lines changed

4 files changed

+328
-209
lines changed

.github/workflows/build.yml

+45-51
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,32 @@ env:
2222
FORCE_COLOR: 1
2323

2424
jobs:
25-
check_source:
25+
build-context:
2626
name: Change detection
2727
# To use boolean outputs from this job, parse them as JSON.
2828
# Here's some examples:
2929
#
30-
# if: fromJSON(needs.check_source.outputs.run-docs)
30+
# if: fromJSON(needs.build-context.outputs.run-docs)
3131
#
3232
# ${{
33-
# fromJSON(needs.check_source.outputs.run_tests)
33+
# fromJSON(needs.build-context.outputs.run-tests)
3434
# && 'truthy-branch'
3535
# || 'falsy-branch'
3636
# }}
3737
#
38-
uses: ./.github/workflows/reusable-change-detection.yml
38+
uses: ./.github/workflows/reusable-context.yml
3939

4040
check-docs:
4141
name: Docs
42-
needs: check_source
43-
if: fromJSON(needs.check_source.outputs.run-docs)
42+
needs: build-context
43+
if: fromJSON(needs.build-context.outputs.run-docs)
4444
uses: ./.github/workflows/reusable-docs.yml
4545

4646
check_abi:
4747
name: 'Check if the ABI has changed'
4848
runs-on: ubuntu-22.04 # 24.04 causes spurious errors
49-
needs: check_source
50-
if: needs.check_source.outputs.run_tests == 'true'
49+
needs: build-context
50+
if: needs.build-context.outputs.run-tests == 'true'
5151
steps:
5252
- uses: actions/checkout@v4
5353
with:
@@ -96,8 +96,8 @@ jobs:
9696
container:
9797
image: ghcr.io/python/autoconf:2024.10.16.11360930377
9898
timeout-minutes: 60
99-
needs: check_source
100-
if: needs.check_source.outputs.run_tests == 'true'
99+
needs: build-context
100+
if: needs.build-context.outputs.run-tests == 'true'
101101
steps:
102102
- name: Install Git
103103
run: |
@@ -137,8 +137,8 @@ jobs:
137137
# reproducible: to get the same tools versions (autoconf, aclocal, ...)
138138
runs-on: ubuntu-24.04
139139
timeout-minutes: 60
140-
needs: check_source
141-
if: needs.check_source.outputs.run_tests == 'true'
140+
needs: build-context
141+
if: needs.build-context.outputs.run-tests == 'true'
142142
steps:
143143
- uses: actions/checkout@v4
144144
with:
@@ -153,7 +153,7 @@ jobs:
153153
with:
154154
path: config.cache
155155
# Include env.pythonLocation in key to avoid changes in environment when setup-python updates Python
156-
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ needs.check_source.outputs.config_hash }}-${{ env.pythonLocation }}
156+
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ needs.build-context.outputs.config-hash }}-${{ env.pythonLocation }}
157157
- name: Install dependencies
158158
run: sudo ./.github/workflows/posix-deps-apt.sh
159159
- name: Add ccache to PATH
@@ -196,8 +196,8 @@ jobs:
196196
name: >-
197197
Windows
198198
${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
199-
needs: check_source
200-
if: fromJSON(needs.check_source.outputs.run_tests)
199+
needs: build-context
200+
if: fromJSON(needs.build-context.outputs.run-tests)
201201
strategy:
202202
fail-fast: false
203203
matrix:
@@ -227,8 +227,8 @@ jobs:
227227
build_windows_msi:
228228
name: >- # ${{ '' } is a hack to nest jobs under the same sidebar category
229229
Windows MSI${{ '' }}
230-
needs: check_source
231-
if: fromJSON(needs.check_source.outputs.run-win-msi)
230+
needs: build-context
231+
if: fromJSON(needs.build-context.outputs.run-windows-msi)
232232
strategy:
233233
matrix:
234234
arch:
@@ -243,8 +243,8 @@ jobs:
243243
name: >-
244244
macOS
245245
${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
246-
needs: check_source
247-
if: needs.check_source.outputs.run_tests == 'true'
246+
needs: build-context
247+
if: needs.build-context.outputs.run-tests == 'true'
248248
strategy:
249249
fail-fast: false
250250
matrix:
@@ -269,32 +269,32 @@ jobs:
269269
free-threading: true
270270
uses: ./.github/workflows/reusable-macos.yml
271271
with:
272-
config_hash: ${{ needs.check_source.outputs.config_hash }}
272+
config_hash: ${{ needs.build-context.outputs.config-hash }}
273273
free-threading: ${{ matrix.free-threading }}
274274
os: ${{ matrix.os }}
275275

276276
build_ubuntu:
277277
name: >-
278278
Ubuntu
279279
${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
280-
needs: check_source
281-
if: needs.check_source.outputs.run_tests == 'true'
280+
needs: build-context
281+
if: needs.build-context.outputs.run-tests == 'true'
282282
strategy:
283283
matrix:
284284
free-threading:
285285
- false
286286
- true
287287
uses: ./.github/workflows/reusable-ubuntu.yml
288288
with:
289-
config_hash: ${{ needs.check_source.outputs.config_hash }}
289+
config_hash: ${{ needs.build-context.outputs.config-hash }}
290290
free-threading: ${{ matrix.free-threading }}
291291

292292
build_ubuntu_ssltests:
293293
name: 'Ubuntu SSL tests with OpenSSL'
294294
runs-on: ${{ matrix.os }}
295295
timeout-minutes: 60
296-
needs: check_source
297-
if: needs.check_source.outputs.run_tests == 'true'
296+
needs: build-context
297+
if: needs.build-context.outputs.run-tests == 'true'
298298
strategy:
299299
fail-fast: false
300300
matrix:
@@ -315,7 +315,7 @@ jobs:
315315
uses: actions/cache@v4
316316
with:
317317
path: config.cache
318-
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ needs.check_source.outputs.config_hash }}
318+
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ needs.build-context.outputs.config-hash }}
319319
- name: Register gcc problem matcher
320320
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
321321
- name: Install dependencies
@@ -352,18 +352,18 @@ jobs:
352352

353353
build_wasi:
354354
name: 'WASI'
355-
needs: check_source
356-
if: needs.check_source.outputs.run_tests == 'true'
355+
needs: build-context
356+
if: needs.build-context.outputs.run-tests == 'true'
357357
uses: ./.github/workflows/reusable-wasi.yml
358358
with:
359-
config_hash: ${{ needs.check_source.outputs.config_hash }}
359+
config_hash: ${{ needs.build-context.outputs.config-hash }}
360360

361361
test_hypothesis:
362362
name: "Hypothesis tests on Ubuntu"
363363
runs-on: ubuntu-24.04
364364
timeout-minutes: 60
365-
needs: check_source
366-
if: needs.check_source.outputs.run_tests == 'true' && needs.check_source.outputs.run_hypothesis == 'true'
365+
needs: build-context
366+
if: needs.build-context.outputs.run-tests == 'true'
367367
env:
368368
OPENSSL_VER: 3.0.15
369369
PYTHONSTRICTEXTENSIONBUILD: 1
@@ -410,7 +410,7 @@ jobs:
410410
uses: actions/cache@v4
411411
with:
412412
path: ${{ env.CPYTHON_BUILDDIR }}/config.cache
413-
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ needs.check_source.outputs.config_hash }}
413+
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ needs.build-context.outputs.config-hash }}
414414
- name: Configure CPython out-of-tree
415415
working-directory: ${{ env.CPYTHON_BUILDDIR }}
416416
run: |
@@ -477,8 +477,8 @@ jobs:
477477
name: 'Address sanitizer'
478478
runs-on: ${{ matrix.os }}
479479
timeout-minutes: 60
480-
needs: check_source
481-
if: needs.check_source.outputs.run_tests == 'true'
480+
needs: build-context
481+
if: needs.build-context.outputs.run-tests == 'true'
482482
strategy:
483483
matrix:
484484
os: [ubuntu-24.04]
@@ -496,7 +496,7 @@ jobs:
496496
uses: actions/cache@v4
497497
with:
498498
path: config.cache
499-
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ needs.check_source.outputs.config_hash }}
499+
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ needs.build-context.outputs.config-hash }}
500500
- name: Register gcc problem matcher
501501
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
502502
- name: Install dependencies
@@ -540,25 +540,25 @@ jobs:
540540
name: >-
541541
Thread sanitizer
542542
${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
543-
needs: check_source
544-
if: needs.check_source.outputs.run_tests == 'true'
543+
needs: build-context
544+
if: needs.build-context.outputs.run-tests == 'true'
545545
strategy:
546546
matrix:
547547
free-threading:
548548
- false
549549
- true
550550
uses: ./.github/workflows/reusable-tsan.yml
551551
with:
552-
config_hash: ${{ needs.check_source.outputs.config_hash }}
552+
config_hash: ${{ needs.build-context.outputs.config-hash }}
553553
free-threading: ${{ matrix.free-threading }}
554554

555555
# CIFuzz job based on https://google.github.io/oss-fuzz/getting-started/continuous-integration/
556556
cifuzz:
557557
name: CIFuzz
558558
runs-on: ubuntu-latest
559559
timeout-minutes: 60
560-
needs: check_source
561-
if: needs.check_source.outputs.run_cifuzz == 'true'
560+
needs: build-context
561+
if: needs.build-context.outputs.run-ci-fuzz == 'true'
562562
permissions:
563563
security-events: write
564564
strategy:
@@ -597,7 +597,7 @@ jobs:
597597
if: always()
598598

599599
needs:
600-
- check_source # Transitive dependency, needed to access `run_tests` value
600+
- build-context # Transitive dependency, needed to access `run-tests` value
601601
- check-docs
602602
- check_autoconf_regen
603603
- check_generated_files
@@ -625,14 +625,14 @@ jobs:
625625
test_hypothesis,
626626
allowed-skips: >-
627627
${{
628-
!fromJSON(needs.check_source.outputs.run-docs)
628+
!fromJSON(needs.build-context.outputs.run-docs)
629629
&& '
630630
check-docs,
631631
'
632632
|| ''
633633
}}
634634
${{
635-
needs.check_source.outputs.run_tests != 'true'
635+
needs.build-context.outputs.run-tests != 'true'
636636
&& '
637637
check_autoconf_regen,
638638
check_generated_files,
@@ -643,21 +643,15 @@ jobs:
643643
build_windows,
644644
build_asan,
645645
build_tsan,
646+
test_hypothesis,
646647
'
647648
|| ''
648649
}}
649650
${{
650-
!fromJSON(needs.check_source.outputs.run_cifuzz)
651+
!fromJSON(needs.build-context.outputs.run-ci-fuzz)
651652
&& '
652653
cifuzz,
653654
'
654655
|| ''
655656
}}
656-
${{
657-
!fromJSON(needs.check_source.outputs.run_hypothesis)
658-
&& '
659-
test_hypothesis,
660-
'
661-
|| ''
662-
}}
663657
jobs: ${{ toJSON(needs) }}

0 commit comments

Comments
 (0)