Skip to content

Commit 94c0cb7

Browse files
committed
Run a small subset of targets on pull requests w/o labels
Run a small subset of targets on pull requests when no labels are specified. If labels are specified they filter the full set of targets. On a push all targets are run.
1 parent a186551 commit 94c0cb7

6 files changed

Lines changed: 95 additions & 3 deletions

File tree

.github/workflows/linux.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ jobs:
178178
--platform linux \
179179
--labels "${STEPS_GET_LABELS_OUTPUTS_LABELS}" \
180180
--max-shards 2 \
181+
--event ${{ github.event_name }} \
181182
${{ (steps.check-pythonbuild.outputs.changed == 'true' || github.ref == 'refs/heads/main') && '--force-crate-build' || '' }} \
182183
> matrix.json
183184

.github/workflows/macos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292
- name: Generate build matrix
9393
id: set-matrix
9494
run: |
95-
uv run ci-matrix.py --platform darwin --labels "${STEPS_GET_LABELS_OUTPUTS_LABELS}" ${{ (steps.check-pythonbuild.outputs.changed == 'true' || github.ref == 'refs/heads/main') && '--force-crate-build' || '' }} > matrix.json
95+
uv run ci-matrix.py --platform darwin --labels "${STEPS_GET_LABELS_OUTPUTS_LABELS}" --event ${{ github.event_name }} ${{ (steps.check-pythonbuild.outputs.changed == 'true' || github.ref == 'refs/heads/main') && '--force-crate-build' || '' }} > matrix.json
9696
9797
# Extract python-build matrix
9898
echo "matrix=$(jq -c '."python-build"' matrix.json)" >> $GITHUB_OUTPUT

.github/workflows/windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292
- name: Generate build matrix
9393
id: set-matrix
9494
run: |
95-
uv run ci-matrix.py --platform windows --labels "${STEPS_GET_LABELS_OUTPUTS_LABELS}" ${{ (steps.check-pythonbuild.outputs.changed == 'true' || github.ref == 'refs/heads/main') && '--force-crate-build' || '' }} > matrix.json
95+
uv run ci-matrix.py --platform windows --labels "${STEPS_GET_LABELS_OUTPUTS_LABELS}" --event ${{ github.event_name }} ${{ (steps.check-pythonbuild.outputs.changed == 'true' || github.ref == 'refs/heads/main') && '--force-crate-build' || '' }} > matrix.json
9696
9797
# Extract python-build matrix
9898
echo "matrix=$(jq -c '."python-build"' matrix.json)" >> $GITHUB_OUTPUT

ci-defaults.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Describes the default targets that CI will build for different events.
2+
3+
pull_request:
4+
python_version: "3.14"
5+
6+
targets:
7+
x86_64-pc-windows-msvc:
8+
build_options:
9+
- pgo
10+
11+
aarch64-apple-darwin:
12+
build_options:
13+
- pgo+lto
14+
15+
x86_64-unknown-linux-gnu:
16+
build_options:
17+
- pgo+lto
18+
- freethreaded+pgo+lto
19+
20+
x86_64-unknown-linux-musl:
21+
build_options:
22+
- lto
23+
- lto+static
24+
- freethreaded+lto
25+
26+
armv7-unknown-linux-gnueabihf:
27+
build_options:
28+
- lto

ci-matrix.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from packaging.version import Version
1616

1717
CI_TARGETS_YAML = "ci-targets.yaml"
18+
CI_TARGETS_PULL_REQUEST_NO_LABELS = "ci-targets-pull-request-no-labels.yaml"
1819
CI_RUNNERS_YAML = "ci-runners.yaml"
1920
CI_EXTRA_SKIP_LABELS = ["documentation"]
2021
CI_MATRIX_SIZE_LIMIT = 256 # The maximum size of a matrix in GitHub Actions
@@ -343,6 +344,11 @@ def parse_args() -> argparse.Namespace:
343344
"--labels",
344345
help="Comma-separated list of labels to filter by (e.g., 'platform:darwin,python:3.13,build:debug'), all must match.",
345346
)
347+
parser.add_argument(
348+
"--event",
349+
choices=["pull_request", "push"],
350+
help="The GitHub event type. When 'pull_request', uses ci-defaults.yaml for the default subset.",
351+
)
346352
parser.add_argument(
347353
"--free-runners",
348354
action="store_true",
@@ -366,7 +372,11 @@ def main() -> None:
366372
args = parse_args()
367373
labels = parse_labels(args.labels)
368374

369-
with open(CI_TARGETS_YAML) as f:
375+
if args.event == "pull_request" and not any(labels.values()):
376+
config_yaml = CI_TARGETS_PULL_REQUEST_NO_LABELS
377+
else:
378+
config_yaml = CI_TARGETS_YAML
379+
with open(config_yaml) as f:
370380
config = yaml.safe_load(f)
371381

372382
with open(CI_RUNNERS_YAML) as f:
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Describes the targets that the CI system will build on a pull request if no labels are specified
2+
# This is a subset of the targets from ci-targets.yaml
3+
4+
darwin:
5+
aarch64-apple-darwin:
6+
arch: aarch64
7+
python_versions:
8+
- "3.14"
9+
build_options:
10+
- pgo+lto
11+
12+
linux:
13+
armv7-unknown-linux-gnueabihf:
14+
arch: armv7
15+
libc: gnu
16+
python_versions:
17+
- "3.14"
18+
build_options:
19+
- lto
20+
21+
x86_64-unknown-linux-gnu:
22+
arch: x86_64
23+
libc: gnu
24+
python_versions:
25+
- "3.14"
26+
build_options:
27+
- pgo+lto
28+
- freethreaded+pgo+lto
29+
run: true
30+
31+
x86_64-unknown-linux-musl:
32+
arch: x86_64
33+
libc: musl
34+
python_versions:
35+
- "3.14"
36+
build_options:
37+
- lto+static
38+
- lto
39+
- freethreaded+lto
40+
run: true
41+
42+
windows:
43+
x86_64-pc-windows-msvc:
44+
arch: x86_64
45+
vcvars: vcvars64.bat
46+
python_versions:
47+
- "3.14"
48+
vs_version: "2022"
49+
vs_version_override_conditional:
50+
vs_version: "2026"
51+
minimum-python-version: "3.15"
52+
build_options:
53+
- pgo

0 commit comments

Comments
 (0)