Skip to content

Commit 7d9a22f

Browse files
AA-Turnerhugovkwebknjaz
authored
Convert change detection to a Python script (#129627)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
1 parent 58a4357 commit 7d9a22f

File tree

4 files changed

+329
-225
lines changed

4 files changed

+329
-225
lines changed

.github/workflows/build.yml

+46-52
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,25 @@ 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_autoconf_regen:
@@ -51,8 +51,8 @@ jobs:
5151
container:
5252
image: ghcr.io/python/autoconf:2025.01.02.12581854023
5353
timeout-minutes: 60
54-
needs: check_source
55-
if: needs.check_source.outputs.run_tests == 'true'
54+
needs: build-context
55+
if: needs.build-context.outputs.run-tests == 'true'
5656
steps:
5757
- name: Install Git
5858
run: |
@@ -94,8 +94,8 @@ jobs:
9494
# reproducible: to get the same tools versions (autoconf, aclocal, ...)
9595
runs-on: ubuntu-24.04
9696
timeout-minutes: 60
97-
needs: check_source
98-
if: needs.check_source.outputs.run_tests == 'true'
97+
needs: build-context
98+
if: needs.build-context.outputs.run-tests == 'true'
9999
steps:
100100
- uses: actions/checkout@v4
101101
with:
@@ -110,7 +110,7 @@ jobs:
110110
with:
111111
path: config.cache
112112
# Include env.pythonLocation in key to avoid changes in environment when setup-python updates Python
113-
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.check_source.outputs.config_hash }}-${{ env.pythonLocation }}
113+
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.build-context.outputs.config-hash }}-${{ env.pythonLocation }}
114114
- name: Install Dependencies
115115
run: sudo ./.github/workflows/posix-deps-apt.sh
116116
- name: Add ccache to PATH
@@ -153,8 +153,8 @@ jobs:
153153
name: >-
154154
Windows
155155
${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
156-
needs: check_source
157-
if: fromJSON(needs.check_source.outputs.run_tests)
156+
needs: build-context
157+
if: fromJSON(needs.build-context.outputs.run-tests)
158158
strategy:
159159
fail-fast: false
160160
matrix:
@@ -184,8 +184,8 @@ jobs:
184184
build_windows_msi:
185185
name: >- # ${{ '' } is a hack to nest jobs under the same sidebar category
186186
Windows MSI${{ '' }}
187-
needs: check_source
188-
if: fromJSON(needs.check_source.outputs.run-win-msi)
187+
needs: build-context
188+
if: fromJSON(needs.build-context.outputs.run-windows-msi)
189189
strategy:
190190
matrix:
191191
arch:
@@ -200,8 +200,8 @@ jobs:
200200
name: >-
201201
macOS
202202
${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
203-
needs: check_source
204-
if: needs.check_source.outputs.run_tests == 'true'
203+
needs: build-context
204+
if: needs.build-context.outputs.run-tests == 'true'
205205
strategy:
206206
fail-fast: false
207207
matrix:
@@ -226,7 +226,7 @@ jobs:
226226
free-threading: true
227227
uses: ./.github/workflows/reusable-macos.yml
228228
with:
229-
config_hash: ${{ needs.check_source.outputs.config_hash }}
229+
config_hash: ${{ needs.build-context.outputs.config-hash }}
230230
free-threading: ${{ matrix.free-threading }}
231231
os: ${{ matrix.os }}
232232

@@ -235,8 +235,8 @@ jobs:
235235
Ubuntu
236236
${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
237237
${{ fromJSON(matrix.bolt) && '(bolt)' || '' }}
238-
needs: check_source
239-
if: needs.check_source.outputs.run_tests == 'true'
238+
needs: build-context
239+
if: needs.build-context.outputs.run-tests == 'true'
240240
strategy:
241241
matrix:
242242
bolt:
@@ -257,7 +257,7 @@ jobs:
257257
bolt: true
258258
uses: ./.github/workflows/reusable-ubuntu.yml
259259
with:
260-
config_hash: ${{ needs.check_source.outputs.config_hash }}
260+
config_hash: ${{ needs.build-context.outputs.config-hash }}
261261
bolt-optimizations: ${{ matrix.bolt }}
262262
free-threading: ${{ matrix.free-threading }}
263263
os: ${{ matrix.os }}
@@ -266,8 +266,8 @@ jobs:
266266
name: 'Ubuntu SSL tests with OpenSSL'
267267
runs-on: ${{ matrix.os }}
268268
timeout-minutes: 60
269-
needs: check_source
270-
if: needs.check_source.outputs.run_tests == 'true'
269+
needs: build-context
270+
if: needs.build-context.outputs.run-tests == 'true'
271271
strategy:
272272
fail-fast: false
273273
matrix:
@@ -289,7 +289,7 @@ jobs:
289289
uses: actions/cache@v4
290290
with:
291291
path: config.cache
292-
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.check_source.outputs.config_hash }}
292+
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.build-context.outputs.config-hash }}
293293
- name: Register gcc problem matcher
294294
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
295295
- name: Install Dependencies
@@ -326,18 +326,18 @@ jobs:
326326

327327
build_wasi:
328328
name: 'WASI'
329-
needs: check_source
330-
if: needs.check_source.outputs.run_tests == 'true'
329+
needs: build-context
330+
if: needs.build-context.outputs.run-tests == 'true'
331331
uses: ./.github/workflows/reusable-wasi.yml
332332
with:
333-
config_hash: ${{ needs.check_source.outputs.config_hash }}
333+
config_hash: ${{ needs.build-context.outputs.config-hash }}
334334

335335
test_hypothesis:
336336
name: "Hypothesis tests on Ubuntu"
337337
runs-on: ubuntu-24.04
338338
timeout-minutes: 60
339-
needs: check_source
340-
if: needs.check_source.outputs.run_tests == 'true' && needs.check_source.outputs.run_hypothesis == 'true'
339+
needs: build-context
340+
if: needs.build-context.outputs.run-tests == 'true'
341341
env:
342342
OPENSSL_VER: 3.0.15
343343
PYTHONSTRICTEXTENSIONBUILD: 1
@@ -384,7 +384,7 @@ jobs:
384384
uses: actions/cache@v4
385385
with:
386386
path: ${{ env.CPYTHON_BUILDDIR }}/config.cache
387-
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.check_source.outputs.config_hash }}
387+
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.build-context.outputs.config-hash }}
388388
- name: Configure CPython out-of-tree
389389
working-directory: ${{ env.CPYTHON_BUILDDIR }}
390390
run: |
@@ -452,8 +452,8 @@ jobs:
452452
name: 'Address sanitizer'
453453
runs-on: ${{ matrix.os }}
454454
timeout-minutes: 60
455-
needs: check_source
456-
if: needs.check_source.outputs.run_tests == 'true'
455+
needs: build-context
456+
if: needs.build-context.outputs.run-tests == 'true'
457457
strategy:
458458
matrix:
459459
os: [ubuntu-24.04]
@@ -471,7 +471,7 @@ jobs:
471471
uses: actions/cache@v4
472472
with:
473473
path: config.cache
474-
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.check_source.outputs.config_hash }}
474+
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.build-context.outputs.config-hash }}
475475
- name: Register gcc problem matcher
476476
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
477477
- name: Install Dependencies
@@ -515,23 +515,23 @@ jobs:
515515
name: >-
516516
Thread sanitizer
517517
${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
518-
needs: check_source
519-
if: needs.check_source.outputs.run_tests == 'true'
518+
needs: build-context
519+
if: needs.build-context.outputs.run-tests == 'true'
520520
strategy:
521521
matrix:
522522
free-threading:
523523
- false
524524
- true
525525
uses: ./.github/workflows/reusable-tsan.yml
526526
with:
527-
config_hash: ${{ needs.check_source.outputs.config_hash }}
527+
config_hash: ${{ needs.build-context.outputs.config-hash }}
528528
free-threading: ${{ matrix.free-threading }}
529529

530530
cross-build-linux:
531531
name: Cross build Linux
532532
runs-on: ubuntu-latest
533-
needs: check_source
534-
if: needs.check_source.outputs.run_tests == 'true'
533+
needs: build-context
534+
if: needs.build-context.outputs.run-tests == 'true'
535535
steps:
536536
- uses: actions/checkout@v4
537537
with:
@@ -542,7 +542,7 @@ jobs:
542542
uses: actions/cache@v4
543543
with:
544544
path: config.cache
545-
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.check_source.outputs.config_hash }}
545+
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.build-context.outputs.config-hash }}
546546
- name: Register gcc problem matcher
547547
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
548548
- name: Set build dir
@@ -571,8 +571,8 @@ jobs:
571571
name: CIFuzz
572572
runs-on: ubuntu-latest
573573
timeout-minutes: 60
574-
needs: check_source
575-
if: needs.check_source.outputs.run_cifuzz == 'true'
574+
needs: build-context
575+
if: needs.build-context.outputs.run-ci-fuzz == 'true'
576576
permissions:
577577
security-events: write
578578
strategy:
@@ -611,7 +611,7 @@ jobs:
611611
if: always()
612612

613613
needs:
614-
- check_source # Transitive dependency, needed to access `run_tests` value
614+
- build-context # Transitive dependency, needed to access `run-tests` value
615615
- check-docs
616616
- check_autoconf_regen
617617
- check_generated_files
@@ -639,14 +639,14 @@ jobs:
639639
test_hypothesis,
640640
allowed-skips: >-
641641
${{
642-
!fromJSON(needs.check_source.outputs.run-docs)
642+
!fromJSON(needs.build-context.outputs.run-docs)
643643
&& '
644644
check-docs,
645645
'
646646
|| ''
647647
}}
648648
${{
649-
needs.check_source.outputs.run_tests != 'true'
649+
needs.build-context.outputs.run-tests != 'true'
650650
&& '
651651
check_autoconf_regen,
652652
check_generated_files,
@@ -657,21 +657,15 @@ jobs:
657657
build_windows,
658658
build_asan,
659659
build_tsan,
660+
test_hypothesis,
660661
'
661662
|| ''
662663
}}
663664
${{
664-
!fromJSON(needs.check_source.outputs.run_cifuzz)
665+
!fromJSON(needs.build-context.outputs.run-ci-fuzz)
665666
&& '
666667
cifuzz,
667668
'
668669
|| ''
669670
}}
670-
${{
671-
!fromJSON(needs.check_source.outputs.run_hypothesis)
672-
&& '
673-
test_hypothesis,
674-
'
675-
|| ''
676-
}}
677671
jobs: ${{ toJSON(needs) }}

0 commit comments

Comments
 (0)