Skip to content
Closed
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
26 changes: 23 additions & 3 deletions .github/workflows/restricted-paths-guard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ name: "CI: Restricted Paths Guard"
on:
# Run on drafts too so maintainers get early awareness on WIP PRs.
# Label updates on fork PRs require pull_request_target permissions.
pull_request_target:
# TEMPORARY: Using pull_request for testing; revert to pull_request_target before merge.
pull_request:
types:
- opened
- synchronize
Expand All @@ -29,6 +30,7 @@ jobs:
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_URL: ${{ github.event.pull_request.html_url }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

# Workflow policy inputs
REVIEW_LABEL: Needs-Restricted-Paths-Review
Expand Down Expand Up @@ -113,9 +115,25 @@ jobs:
echo '```'
}

post_review_label_comment() {
local comment_body
printf -v comment_body '%s\n\n%s\n' \
"\`$REVIEW_LABEL\` was assigned by \`CI: Restricted Paths Guard\`." \
"For details, open [this workflow run]($RUN_URL) and click **Summary**."

if gh api "repos/$REPO/issues/$PR_NUMBER/comments" \
-f body="$comment_body" >/dev/null; then
COMMENT_ACTION="posted"
else
COMMENT_ACTION="failed (non-fatal)"
echo "::warning::Failed to post PR comment about newly added $REVIEW_LABEL."
fi
}

HAS_TRUSTED_SIGNAL=false
LABEL_ACTION="not needed (no restricted paths)"
TRUSTED_SIGNALS="(none)"
COMMENT_ACTION="not needed"

if [ "$TOUCHES_RESTRICTED_PATHS" = "true" ]; then
# Distinguish a legitimate 404 "not a collaborator" response from
Expand Down Expand Up @@ -149,13 +167,13 @@ jobs:
fi

case "$COLLABORATOR_PERMISSION" in
admin|maintain|write)
admin|maintain|triage|read)
HAS_TRUSTED_SIGNAL=true
LABEL_ACTION="not needed (collaborator permission is a trusted signal)"
TRUSTED_SIGNALS="collaborator_permission:$COLLABORATOR_PERMISSION"
;;
*)
# triage, read, or none: not a trusted signal
# none: not a trusted signal
;;
esac
fi
Expand Down Expand Up @@ -189,6 +207,7 @@ jobs:
exit 1
else
LABEL_ACTION="added"
post_review_label_comment
fi
elif [ "$LABEL_ALREADY_PRESENT" = "true" ]; then
LABEL_ACTION="left in place (manual removal required)"
Expand All @@ -203,6 +222,7 @@ jobs:
echo "- **Restricted paths**: \`cuda_bindings/\`, \`cuda_python/\`"
echo "- **Trusted signals**: $TRUSTED_SIGNALS"
echo "- **Label action**: $LABEL_ACTION"
echo "- **Comment action**: $COMMENT_ACTION"
if [ "$TOUCHES_RESTRICTED_PATHS" = "true" ]; then
echo ""
write_matching_restricted_paths
Expand Down
1 change: 1 addition & 0 deletions cuda_bindings/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# SPDX-FileCopyrightText: Copyright (c) 2023-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
# XXX DUMMY CHANGE FOR TESTING restricted-paths-guard.yml - REMOVE BEFORE MERGE XXX
[build-system]
requires = [
"setuptools>=80.0.0",
Expand Down
Loading