Skip to content
Merged
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
39 changes: 24 additions & 15 deletions .github/workflows/pr-metadata-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,20 @@ jobs:

# Module labels identify which package the PR touches.
# Cross-cutting labels exempt PRs from needing a module label.
LABEL_NAMES=$(echo "$LABELS" | jq -r '.[].name')
# Read label names line-by-line (jq outputs one per line) so
# multi-word GitHub labels are not split by shell word-splitting.
MODULE_LABELS="cuda.bindings cuda.core cuda.pathfinder"
MODULE_EXEMPT_LABELS="CI/CD"
HAS_MODULE=false
for label in $LABEL_NAMES; do
while IFS= read -r label; do
[ -n "$label" ] || continue
for mod in $MODULE_LABELS $MODULE_EXEMPT_LABELS; do
if [ "$label" = "$mod" ]; then
HAS_MODULE=true
break 2
fi
done
done
done < <(echo "$LABELS" | jq -r '.[].name')

if [ "$HAS_MODULE" = "false" ]; then
ERRORS="${ERRORS}- **Missing module label**: add at least one of: \`cuda.bindings\`, \`cuda.core\`, \`cuda.pathfinder\` (or a cross-cutting label such as \`CI/CD\`).\n"
Expand All @@ -66,14 +68,15 @@ jobs:
# Type labels categorize the kind of change.
TYPE_LABELS="bug enhancement feature documentation test example CI/CD packaging dependencies performance experiment RFC support P0 P1 P2"
HAS_TYPE=false
for label in $LABEL_NAMES; do
while IFS= read -r label; do
[ -n "$label" ] || continue
for typ in $TYPE_LABELS; do
if [ "$label" = "$typ" ]; then
HAS_TYPE=true
break 2
fi
done
done
done < <(echo "$LABELS" | jq -r '.[].name')

if [ "$HAS_TYPE" = "false" ]; then
ERRORS="${ERRORS}- **Missing type label**: add at least one of: \`bug\`, \`enhancement\`, \`feature\`, \`documentation\`, \`test\`, \`example\`, \`CI/CD\`, \`packaging\`, \`dependencies\`, \`performance\`, \`experiment\`, \`RFC\`, \`support\`, \`P0\`, \`P1\`, \`P2\`.\n"
Expand All @@ -84,15 +87,21 @@ jobs:
fi

# Block PRs with labels that indicate they are not ready to merge.
BLOCKED_PATTERNS="blocked DO NOT MERGE do not merge"
for label in $LABEL_NAMES; do
for pattern in $BLOCKED_PATTERNS; do
if echo "$label" | grep -qi "$pattern"; then
ERRORS="${ERRORS}- **Blocked label detected**: label \`$label\` prevents merging. Remove it when the PR is ready.\n"
break
fi
done
done
# Match blocked label names exactly (case-insensitively); emit the
# original spelling from the payload so error text matches GitHub.
BLOCKED_LABELS=$(jq -r '
(["blocked", "do not merge"]) as $blocking
| .[]
| .name as $n
| if ($blocking | index($n | ascii_downcase)) != null
then $n
else empty
end
' <<<"$LABELS")
while IFS= read -r label; do
[ -n "$label" ] || continue
ERRORS="${ERRORS}- **Blocked label detected**: label \`$label\` prevents merging. Remove it when the PR is ready.\n"
done <<<"$BLOCKED_LABELS"

if [ -n "$ERRORS" ]; then
echo "::error::This PR is missing required metadata. See the job summary for details."
Expand All @@ -107,7 +116,7 @@ jobs:
fi

ASSIGNEE_LIST=$(echo "$ASSIGNEES" | jq -r '.[].login' | paste -sd ', ' -)
LABEL_LIST=$(echo "$LABEL_NAMES" | paste -sd ', ' -)
LABEL_LIST=$(echo "$LABELS" | jq -r '.[].name' | paste -sd ', ' -)
{
echo "## PR Metadata Check Passed"
echo ""
Expand Down
Loading