Skip to content

Commit

Permalink
Skip builds on ci:skip or documentation labels (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb authored Dec 18, 2024
1 parent 3291dfe commit b7dd472
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ci-matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from packaging.version import Version

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


def meets_conditional_version(version: str, min_version: str) -> bool:
Expand All @@ -31,12 +32,20 @@ def parse_labels(labels: Optional[str]) -> dict[str, set[str]]:
"build": set(),
"arch": set(),
"libc": set(),
"directives": set(),
}

for label in labels.split(","):
label = label.strip()

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

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

category, value = label.split(":", 1)
if category in result:
result[category].add(value)
Expand All @@ -46,6 +55,9 @@ def parse_labels(labels: Optional[str]) -> dict[str, set[str]]:

def should_include_entry(entry: dict[str, str], filters: dict[str, set[str]]) -> bool:
"""Check if an entry satisfies the label filters."""
if filters.get("directives") and "skip" in filters["directives"]:
return False

if filters.get("platform") and entry["platform"] not in filters["platform"]:
return False

Expand Down

0 comments on commit b7dd472

Please sign in to comment.