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
18 changes: 14 additions & 4 deletions .github/workflows/pr-metadata-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,30 @@
#
# SPDX-License-Identifier: Apache-2.0

name: "CI: Enforce label/milestone on PRs"
name: "CI: Enforce assignee/label/milestone on PRs"

on:
pull_request_target:
types:
- opened
- edited
- synchronize
- assigned
- unassigned
- labeled
- unlabeled
- reopened
- ready_for_review

jobs:
check-metadata:
name: PR has labels and milestone
name: PR has assignee, labels, and milestone
if: github.repository_owner == 'NVIDIA'
runs-on: ubuntu-latest
steps:
- name: Check for labels and milestone
- name: Check for assignee, labels, and milestone
env:
ASSIGNEES: ${{ toJson(github.event.pull_request.assignees) }}
LABELS: ${{ toJson(github.event.pull_request.labels) }}
MILESTONE: ${{ github.event.pull_request.milestone && github.event.pull_request.milestone.title || '' }}
PR_URL: ${{ github.event.pull_request.html_url }}
Expand All @@ -34,11 +37,16 @@ jobs:
exit 0
fi

LABEL_NAMES=$(echo "$LABELS" | jq -r '.[].name')
ERRORS=""

ASSIGNEE_COUNT=$(echo "$ASSIGNEES" | jq 'length')
if [ "$ASSIGNEE_COUNT" -eq 0 ]; then
ERRORS="${ERRORS}- **Missing assignee**: assign at least one person to this PR.\n"
fi

# 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')
MODULE_LABELS="cuda.bindings cuda.core cuda.pathfinder"
MODULE_EXEMPT_LABELS="CI/CD"
HAS_MODULE=false
Expand Down Expand Up @@ -98,10 +106,12 @@ jobs:
exit 1
fi

ASSIGNEE_LIST=$(echo "$ASSIGNEES" | jq -r '.[].login' | paste -sd ', ' -)
LABEL_LIST=$(echo "$LABEL_NAMES" | paste -sd ', ' -)
{
echo "## PR Metadata Check Passed"
echo ""
echo "- **Assignees**: $ASSIGNEE_LIST"
echo "- **Labels**: $LABEL_LIST"
echo "- **Milestone**: $MILESTONE"
} >> "$GITHUB_STEP_SUMMARY"
Loading