Skip to content

Commit 55ff6a4

Browse files
committed
Move to reusable workflow approach
1 parent 88a5b0a commit 55ff6a4

5 files changed

Lines changed: 76 additions & 99 deletions

File tree

.github/workflows/build.yml

Lines changed: 10 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -636,84 +636,18 @@ jobs:
636636
run: |
637637
"$BUILD_DIR/cross-python/bin/python3" -m test test_sysconfig test_site test_embed
638638
639-
# CIFuzz job based on https://google.github.io/oss-fuzz/getting-started/continuous-integration/
640639
cifuzz:
641-
name: CIFuzz
642-
runs-on: ubuntu-latest
643-
timeout-minutes: 60
644640
needs: build-context
645641
if: needs.build-context.outputs.run-ci-fuzz == 'true'
646-
permissions:
647-
security-events: write
648-
strategy:
649-
fail-fast: false
650-
matrix:
651-
sanitizer: [address, undefined, memory]
652-
steps:
653-
- name: Build fuzzers (${{ matrix.sanitizer }})
654-
id: build
655-
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
656-
with:
657-
oss-fuzz-project-name: cpython3
658-
sanitizer: ${{ matrix.sanitizer }}
659-
- name: Run fuzzers (${{ matrix.sanitizer }})
660-
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
661-
with:
662-
fuzz-seconds: 600
663-
oss-fuzz-project-name: cpython3
664-
output-sarif: true
665-
sanitizer: ${{ matrix.sanitizer }}
666-
- name: Upload crash
667-
if: failure() && steps.build.outcome == 'success'
668-
uses: actions/upload-artifact@v4
669-
with:
670-
name: ${{ matrix.sanitizer }}-artifacts
671-
path: ./out/artifacts
672-
- name: Upload SARIF
673-
if: always() && steps.build.outcome == 'success'
674-
uses: github/codeql-action/upload-sarif@v3
675-
with:
676-
sarif_file: cifuzz-sarif/results.sarif
677-
checkout_path: cifuzz-sarif
678-
679-
cifuzz-libraries:
680-
name: CIFuzz-libraries
681-
runs-on: ubuntu-latest
682-
timeout-minutes: 60
642+
uses: ./.github/workflows/reusable-cifuzz.yml
643+
with:
644+
oss-fuzz-project-name: cpython3
645+
cifuzz-stdlib:
683646
needs: build-context
684-
if: needs.build-context.outputs.run-ci-fuzz-libraries == 'true'
685-
permissions:
686-
security-events: write
687-
strategy:
688-
fail-fast: false
689-
matrix:
690-
sanitizer: [address, undefined, memory]
691-
steps:
692-
- name: Build fuzzers (${{ matrix.sanitizer }})
693-
id: build
694-
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
695-
with:
696-
oss-fuzz-project-name: python3-libraries
697-
sanitizer: ${{ matrix.sanitizer }}
698-
- name: Run fuzzers (${{ matrix.sanitizer }})
699-
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
700-
with:
701-
fuzz-seconds: 600
702-
oss-fuzz-project-name: python3-libraries
703-
output-sarif: true
704-
sanitizer: ${{ matrix.sanitizer }}
705-
- name: Upload crash
706-
if: failure() && steps.build.outcome == 'success'
707-
uses: actions/upload-artifact@v4
708-
with:
709-
name: ${{ matrix.sanitizer }}-artifacts
710-
path: ./out/artifacts
711-
- name: Upload SARIF
712-
if: always() && steps.build.outcome == 'success'
713-
uses: github/codeql-action/upload-sarif@v3
714-
with:
715-
sarif_file: cifuzz-sarif/results.sarif
716-
checkout_path: cifuzz-sarif
647+
if: needs.build-context.outputs.run-ci-fuzz-stdlib == 'true'
648+
uses: ./.github/workflows/reusable-cifuzz.yml
649+
with:
650+
oss-fuzz-project-name: python3-libraries
717651

718652
all-required-green: # This job does nothing and is only used for the branch protection
719653
name: All required checks pass
@@ -737,7 +671,7 @@ jobs:
737671
- build-san
738672
- cross-build-linux
739673
- cifuzz
740-
- cifuzz-libraries
674+
- cifuzz-stdlib
741675
if: always()
742676

743677
steps:
@@ -763,6 +697,7 @@ jobs:
763697
}}
764698
${{ !fromJSON(needs.build-context.outputs.run-windows-tests) && 'build-windows,' || '' }}
765699
${{ !fromJSON(needs.build-context.outputs.run-ci-fuzz) && 'cifuzz,' || '' }}
700+
${{ !fromJSON(needs.build-context.outputs.run-ci-fuzz-stdlib) && 'cifuzz-stdlib,' || '' }}
766701
${{ !fromJSON(needs.build-context.outputs.run-macos) && 'build-macos,' || '' }}
767702
${{
768703
!fromJSON(needs.build-context.outputs.run-ubuntu)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# CIFuzz job based on https://google.github.io/oss-fuzz/getting-started/continuous-integration/
2+
name: Reusable CIFuzz
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
oss-fuzz-project-name:
8+
description: OSS-Fuzz project name
9+
required: true
10+
type: string
11+
12+
permissions:
13+
contents: read
14+
security-events: write
15+
16+
jobs:
17+
cifuzz:
18+
name: CIFuzz
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 60
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
sanitizer: [address, undefined, memory]
25+
steps:
26+
- name: Build fuzzers (${{ matrix.sanitizer }})
27+
id: build
28+
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
29+
with:
30+
oss-fuzz-project-name: ${{ inputs.oss-fuzz-project-name }}
31+
sanitizer: ${{ matrix.sanitizer }}
32+
- name: Run fuzzers (${{ matrix.sanitizer }})
33+
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
34+
with:
35+
fuzz-seconds: 600
36+
oss-fuzz-project-name: ${{ inputs.oss-fuzz-project-name }}
37+
output-sarif: true
38+
sanitizer: ${{ matrix.sanitizer }}
39+
- name: Upload crash
40+
if: failure() && steps.build.outcome == 'success'
41+
uses: actions/upload-artifact@v6
42+
with:
43+
name: ${{ matrix.sanitizer }}-artifacts
44+
path: ./out/artifacts
45+
- name: Upload SARIF
46+
if: always() && steps.build.outcome == 'success'
47+
uses: github/codeql-action/upload-sarif@v4
48+
with:
49+
sarif_file: cifuzz-sarif/results.sarif
50+
checkout_path: cifuzz-sarif

.github/workflows/reusable-context.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ on: # yamllint disable-line rule:truthy
2323
run-ci-fuzz:
2424
description: Whether to run the CIFuzz job for 'cpython' fuzzer
2525
value: ${{ jobs.compute-changes.outputs.run-ci-fuzz }} # bool
26-
run-ci-fuzz-libraries:
26+
run-ci-fuzz-stdlib:
2727
description: Whether to run the CIFuzz job for 'python3-libraries' fuzzer
2828
value: ${{ jobs.compute-changes.outputs.run-ci-fuzz }} # bool
2929
run-docs:
@@ -59,7 +59,7 @@ jobs:
5959
outputs:
6060
run-android: ${{ steps.changes.outputs.run-android }}
6161
run-ci-fuzz: ${{ steps.changes.outputs.run-ci-fuzz }}
62-
run-ci-fuzz-libraries: ${{ steps.changes.outputs.run-ci-fuzz-libraries }}
62+
run-ci-fuzz-stdlib: ${{ steps.changes.outputs.run-ci-fuzz-stdlib }}
6363
run-docs: ${{ steps.changes.outputs.run-docs }}
6464
run-ios: ${{ steps.changes.outputs.run-ios }}
6565
run-macos: ${{ steps.changes.outputs.run-macos }}

Misc/NEWS.d/next/Tools-Demos/2026-01-12-13-37-14.gh-issue-143572.WKV_Jk.rst

Lines changed: 0 additions & 2 deletions
This file was deleted.

Tools/build/compute-changes.py

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import os
1313
import subprocess
14-
from dataclasses import dataclass
14+
from dataclasses import dataclass, fields
1515
from pathlib import Path
1616

1717
TYPE_CHECKING = False
@@ -53,6 +53,7 @@
5353
LIBRARY_FUZZER_PATHS = frozenset({
5454
# All C/CPP fuzzers.
5555
Path("configure"),
56+
Path(".github/workflows/reusable-cifuzz.yml"),
5657
# ast
5758
Path("Lib/ast.py"),
5859
Path("Python/ast.c"),
@@ -100,7 +101,7 @@
100101
class Outputs:
101102
run_android: bool = False
102103
run_ci_fuzz: bool = False
103-
run_ci_fuzz_libraries: bool = False
104+
run_ci_fuzz_stdlib: bool = False
104105
run_docs: bool = False
105106
run_ios: bool = False
106107
run_macos: bool = False
@@ -140,7 +141,7 @@ def compute_changes() -> None:
140141
else:
141142
print("Branch too old for CIFuzz tests; or no C files were changed")
142143

143-
if outputs.run_ci_fuzz_libraries:
144+
if outputs.run_ci_fuzz_stdlib:
144145
print("Run CIFuzz tests for libraries")
145146
else:
146147
print("Branch too old for CIFuzz tests; or no library files were changed")
@@ -206,7 +207,7 @@ def is_fuzzable_library_file(file: Path) -> bool:
206207
def process_changed_files(changed_files: Set[Path]) -> Outputs:
207208
run_tests = False
208209
run_ci_fuzz = False
209-
run_ci_fuzz_libraries = False
210+
run_ci_fuzz_stdlib = False
210211
run_docs = False
211212
run_windows_tests = False
212213
run_windows_msi = False
@@ -220,8 +221,8 @@ def process_changed_files(changed_files: Set[Path]) -> Outputs:
220221
doc_file = file.suffix in SUFFIXES_DOCUMENTATION or doc_or_misc
221222

222223
if file.parent == GITHUB_WORKFLOWS_PATH:
223-
if file.name == "build.yml":
224-
run_tests = run_ci_fuzz = run_ci_fuzz_libraries = True
224+
if file.name == "build.yml" or file.name == "reusable-cifuzz.yml":
225+
run_tests = run_ci_fuzz = run_ci_fuzz_stdlib = True
225226
has_platform_specific_change = False
226227
if file.name == "reusable-docs.yml":
227228
run_docs = True
@@ -256,8 +257,8 @@ def process_changed_files(changed_files: Set[Path]) -> Outputs:
256257
("Modules", "_xxtestfuzz"),
257258
}:
258259
run_ci_fuzz = True
259-
if not run_ci_fuzz_libraries and is_fuzzable_library_file(file):
260-
run_ci_fuzz_libraries = True
260+
if not run_ci_fuzz_stdlib and is_fuzzable_library_file(file):
261+
run_ci_fuzz_stdlib = True
261262

262263
# Check for changed documentation-related files
263264
if doc_file:
@@ -291,7 +292,7 @@ def process_changed_files(changed_files: Set[Path]) -> Outputs:
291292
return Outputs(
292293
run_android=run_android,
293294
run_ci_fuzz=run_ci_fuzz,
294-
run_ci_fuzz_libraries=run_ci_fuzz_libraries,
295+
run_ci_fuzz_stdlib=run_ci_fuzz_stdlib,
295296
run_docs=run_docs,
296297
run_ios=run_ios,
297298
run_macos=run_macos,
@@ -326,17 +327,10 @@ def write_github_output(outputs: Outputs) -> None:
326327
return
327328

328329
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as f:
329-
f.write(f"run-android={bool_lower(outputs.run_android)}\n")
330-
f.write(f"run-ci-fuzz={bool_lower(outputs.run_ci_fuzz)}\n")
331-
f.write(f"run-ci-fuzz-libraries={bool_lower(outputs.run_ci_fuzz_libraries)}\n")
332-
f.write(f"run-docs={bool_lower(outputs.run_docs)}\n")
333-
f.write(f"run-ios={bool_lower(outputs.run_ios)}\n")
334-
f.write(f"run-macos={bool_lower(outputs.run_macos)}\n")
335-
f.write(f"run-tests={bool_lower(outputs.run_tests)}\n")
336-
f.write(f"run-ubuntu={bool_lower(outputs.run_ubuntu)}\n")
337-
f.write(f"run-wasi={bool_lower(outputs.run_wasi)}\n")
338-
f.write(f"run-windows-msi={bool_lower(outputs.run_windows_msi)}\n")
339-
f.write(f"run-windows-tests={bool_lower(outputs.run_windows_tests)}\n")
330+
for field in fields(outputs):
331+
name = field.name.replace("_", "-")
332+
val = bool_lower(getattr(outputs, field.name))
333+
f.write(f"{name}={val}\n")
340334

341335

342336
def bool_lower(value: bool, /) -> str:

0 commit comments

Comments
 (0)