4040 run-docs : ${{ steps.docs-changes.outputs.run-docs || false }}
4141 run_tests : ${{ steps.check.outputs.run_tests }}
4242 run_hypothesis : ${{ steps.check.outputs.run_hypothesis }}
43+ run_cifuzz : ${{ steps.check.outputs.run_cifuzz }}
4344 config_hash : ${{ steps.config_hash.outputs.hash }}
4445 steps :
4546 - uses : actions/checkout@v4
7677 echo "Run hypothesis tests"
7778 echo "run_hypothesis=true" >> $GITHUB_OUTPUT
7879 fi
80+
81+ # oss-fuzz maintains a configuration for fuzzing the main branch of
82+ # CPython, so CIFuzz should be run only for code that is likely to be
83+ # merged into the main branch; compatibility with older branches may
84+ # be broken.
85+ FUZZ_RELEVANT_FILES='(\.c$|\.h$|\.cpp$|^configure$|^\.github/workflows/build\.yml$|^Modules/_xxtestfuzz)'
86+ if [ "$GITHUB_BASE_REF" = "main" ] && [ "$(git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qE $FUZZ_RELEVANT_FILES; echo $?)" -eq 0 ]; then
87+ # The tests are pretty slow so they are executed only for PRs
88+ # changing relevant files.
89+ echo "Run CIFuzz tests"
90+ echo "run_cifuzz=true" >> $GITHUB_OUTPUT
91+ else
92+ echo "Branch too old for CIFuzz tests; or no C files were changed"
93+ echo "run_cifuzz=false" >> $GITHUB_OUTPUT
94+ fi
7995 - name : Compute hash for config cache key
8096 id : config_hash
8197 run : |
@@ -140,9 +156,6 @@ jobs:
140156 run : make regen-configure
141157 - name : Build CPython
142158 run : |
143- # Deepfreeze will usually cause global objects to be added or removed,
144- # so we run it before regen-global-objects gets rum (in regen-all).
145- make regen-deepfreeze
146159 make -j4 regen-all
147160 make regen-stdlib-module-names
148161 - name : Check for changes
@@ -182,7 +195,7 @@ jobs:
182195 - name : Display build info
183196 run : .\python.bat -m test.pythoninfo
184197 - name : Tests
185- run : .\PCbuild\rt.bat -p Win32 -d -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0
198+ run : .\PCbuild\rt.bat -p Win32 -d -q --fast-ci
186199
187200 build_win_amd64 :
188201 name : ' Windows (x64)'
@@ -201,7 +214,7 @@ jobs:
201214 - name : Display build info
202215 run : .\python.bat -m test.pythoninfo
203216 - name : Tests
204- run : .\PCbuild\rt.bat -p x64 -d -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0
217+ run : .\PCbuild\rt.bat -p x64 -d -q --fast-ci
205218
206219 build_win_arm64 :
207220 name : ' Windows (arm64)'
@@ -252,7 +265,7 @@ jobs:
252265 - name : Display build info
253266 run : make pythoninfo
254267 - name : Tests
255- run : make buildbottest TESTOPTS="-j4 -uall,-cpu"
268+ run : make test
256269
257270 build_ubuntu :
258271 name : ' Ubuntu'
@@ -261,7 +274,7 @@ jobs:
261274 needs : check_source
262275 if : needs.check_source.outputs.run_tests == 'true'
263276 env :
264- OPENSSL_VER : 1.1.1v
277+ OPENSSL_VER : 3.0.11
265278 PYTHONSTRICTEXTENSIONBUILD : 1
266279 steps :
267280 - uses : actions/checkout@v4
@@ -319,7 +332,7 @@ jobs:
319332 run : sudo mount $CPYTHON_RO_SRCDIR -oremount,rw
320333 - name : Tests
321334 working-directory : ${{ env.CPYTHON_BUILDDIR }}
322- run : xvfb-run make buildbottest TESTOPTS="-j4 -uall,-cpu"
335+ run : xvfb-run make test
323336
324337 build_ubuntu_ssltests :
325338 name : ' Ubuntu SSL tests with OpenSSL'
@@ -330,7 +343,7 @@ jobs:
330343 strategy :
331344 fail-fast : false
332345 matrix :
333- openssl_ver : [1.1.1v , 3.0.10 , 3.1.2 ]
346+ openssl_ver : [1.1.1w , 3.0.11 , 3.1.3 ]
334347 env :
335348 OPENSSL_VER : ${{ matrix.openssl_ver }}
336349 MULTISSL_DIR : ${{ github.workspace }}/multissl
@@ -382,7 +395,7 @@ jobs:
382395 needs : check_source
383396 if : needs.check_source.outputs.run_tests == 'true' && needs.check_source.outputs.run_hypothesis == 'true'
384397 env :
385- OPENSSL_VER : 1.1.1v
398+ OPENSSL_VER : 3.0.11
386399 PYTHONSTRICTEXTENSIONBUILD : 1
387400 steps :
388401 - uses : actions/checkout@v4
@@ -491,7 +504,7 @@ jobs:
491504 needs : check_source
492505 if : needs.check_source.outputs.run_tests == 'true'
493506 env :
494- OPENSSL_VER : 1.1.1v
507+ OPENSSL_VER : 3.0.11
495508 PYTHONSTRICTEXTENSIONBUILD : 1
496509 ASAN_OPTIONS : detect_leaks=0:allocator_may_return_null=1:handle_segv=0
497510 steps :
@@ -535,7 +548,47 @@ jobs:
535548 - name : Display build info
536549 run : make pythoninfo
537550 - name : Tests
538- run : xvfb-run make buildbottest TESTOPTS="-j4 -uall,-cpu"
551+ run : xvfb-run make test
552+
553+ # CIFuzz job based on https://google.github.io/oss-fuzz/getting-started/continuous-integration/
554+ cifuzz :
555+ name : CIFuzz
556+ runs-on : ubuntu-latest
557+ timeout-minutes : 60
558+ needs : check_source
559+ if : needs.check_source.outputs.run_cifuzz == 'true'
560+ permissions :
561+ security-events : write
562+ strategy :
563+ fail-fast : false
564+ matrix :
565+ sanitizer : [address, undefined, memory]
566+ steps :
567+ - name : Build fuzzers (${{ matrix.sanitizer }})
568+ id : build
569+ uses : google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
570+ with :
571+ oss-fuzz-project-name : cpython3
572+ sanitizer : ${{ matrix.sanitizer }}
573+ - name : Run fuzzers (${{ matrix.sanitizer }})
574+ uses : google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
575+ with :
576+ fuzz-seconds : 600
577+ oss-fuzz-project-name : cpython3
578+ output-sarif : true
579+ sanitizer : ${{ matrix.sanitizer }}
580+ - name : Upload crash
581+ uses : actions/upload-artifact@v3
582+ if : failure() && steps.build.outcome == 'success'
583+ with :
584+ name : ${{ matrix.sanitizer }}-artifacts
585+ path : ./out/artifacts
586+ - name : Upload SARIF
587+ if : always() && steps.build.outcome == 'success'
588+ uses : github/codeql-action/upload-sarif@v2
589+ with :
590+ sarif_file : cifuzz-sarif/results.sarif
591+ checkout_path : cifuzz-sarif
539592
540593 all-required-green : # This job does nothing and is only used for the branch protection
541594 name : All required checks pass
@@ -553,6 +606,7 @@ jobs:
553606 - build_ubuntu_ssltests
554607 - test_hypothesis
555608 - build_asan
609+ - cifuzz
556610
557611 runs-on : ubuntu-latest
558612
@@ -565,6 +619,7 @@ jobs:
565619 build_ubuntu_ssltests,
566620 build_win32,
567621 build_win_arm64,
622+ cifuzz,
568623 test_hypothesis,
569624 allowed-skips : >-
570625 ${{
@@ -588,6 +643,13 @@ jobs:
588643 '
589644 || ''
590645 }}
646+ ${{
647+ !fromJSON(needs.check_source.outputs.run_cifuzz)
648+ && '
649+ cifuzz,
650+ '
651+ || ''
652+ }}
591653 ${{
592654 !fromJSON(needs.check_source.outputs.run_hypothesis)
593655 && '
0 commit comments