Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ci:dry-run to skip performing builds but still test the matrix #437

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/apple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ jobs:
path: build

- name: Build
if: ${{ ! matrix.dry-run }}
run: |
if [ "${{ matrix.target_triple }}" = "aarch64-apple-darwin" ]; then
export APPLE_SDK_PATH=/Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk
Expand All @@ -103,18 +104,22 @@ jobs:
./build-macos.py --target-triple ${{ matrix.target_triple }} --python cpython-${{ matrix.python }} --options ${{ matrix.build_options }}

- name: Upload Distributions
if: ${{ ! matrix.dry-run }}
uses: actions/upload-artifact@v4
with:
name: cpython-${{ matrix.python }}-${{ matrix.target_triple }}-${{ matrix.build_options }}
path: dist/*

- uses: actions/checkout@v4
- name: Checkout macOS SDKs for validation
Comment on lines -111 to +113
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(otherwise it's really confusing why there's a checkout action running here)

if: ${{ ! matrix.dry-run }}
uses: actions/checkout@v4
with:
repository: 'phracker/MacOSX-SDKs'
ref: master
path: macosx-sdks

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

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ jobs:
done

- name: Build
if: ${{ ! matrix.dry-run }}
run: |
# Do empty target so all generated files are touched.
./build-linux.py --make-target empty
Expand All @@ -195,6 +196,7 @@ jobs:
./build-linux.py --target-triple ${{ matrix.target_triple }} --python cpython-${{ matrix.python }} --options ${{ matrix.build_options }}

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

Expand All @@ -205,6 +207,7 @@ jobs:
build/pythonbuild validate-distribution ${EXTRA_ARGS} dist/*.tar.zst

- name: Upload Distribution
if: ${{ ! matrix.dry-run }}
uses: actions/upload-artifact@v4
with:
name: cpython-${{ matrix.python }}-${{ matrix.target_triple }}-${{ matrix.build_options }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@ jobs:
py.exe -3.9 build-windows.py --help

- name: Build
if: ${{ ! matrix.dry-run }}
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\${{ matrix.vcvars }}"
py.exe -3.9 build-windows.py --python cpython-${{ matrix.python }} --sh c:\cygwin\bin\sh.exe --options ${{ matrix.build_options }}

- name: Validate Distribution
if: ${{ ! matrix.dry-run }}
run: |
$Dists = Resolve-Path -Path "dist/*.tar.zst" -Relative
.\pythonbuild.exe validate-distribution --run $Dists
Expand Down
15 changes: 12 additions & 3 deletions ci-matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from packaging.version import Version

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


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

# Handle special directive labels
if label in CI_SKIP_LABELS:
# Handle special labels
if label in CI_EXTRA_SKIP_LABELS:
result["directives"].add("skip")
continue

if not label or ":" not in label:
continue

category, value = label.split(":", 1)

if category == "ci":
category = "directives"
Comment on lines +51 to +52
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could just avoid this rename and use ci instead of directives throughout, not sure if it really matters.


if category in result:
result[category].add(value)

Expand Down Expand Up @@ -95,6 +99,7 @@ def generate_matrix_entries(
target_triple,
target_config,
platform,
label_filters.get("directives", set()),
)

# Apply label filters if present
Expand All @@ -113,6 +118,7 @@ def add_matrix_entries_for_config(
target_triple: str,
config: dict[str, Any],
platform: str,
directives: set[str],
) -> None:
python_versions = config["python_versions"]
build_options = config["build_options"]
Expand All @@ -135,6 +141,9 @@ def add_matrix_entries_for_config(
if "run" in config:
base_entry["run"] = str(config["run"]).lower()

if "dry-run" in directives:
base_entry["dry-run"] = "true"

# Process regular build options
for python_version in python_versions:
for build_option in build_options:
Expand Down
Loading