Skip to content

Commit 8e56c4e

Browse files
rparolinclaude
andcommitted
Enhance PR metadata check with structured label validation
Inspired by the RAPIDS label checker, this strengthens the PR metadata check to require both a module label and a type label, block merge- preventing labels, and render results as a GitHub Job Summary. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0ae7729 commit 8e56c4e

File tree

1 file changed

+60
-11
lines changed

1 file changed

+60
-11
lines changed

.github/workflows/pr-metadata-check.yml

Lines changed: 60 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ on:
1212
- synchronize
1313
- labeled
1414
- unlabeled
15-
# - milestoned
16-
# - demilestoned
15+
- reopened
16+
- ready_for_review
1717

1818
jobs:
1919
check-metadata:
@@ -34,23 +34,72 @@ jobs:
3434
exit 0
3535
fi
3636
37-
LABEL_COUNT=$(echo "$LABELS" | jq 'length')
37+
LABEL_NAMES=$(echo "$LABELS" | jq -r '.[].name')
3838
ERRORS=""
3939
40-
if [ "$LABEL_COUNT" -eq 0 ]; then
41-
ERRORS="${ERRORS} - Missing labels: add at least one label to categorize this PR.\n"
40+
# Module labels identify which package the PR touches.
41+
MODULE_LABELS="cuda.bindings cuda.core cuda.pathfinder"
42+
HAS_MODULE=false
43+
for label in $LABEL_NAMES; do
44+
for mod in $MODULE_LABELS; do
45+
if [ "$label" = "$mod" ]; then
46+
HAS_MODULE=true
47+
break 2
48+
fi
49+
done
50+
done
51+
52+
if [ "$HAS_MODULE" = "false" ]; then
53+
ERRORS="${ERRORS}- **Missing module label**: add at least one of: \`cuda.bindings\`, \`cuda.core\`, \`cuda.pathfinder\`.\n"
54+
fi
55+
56+
# Type labels categorize the kind of change.
57+
TYPE_LABELS="bug enhancement feature documentation test example CI/CD packaging dependencies performance experiment RFC support P0 P1 P2"
58+
HAS_TYPE=false
59+
for label in $LABEL_NAMES; do
60+
for typ in $TYPE_LABELS; do
61+
if [ "$label" = "$typ" ]; then
62+
HAS_TYPE=true
63+
break 2
64+
fi
65+
done
66+
done
67+
68+
if [ "$HAS_TYPE" = "false" ]; then
69+
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"
4270
fi
4371
4472
if [ -z "$MILESTONE" ]; then
45-
ERRORS="${ERRORS} - Missing milestone: assign a milestone to this PR.\n"
73+
ERRORS="${ERRORS}- **Missing milestone**: assign a milestone to this PR.\n"
4674
fi
4775
76+
# Block PRs with labels that indicate they are not ready to merge.
77+
BLOCKED_PATTERNS="blocked DO NOT MERGE do not merge"
78+
for label in $LABEL_NAMES; do
79+
for pattern in $BLOCKED_PATTERNS; do
80+
if echo "$label" | grep -qi "$pattern"; then
81+
ERRORS="${ERRORS}- **Blocked label detected**: label \`$label\` prevents merging. Remove it when the PR is ready.\n"
82+
break
83+
fi
84+
done
85+
done
86+
4887
if [ -n "$ERRORS" ]; then
49-
echo "::error::This PR is missing required metadata:"
50-
printf "$ERRORS"
51-
echo ""
52-
echo "Please update the PR at: $PR_URL"
88+
echo "::error::This PR is missing required metadata. See the job summary for details."
89+
{
90+
echo "## PR Metadata Check Failed"
91+
echo ""
92+
printf "$ERRORS"
93+
echo ""
94+
echo "Please update the PR at: $PR_URL"
95+
} >> "$GITHUB_STEP_SUMMARY"
5396
exit 1
5497
fi
5598
56-
echo "PR has $LABEL_COUNT label(s) and milestone '$MILESTONE'."
99+
LABEL_LIST=$(echo "$LABEL_NAMES" | paste -sd ', ' -)
100+
{
101+
echo "## PR Metadata Check Passed"
102+
echo ""
103+
echo "- **Labels**: $LABEL_LIST"
104+
echo "- **Milestone**: $MILESTONE"
105+
} >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)