@@ -18,26 +18,29 @@ concurrency:
1818 group : ${{ github.workflow }}-${{ github.head_ref || github.run_id }}-reusable
1919 cancel-in-progress : true
2020
21+ env :
22+ FORCE_COLOR : 1
23+
2124jobs :
22- check_source :
25+ build-context :
2326 name : Change detection
2427 # To use boolean outputs from this job, parse them as JSON.
2528 # Here's some examples:
2629 #
27- # if: fromJSON(needs.check_source .outputs.run-docs)
30+ # if: fromJSON(needs.build-context .outputs.run-docs)
2831 #
2932 # ${{
30- # fromJSON(needs.check_source .outputs.run_tests )
33+ # fromJSON(needs.build-context .outputs.run-tests )
3134 # && 'truthy-branch'
3235 # || 'falsy-branch'
3336 # }}
3437 #
35- uses : ./.github/workflows/reusable-change-detection .yml
38+ uses : ./.github/workflows/reusable-context .yml
3639
3740 check-docs :
3841 name : Docs
39- needs : check_source
40- if : fromJSON(needs.check_source .outputs.run-docs)
42+ needs : build-context
43+ if : fromJSON(needs.build-context .outputs.run-docs)
4144 uses : ./.github/workflows/reusable-docs.yml
4245
4346 check_autoconf_regen :
4851 container :
4952 image : ghcr.io/python/autoconf:2025.01.02.12581854023
5053 timeout-minutes : 60
51- needs : check_source
52- if : needs.check_source .outputs.run_tests == 'true'
54+ needs : build-context
55+ if : needs.build-context .outputs.run-tests == 'true'
5356 steps :
5457 - name : Install Git
5558 run : |
9194 # reproducible: to get the same tools versions (autoconf, aclocal, ...)
9295 runs-on : ubuntu-24.04
9396 timeout-minutes : 60
94- needs : check_source
95- if : needs.check_source .outputs.run_tests == 'true'
97+ needs : build-context
98+ if : needs.build-context .outputs.run-tests == 'true'
9699 steps :
97100 - uses : actions/checkout@v4
98101 with :
@@ -107,7 +110,7 @@ jobs:
107110 with :
108111 path : config.cache
109112 # Include env.pythonLocation in key to avoid changes in environment when setup-python updates Python
110- 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 }}
111114 - name : Install Dependencies
112115 run : sudo ./.github/workflows/posix-deps-apt.sh
113116 - name : Add ccache to PATH
@@ -150,8 +153,8 @@ jobs:
150153 name : >-
151154 Windows
152155 ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
153- needs : check_source
154- if : fromJSON(needs.check_source .outputs.run_tests )
156+ needs : build-context
157+ if : fromJSON(needs.build-context .outputs.run-tests )
155158 strategy :
156159 fail-fast : false
157160 matrix :
@@ -181,8 +184,8 @@ jobs:
181184 build_windows_msi :
182185 name : >- # ${{ '' } is a hack to nest jobs under the same sidebar category
183186 Windows MSI${{ '' }}
184- needs : check_source
185- if : fromJSON(needs.check_source .outputs.run-win -msi)
187+ needs : build-context
188+ if : fromJSON(needs.build-context .outputs.run-windows -msi)
186189 strategy :
187190 matrix :
188191 arch :
@@ -197,8 +200,8 @@ jobs:
197200 name : >-
198201 macOS
199202 ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
200- needs : check_source
201- if : needs.check_source .outputs.run_tests == 'true'
203+ needs : build-context
204+ if : needs.build-context .outputs.run-tests == 'true'
202205 strategy :
203206 fail-fast : false
204207 matrix :
@@ -223,7 +226,7 @@ jobs:
223226 free-threading : true
224227 uses : ./.github/workflows/reusable-macos.yml
225228 with :
226- config_hash : ${{ needs.check_source .outputs.config_hash }}
229+ config_hash : ${{ needs.build-context .outputs.config-hash }}
227230 free-threading : ${{ matrix.free-threading }}
228231 os : ${{ matrix.os }}
229232
@@ -232,8 +235,8 @@ jobs:
232235 Ubuntu
233236 ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
234237 ${{ fromJSON(matrix.bolt) && '(bolt)' || '' }}
235- needs : check_source
236- if : needs.check_source .outputs.run_tests == 'true'
238+ needs : build-context
239+ if : needs.build-context .outputs.run-tests == 'true'
237240 strategy :
238241 matrix :
239242 bolt :
@@ -254,7 +257,7 @@ jobs:
254257 bolt : true
255258 uses : ./.github/workflows/reusable-ubuntu.yml
256259 with :
257- config_hash : ${{ needs.check_source .outputs.config_hash }}
260+ config_hash : ${{ needs.build-context .outputs.config-hash }}
258261 bolt-optimizations : ${{ matrix.bolt }}
259262 free-threading : ${{ matrix.free-threading }}
260263 os : ${{ matrix.os }}
@@ -263,8 +266,8 @@ jobs:
263266 name : ' Ubuntu SSL tests with OpenSSL'
264267 runs-on : ${{ matrix.os }}
265268 timeout-minutes : 60
266- needs : check_source
267- if : needs.check_source .outputs.run_tests == 'true'
269+ needs : build-context
270+ if : needs.build-context .outputs.run-tests == 'true'
268271 strategy :
269272 fail-fast : false
270273 matrix :
@@ -286,7 +289,7 @@ jobs:
286289 uses : actions/cache@v4
287290 with :
288291 path : config.cache
289- 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 }}
290293 - name : Register gcc problem matcher
291294 run : echo "::add-matcher::.github/problem-matchers/gcc.json"
292295 - name : Install Dependencies
@@ -323,18 +326,18 @@ jobs:
323326
324327 build_wasi :
325328 name : ' WASI'
326- needs : check_source
327- if : needs.check_source .outputs.run_tests == 'true'
329+ needs : build-context
330+ if : needs.build-context .outputs.run-tests == 'true'
328331 uses : ./.github/workflows/reusable-wasi.yml
329332 with :
330- config_hash : ${{ needs.check_source .outputs.config_hash }}
333+ config_hash : ${{ needs.build-context .outputs.config-hash }}
331334
332335 test_hypothesis :
333336 name : " Hypothesis tests on Ubuntu"
334337 runs-on : ubuntu-24.04
335338 timeout-minutes : 60
336- needs : check_source
337- 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'
338341 env :
339342 OPENSSL_VER : 3.0.15
340343 PYTHONSTRICTEXTENSIONBUILD : 1
@@ -381,7 +384,7 @@ jobs:
381384 uses : actions/cache@v4
382385 with :
383386 path : ${{ env.CPYTHON_BUILDDIR }}/config.cache
384- 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 }}
385388 - name : Configure CPython out-of-tree
386389 working-directory : ${{ env.CPYTHON_BUILDDIR }}
387390 run : |
@@ -449,8 +452,8 @@ jobs:
449452 name : ' Address sanitizer'
450453 runs-on : ${{ matrix.os }}
451454 timeout-minutes : 60
452- needs : check_source
453- if : needs.check_source .outputs.run_tests == 'true'
455+ needs : build-context
456+ if : needs.build-context .outputs.run-tests == 'true'
454457 strategy :
455458 matrix :
456459 os : [ubuntu-24.04]
@@ -468,7 +471,7 @@ jobs:
468471 uses : actions/cache@v4
469472 with :
470473 path : config.cache
471- 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 }}
472475 - name : Register gcc problem matcher
473476 run : echo "::add-matcher::.github/problem-matchers/gcc.json"
474477 - name : Install Dependencies
@@ -509,34 +512,67 @@ jobs:
509512 run : xvfb-run make ci
510513
511514 build_tsan :
512- name : ' Thread sanitizer'
513- needs : check_source
514- if : needs.check_source.outputs.run_tests == 'true'
515+ name : >-
516+ Thread sanitizer
517+ ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
518+ needs : build-context
519+ if : needs.build-context.outputs.run-tests == 'true'
520+ strategy :
521+ matrix :
522+ free-threading :
523+ - false
524+ - true
515525 uses : ./.github/workflows/reusable-tsan.yml
516526 with :
517- config_hash : ${{ needs.check_source.outputs.config_hash }}
518- options : ./configure --config-cache --with-thread-sanitizer --with-pydebug
519- suppressions_path : Tools/tsan/supressions.txt
520- tsan_logs_artifact_name : tsan-logs-default
527+ config_hash : ${{ needs.build-context.outputs.config-hash }}
528+ free-threading : ${{ matrix.free-threading }}
521529
522- build_tsan_free_threading :
523- name : ' Thread sanitizer (free-threading)'
524- needs : check_source
525- if : needs.check_source.outputs.run_tests == 'true'
526- uses : ./.github/workflows/reusable-tsan.yml
527- with :
528- config_hash : ${{ needs.check_source.outputs.config_hash }}
529- options : ./configure --config-cache --disable-gil --with-thread-sanitizer --with-pydebug
530- suppressions_path : Tools/tsan/suppressions_free_threading.txt
531- tsan_logs_artifact_name : tsan-logs-free-threading
530+ cross-build-linux :
531+ name : Cross build Linux
532+ runs-on : ubuntu-latest
533+ needs : build-context
534+ if : needs.build-context.outputs.run-tests == 'true'
535+ steps :
536+ - uses : actions/checkout@v4
537+ with :
538+ persist-credentials : false
539+ - name : Runner image version
540+ run : echo "IMAGE_VERSION=${ImageVersion}" >> "$GITHUB_ENV"
541+ - name : Restore config.cache
542+ uses : actions/cache@v4
543+ with :
544+ path : config.cache
545+ key : ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.build-context.outputs.config-hash }}
546+ - name : Register gcc problem matcher
547+ run : echo "::add-matcher::.github/problem-matchers/gcc.json"
548+ - name : Set build dir
549+ run :
550+ # an absolute path outside of the working directoy
551+ echo "BUILD_DIR=$(realpath ${{ github.workspace }}/../build)" >> "$GITHUB_ENV"
552+ - name : Install Dependencies
553+ run : sudo ./.github/workflows/posix-deps-apt.sh
554+ - name : Configure host build
555+ run : ./configure --prefix="$BUILD_DIR/host-python"
556+ - name : Install host Python
557+ run : make -j8 install
558+ - name : Run test subset with host build
559+ run : |
560+ "$BUILD_DIR/host-python/bin/python3" -m test test_sysconfig test_site test_embed
561+ - name : Configure cross build
562+ run : ./configure --prefix="$BUILD_DIR/cross-python" --with-build-python="$BUILD_DIR/host-python/bin/python3"
563+ - name : Install cross Python
564+ run : make -j8 install
565+ - name : Run test subset with host build
566+ run : |
567+ "$BUILD_DIR/cross-python/bin/python3" -m test test_sysconfig test_site test_embed
532568
533569 # CIFuzz job based on https://google.github.io/oss-fuzz/getting-started/continuous-integration/
534570 cifuzz :
535571 name : CIFuzz
536572 runs-on : ubuntu-latest
537573 timeout-minutes : 60
538- needs : check_source
539- if : needs.check_source .outputs.run_cifuzz == 'true'
574+ needs : build-context
575+ if : needs.build-context .outputs.run-ci-fuzz == 'true'
540576 permissions :
541577 security-events : write
542578 strategy :
@@ -575,7 +611,7 @@ jobs:
575611 if : always()
576612
577613 needs :
578- - check_source # Transitive dependency, needed to access `run_tests ` value
614+ - build-context # Transitive dependency, needed to access `run-tests ` value
579615 - check-docs
580616 - check_autoconf_regen
581617 - check_generated_files
@@ -588,7 +624,6 @@ jobs:
588624 - test_hypothesis
589625 - build_asan
590626 - build_tsan
591- - build_tsan_free_threading
592627 - cifuzz
593628
594629 runs-on : ubuntu-latest
@@ -604,14 +639,14 @@ jobs:
604639 test_hypothesis,
605640 allowed-skips : >-
606641 ${{
607- !fromJSON(needs.check_source .outputs.run-docs)
642+ !fromJSON(needs.build-context .outputs.run-docs)
608643 && '
609644 check-docs,
610645 '
611646 || ''
612647 }}
613648 ${{
614- needs.check_source .outputs.run_tests != 'true'
649+ needs.build-context .outputs.run-tests != 'true'
615650 && '
616651 check_autoconf_regen,
617652 check_generated_files,
@@ -622,22 +657,15 @@ jobs:
622657 build_windows,
623658 build_asan,
624659 build_tsan,
625- build_tsan_free_threading ,
660+ test_hypothesis ,
626661 '
627662 || ''
628663 }}
629664 ${{
630- !fromJSON(needs.check_source .outputs.run_cifuzz )
665+ !fromJSON(needs.build-context .outputs.run-ci-fuzz )
631666 && '
632667 cifuzz,
633668 '
634669 || ''
635670 }}
636- ${{
637- !fromJSON(needs.check_source.outputs.run_hypothesis)
638- && '
639- test_hypothesis,
640- '
641- || ''
642- }}
643671 jobs : ${{ toJSON(needs) }}
0 commit comments