1
1
name : Tests
2
2
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".
6
3
on :
7
4
workflow_dispatch :
8
5
push :
@@ -23,86 +20,19 @@ concurrency:
23
20
24
21
jobs :
25
22
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
- uses : Ana06/get-changed-files@v2.3.0
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
106
36
107
37
check-docs :
108
38
name : Docs
@@ -198,55 +128,70 @@ jobs:
198
128
arch : ${{ matrix.arch }}
199
129
free-threading : ${{ matrix.free-threading }}
200
130
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${{ '' }}
203
134
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
206
143
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 }}
211
145
212
- build_macos_free_threading :
213
- name : ' macOS (free-threading)'
146
+ build_macos :
147
+ name : >-
148
+ macOS
149
+ ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
214
150
needs : check_source
215
151
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
216
174
uses : ./.github/workflows/reusable-macos.yml
217
175
with :
218
176
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 }}
223
179
224
180
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)' || '' }}
239
184
needs : check_source
240
185
if : needs.check_source.outputs.run_tests == 'true'
186
+ strategy :
187
+ matrix :
188
+ free-threading :
189
+ - false
190
+ - true
241
191
uses : ./.github/workflows/reusable-ubuntu.yml
242
192
with :
243
193
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 }}
250
195
251
196
build_ubuntu_ssltests :
252
197
name : ' Ubuntu SSL tests with OpenSSL'
@@ -298,7 +243,7 @@ jobs:
298
243
with :
299
244
save : false
300
245
- 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
302
247
- name : Build CPython
303
248
run : make -j4
304
249
- name : Display build info
@@ -371,6 +316,7 @@ jobs:
371
316
../cpython-ro-srcdir/configure \
372
317
--config-cache \
373
318
--with-pydebug \
319
+ --enable-slower-safety \
374
320
--with-openssl=$OPENSSL_DIR
375
321
- name : Build CPython out-of-tree
376
322
working-directory : ${{ env.CPYTHON_BUILDDIR }}
@@ -556,12 +502,11 @@ jobs:
556
502
- check-docs
557
503
- check_generated_files
558
504
- build_macos
559
- - build_macos_free_threading
560
505
- build_ubuntu
561
- - build_ubuntu_free_threading
562
506
- build_ubuntu_ssltests
563
507
- build_wasi
564
508
- build_windows
509
+ - build_windows_msi
565
510
- test_hypothesis
566
511
- build_asan
567
512
- build_tsan
@@ -576,6 +521,7 @@ jobs:
576
521
with :
577
522
allowed-failures : >-
578
523
build_ubuntu_ssltests,
524
+ build_windows_msi,
579
525
cifuzz,
580
526
test_hypothesis,
581
527
allowed-skips : >-
@@ -591,9 +537,7 @@ jobs:
591
537
&& '
592
538
check_generated_files,
593
539
build_macos,
594
- build_macos_free_threading,
595
540
build_ubuntu,
596
- build_ubuntu_free_threading,
597
541
build_ubuntu_ssltests,
598
542
build_wasi,
599
543
build_windows,
0 commit comments