11name : Tests
22
3- # gh-84728: "paths-ignore" is not used to skip documentation-only PRs, because
4- # it prevents to mark a job as mandatory. A PR cannot be merged if a job is
5- # mandatory but not scheduled because of "paths-ignore".
63on :
74 workflow_dispatch :
85 push :
@@ -23,86 +20,19 @@ concurrency:
2320
2421jobs :
2522 check_source :
26- name : ' Check for source changes'
27- runs-on : ubuntu-latest
28- timeout-minutes : 10
29- outputs :
30- run-docs : ${{ steps.docs-changes.outputs.run-docs || false }}
31- run_tests : ${{ steps.check.outputs.run_tests }}
32- run_hypothesis : ${{ steps.check.outputs.run_hypothesis }}
33- run_cifuzz : ${{ steps.check.outputs.run_cifuzz }}
34- config_hash : ${{ steps.config_hash.outputs.hash }}
35- steps :
36- - uses : actions/checkout@v4
37- - name : Check for source changes
38- id : check
39- run : |
40- if [ -z "$GITHUB_BASE_REF" ]; then
41- echo "run_tests=true" >> $GITHUB_OUTPUT
42- else
43- git fetch origin $GITHUB_BASE_REF --depth=1
44- # git diff "origin/$GITHUB_BASE_REF..." (3 dots) may be more
45- # reliable than git diff "origin/$GITHUB_BASE_REF.." (2 dots),
46- # but it requires to download more commits (this job uses
47- # "git fetch --depth=1").
48- #
49- # git diff "origin/$GITHUB_BASE_REF..." (3 dots) works with Git
50- # 2.26, but Git 2.28 is stricter and fails with "no merge base".
51- #
52- # git diff "origin/$GITHUB_BASE_REF.." (2 dots) should be enough on
53- # GitHub, since GitHub starts by merging origin/$GITHUB_BASE_REF
54- # into the PR branch anyway.
55- #
56- # https://github.com/python/core-workflow/issues/373
57- git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qvE '(\.rst$|^Doc|^Misc|^\.pre-commit-config\.yaml$|\.ruff\.toml$|\.md$|mypy\.ini$)' && echo "run_tests=true" >> $GITHUB_OUTPUT || true
58- fi
59-
60- # Check if we should run hypothesis tests
61- GIT_BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}
62- echo $GIT_BRANCH
63- if $(echo "$GIT_BRANCH" | grep -q -w '3\.\(8\|9\|10\|11\)'); then
64- echo "Branch too old for hypothesis tests"
65- echo "run_hypothesis=false" >> $GITHUB_OUTPUT
66- else
67- echo "Run hypothesis tests"
68- echo "run_hypothesis=true" >> $GITHUB_OUTPUT
69- fi
70-
71- # oss-fuzz maintains a configuration for fuzzing the main branch of
72- # CPython, so CIFuzz should be run only for code that is likely to be
73- # merged into the main branch; compatibility with older branches may
74- # be broken.
75- FUZZ_RELEVANT_FILES='(\.c$|\.h$|\.cpp$|^configure$|^\.github/workflows/build\.yml$|^Modules/_xxtestfuzz)'
76- if [ "$GITHUB_BASE_REF" = "main" ] && [ "$(git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qE $FUZZ_RELEVANT_FILES; echo $?)" -eq 0 ]; then
77- # The tests are pretty slow so they are executed only for PRs
78- # changing relevant files.
79- echo "Run CIFuzz tests"
80- echo "run_cifuzz=true" >> $GITHUB_OUTPUT
81- else
82- echo "Branch too old for CIFuzz tests; or no C files were changed"
83- echo "run_cifuzz=false" >> $GITHUB_OUTPUT
84- fi
85- - name : Compute hash for config cache key
86- id : config_hash
87- run : |
88- echo "hash=${{ hashFiles('configure', 'configure.ac', '.github/workflows/build.yml') }}" >> $GITHUB_OUTPUT
89- - name : Get a list of the changed documentation-related files
90- if : github.event_name == 'pull_request'
91- id : changed-docs-files
92- 93- with :
94- filter : |
95- Doc/**
96- Misc/**
97- .github/workflows/reusable-docs.yml
98- format : csv # works for paths with spaces
99- - name : Check for docs changes
100- if : >-
101- github.event_name == 'pull_request'
102- && steps.changed-docs-files.outputs.added_modified_renamed != ''
103- id : docs-changes
104- run : |
105- echo "run-docs=true" >> "${GITHUB_OUTPUT}"
23+ name : Change detection
24+ # To use boolean outputs from this job, parse them as JSON.
25+ # Here's some examples:
26+ #
27+ # if: fromJSON(needs.check_source.outputs.run-docs)
28+ #
29+ # ${{
30+ # fromJSON(needs.check_source.outputs.run_tests)
31+ # && 'truthy-branch'
32+ # || 'falsy-branch'
33+ # }}
34+ #
35+ uses : ./.github/workflows/reusable-change-detection.yml
10636
10737 check-docs :
10838 name : Docs
@@ -198,55 +128,70 @@ jobs:
198128 arch : ${{ matrix.arch }}
199129 free-threading : ${{ matrix.free-threading }}
200130
201- build_macos :
202- name : ' macOS'
131+ build_windows_msi :
132+ name : >- # ${{ '' } is a hack to nest jobs under the same sidebar category
133+ Windows MSI${{ '' }}
203134 needs : check_source
204- if : needs.check_source.outputs.run_tests == 'true'
205- uses : ./.github/workflows/reusable-macos.yml
135+ if : fromJSON(needs.check_source.outputs.run-win-msi)
136+ strategy :
137+ matrix :
138+ arch :
139+ - x86
140+ - x64
141+ - arm64
142+ uses : ./.github/workflows/reusable-windows-msi.yml
206143 with :
207- config_hash : ${{ needs.check_source.outputs.config_hash }}
208- # Cirrus and macos-14 are M1, macos-13 is default GHA Intel.
209- # Cirrus used for upstream, macos-14 for forks.
210- os-matrix : ' ["ghcr.io/cirruslabs/macos-runner:sonoma", "macos-14", "macos-13"]'
144+ arch : ${{ matrix.arch }}
211145
212- build_macos_free_threading :
213- name : ' macOS (free-threading)'
146+ build_macos :
147+ name : >-
148+ macOS
149+ ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
214150 needs : check_source
215151 if : needs.check_source.outputs.run_tests == 'true'
152+ strategy :
153+ fail-fast : false
154+ matrix :
155+ # Cirrus and macos-14 are M1, macos-13 is default GHA Intel.
156+ # macOS 13 only runs tests against the GIL-enabled CPython.
157+ # Cirrus used for upstream, macos-14 for forks.
158+ os :
159+ - ghcr.io/cirruslabs/macos-runner:sonoma
160+ - macos-14
161+ - macos-13
162+ is-fork : # only used for the exclusion trick
163+ - ${{ github.repository_owner != 'python' }}
164+ free-threading :
165+ - false
166+ - true
167+ exclude :
168+ - os : ghcr.io/cirruslabs/macos-runner:sonoma
169+ is-fork : true
170+ - os : macos-14
171+ is-fork : false
172+ - os : macos-13
173+ free-threading : true
216174 uses : ./.github/workflows/reusable-macos.yml
217175 with :
218176 config_hash : ${{ needs.check_source.outputs.config_hash }}
219- free-threading : true
220- # Cirrus and macos-14 are M1.
221- # Cirrus used for upstream, macos-14 for forks.
222- os-matrix : ' ["ghcr.io/cirruslabs/macos-runner:sonoma", "macos-14"]'
177+ free-threading : ${{ matrix.free-threading }}
178+ os : ${{ matrix.os }}
223179
224180 build_ubuntu :
225- name : ' Ubuntu'
226- needs : check_source
227- if : needs.check_source.outputs.run_tests == 'true'
228- uses : ./.github/workflows/reusable-ubuntu.yml
229- with :
230- config_hash : ${{ needs.check_source.outputs.config_hash }}
231- options : |
232- ../cpython-ro-srcdir/configure \
233- --config-cache \
234- --with-pydebug \
235- --with-openssl=$OPENSSL_DIR
236-
237- build_ubuntu_free_threading :
238- name : ' Ubuntu (free-threading)'
181+ name : >-
182+ Ubuntu
183+ ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
239184 needs : check_source
240185 if : needs.check_source.outputs.run_tests == 'true'
186+ strategy :
187+ matrix :
188+ free-threading :
189+ - false
190+ - true
241191 uses : ./.github/workflows/reusable-ubuntu.yml
242192 with :
243193 config_hash : ${{ needs.check_source.outputs.config_hash }}
244- options : |
245- ../cpython-ro-srcdir/configure \
246- --config-cache \
247- --with-pydebug \
248- --with-openssl=$OPENSSL_DIR \
249- --disable-gil
194+ free-threading : ${{ matrix.free-threading }}
250195
251196 build_ubuntu_ssltests :
252197 name : ' Ubuntu SSL tests with OpenSSL'
@@ -298,7 +243,7 @@ jobs:
298243 with :
299244 save : false
300245 - name : Configure CPython
301- run : ./configure -- config-cache --with-pydebug --with-openssl=$OPENSSL_DIR
246+ run : ./configure CFLAGS="-fdiagnostics-format=json" -- config-cache --enable-slower-safety --with-pydebug --with-openssl=$OPENSSL_DIR
302247 - name : Build CPython
303248 run : make -j4
304249 - name : Display build info
@@ -371,6 +316,7 @@ jobs:
371316 ../cpython-ro-srcdir/configure \
372317 --config-cache \
373318 --with-pydebug \
319+ --enable-slower-safety \
374320 --with-openssl=$OPENSSL_DIR
375321 - name : Build CPython out-of-tree
376322 working-directory : ${{ env.CPYTHON_BUILDDIR }}
@@ -556,12 +502,11 @@ jobs:
556502 - check-docs
557503 - check_generated_files
558504 - build_macos
559- - build_macos_free_threading
560505 - build_ubuntu
561- - build_ubuntu_free_threading
562506 - build_ubuntu_ssltests
563507 - build_wasi
564508 - build_windows
509+ - build_windows_msi
565510 - test_hypothesis
566511 - build_asan
567512 - build_tsan
@@ -576,6 +521,7 @@ jobs:
576521 with :
577522 allowed-failures : >-
578523 build_ubuntu_ssltests,
524+ build_windows_msi,
579525 cifuzz,
580526 test_hypothesis,
581527 allowed-skips : >-
@@ -591,9 +537,7 @@ jobs:
591537 && '
592538 check_generated_files,
593539 build_macos,
594- build_macos_free_threading,
595540 build_ubuntu,
596- build_ubuntu_free_threading,
597541 build_ubuntu_ssltests,
598542 build_wasi,
599543 build_windows,
0 commit comments