Skip to content

Commit 6b4d414

Browse files
authored
Add ci:dry-run to skip performing builds but still test the matrix (#437)
In general, I think this will be a little niche but in the short-term it'll be really helpful for iterating on our build matrix.
1 parent b7dd472 commit 6b4d414

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

.github/workflows/apple.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ jobs:
9090
path: build
9191

9292
- name: Build
93+
if: ${{ ! matrix.dry-run }}
9394
run: |
9495
if [ "${{ matrix.target_triple }}" = "aarch64-apple-darwin" ]; then
9596
export APPLE_SDK_PATH=/Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk
@@ -103,18 +104,22 @@ jobs:
103104
./build-macos.py --target-triple ${{ matrix.target_triple }} --python cpython-${{ matrix.python }} --options ${{ matrix.build_options }}
104105
105106
- name: Upload Distributions
107+
if: ${{ ! matrix.dry-run }}
106108
uses: actions/upload-artifact@v4
107109
with:
108110
name: cpython-${{ matrix.python }}-${{ matrix.target_triple }}-${{ matrix.build_options }}
109111
path: dist/*
110112

111-
- uses: actions/checkout@v4
113+
- name: Checkout macOS SDKs for validation
114+
if: ${{ ! matrix.dry-run }}
115+
uses: actions/checkout@v4
112116
with:
113117
repository: 'phracker/MacOSX-SDKs'
114118
ref: master
115119
path: macosx-sdks
116120

117121
- name: Validate Distribution
122+
if: ${{ ! matrix.dry-run }}
118123
run: |
119124
chmod +x build/pythonbuild
120125

.github/workflows/linux.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ jobs:
185185
done
186186
187187
- name: Build
188+
if: ${{ ! matrix.dry-run }}
188189
run: |
189190
# Do empty target so all generated files are touched.
190191
./build-linux.py --make-target empty
@@ -195,6 +196,7 @@ jobs:
195196
./build-linux.py --target-triple ${{ matrix.target_triple }} --python cpython-${{ matrix.python }} --options ${{ matrix.build_options }}
196197
197198
- name: Validate Distribution
199+
if: ${{ ! matrix.dry-run }}
198200
run: |
199201
chmod +x build/pythonbuild
200202
@@ -205,6 +207,7 @@ jobs:
205207
build/pythonbuild validate-distribution ${EXTRA_ARGS} dist/*.tar.zst
206208
207209
- name: Upload Distribution
210+
if: ${{ ! matrix.dry-run }}
208211
uses: actions/upload-artifact@v4
209212
with:
210213
name: cpython-${{ matrix.python }}-${{ matrix.target_triple }}-${{ matrix.build_options }}

.github/workflows/windows.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,14 @@ jobs:
100100
py.exe -3.9 build-windows.py --help
101101
102102
- name: Build
103+
if: ${{ ! matrix.dry-run }}
103104
shell: cmd
104105
run: |
105106
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\${{ matrix.vcvars }}"
106107
py.exe -3.9 build-windows.py --python cpython-${{ matrix.python }} --sh c:\cygwin\bin\sh.exe --options ${{ matrix.build_options }}
107108
108109
- name: Validate Distribution
110+
if: ${{ ! matrix.dry-run }}
109111
run: |
110112
$Dists = Resolve-Path -Path "dist/*.tar.zst" -Relative
111113
.\pythonbuild.exe validate-distribution --run $Dists

ci-matrix.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from packaging.version import Version
1515

1616
CI_TARGETS_YAML = "ci-targets.yaml"
17-
CI_SKIP_LABELS = ["ci:skip", "documentation"]
17+
CI_EXTRA_SKIP_LABELS = ["documentation"]
1818

1919

2020
def meets_conditional_version(version: str, min_version: str) -> bool:
@@ -38,15 +38,19 @@ def parse_labels(labels: Optional[str]) -> dict[str, set[str]]:
3838
for label in labels.split(","):
3939
label = label.strip()
4040

41-
# Handle special directive labels
42-
if label in CI_SKIP_LABELS:
41+
# Handle special labels
42+
if label in CI_EXTRA_SKIP_LABELS:
4343
result["directives"].add("skip")
4444
continue
4545

4646
if not label or ":" not in label:
4747
continue
4848

4949
category, value = label.split(":", 1)
50+
51+
if category == "ci":
52+
category = "directives"
53+
5054
if category in result:
5155
result[category].add(value)
5256

@@ -95,6 +99,7 @@ def generate_matrix_entries(
9599
target_triple,
96100
target_config,
97101
platform,
102+
label_filters.get("directives", set()),
98103
)
99104

100105
# Apply label filters if present
@@ -113,6 +118,7 @@ def add_matrix_entries_for_config(
113118
target_triple: str,
114119
config: dict[str, Any],
115120
platform: str,
121+
directives: set[str],
116122
) -> None:
117123
python_versions = config["python_versions"]
118124
build_options = config["build_options"]
@@ -135,6 +141,9 @@ def add_matrix_entries_for_config(
135141
if "run" in config:
136142
base_entry["run"] = str(config["run"]).lower()
137143

144+
if "dry-run" in directives:
145+
base_entry["dry-run"] = "true"
146+
138147
# Process regular build options
139148
for python_version in python_versions:
140149
for build_option in build_options:

0 commit comments

Comments
 (0)