Draft: Begin implementing auth service #267
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| # | |
| # SPDX-License-Identifier: Apache-2.0 | |
| name: PR Description Check | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened, edited] | |
| branches: [main] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| jobs: | |
| validate-pr-description: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Validate PR Description | |
| env: | |
| PR_BODY: ${{ github.event.pull_request.body }} | |
| run: | | |
| echo "Validating PR description..." | |
| echo "----------------------------------------" | |
| # Initialize error tracking | |
| has_errors=false | |
| error_messages="" | |
| # Check 1: Verify Issue # is present (case-insensitive) | |
| if ! echo "$PR_BODY" | grep -qiE "Issue (#[0-9]+|#None|- None)"; then | |
| has_errors=true | |
| error_messages="${error_messages} | |
| ❌ ERROR: Missing or invalid Issue reference | |
| The PR description must include an issue reference in the format: | |
| 'Issue #XX' (where XX is a number) or 'Issue - None' | |
| (Case-insensitive: 'issue #123' or 'ISSUE #None' are also valid) | |
| Example: | |
| Issue #123 | |
| Issue - None | |
| issue #42 | |
| " | |
| else | |
| echo "✅ Issue reference found" | |
| fi | |
| # Check 2: Verify all checklist items in the Checklist section are checked | |
| # Extract only the Checklist section - more robust approach | |
| # Save PR body to a temp file for easier processing | |
| echo "$PR_BODY" > /tmp/pr_body.txt | |
| # Extract checklist section: from "## Checklist" to next "##" or end of file | |
| checklist_section=$(awk ' | |
| /^## [Cc]hecklist/ { in_checklist=1; next } | |
| in_checklist && /^##/ { exit } | |
| in_checklist { print } | |
| ' /tmp/pr_body.txt) | |
| # Check if we found a checklist section | |
| if [ -z "$checklist_section" ]; then | |
| has_errors=true | |
| error_messages="${error_messages} | |
| ❌ ERROR: Missing Checklist section | |
| The PR description must include a '## Checklist' section. | |
| Please see the PR template: .github/PULL_REQUEST_TEMPLATE.md | |
| " | |
| else | |
| # Count checkbox items in the checklist | |
| total_checkboxes=$(echo "$checklist_section" | grep -cE "^- \[[ x]\]" || true) | |
| unchecked_items=$(echo "$checklist_section" | grep -cE "^- \[ \]" || true) | |
| if [ "$total_checkboxes" -eq 0 ]; then | |
| has_errors=true | |
| error_messages="${error_messages} | |
| ❌ ERROR: No checklist items found | |
| The ## Checklist section exists but contains no checkbox items. | |
| Please see the PR template: .github/PULL_REQUEST_TEMPLATE.md | |
| " | |
| elif [ "$unchecked_items" -gt 0 ]; then | |
| has_errors=true | |
| error_messages="${error_messages} | |
| ❌ ERROR: Incomplete checklist | |
| All checklist items must be completed before the PR can be merged. | |
| Found $unchecked_items unchecked item(s) out of $total_checkboxes in the ## Checklist section. | |
| Please check all boxes in the checklist: | |
| - [x] I am familiar with the Contributing Guidelines | |
| - [x] New or existing tests cover these changes | |
| - [x] The documentation is up to date with these changes | |
| " | |
| else | |
| echo "✅ All $total_checkboxes checklist items are checked" | |
| fi | |
| fi | |
| # Clean up temp file | |
| rm -f /tmp/pr_body.txt | |
| # Report results | |
| if [ "$has_errors" = true ]; then | |
| echo "" | |
| echo "========================================" | |
| echo "PR DESCRIPTION VALIDATION FAILED" | |
| echo "========================================" | |
| echo "$error_messages" | |
| echo "" | |
| echo "Please update your PR description to meet the requirements." | |
| echo "See the PR template: .github/PULL_REQUEST_TEMPLATE.md" | |
| echo "========================================" | |
| exit 1 | |
| else | |
| echo "" | |
| echo "========================================" | |
| echo "✅ PR description validation passed!" | |
| echo "========================================" | |
| fi |