Skip to content

Add PR checklist validation to pr-description-check action - #52

Merged
pxLi merged 2 commits into
NVIDIA:mainfrom
pxLi:pr-desc-update
Mar 24, 2026
Merged

pxLi merged 2 commits into
NVIDIA:mainfrom
pxLi:pr-desc-update

Conversation

@pxLi

@pxLi pxLi commented Mar 24, 2026 •

Copy link
Copy Markdown
Member

Fix NVIDIA/cudf-spark#14457

Summary

Some checklist items may be unexpectedly removed from PR descriptions. This change extends the pr-description-check action to verify that all required checklist items from the repo's PR template are still present in the PR body.

How it works

  1. Fetches .github/PULL_REQUEST_TEMPLATE.md from the caller repo via GitHub API at runtime
  2. Extracts all - [ ] checklist items from the template
  3. Verifies each item exists in the PR body (accepts - [ ], - [x], or - [X])
  4. Reports missing items with a clear failure message

Key design decisions

  • No hardcoded checklist items — reads the template dynamically via GitHub API, so the check auto-adapts when the template changes
  • Single commit status — both the HTML comment check and checklist check report under one PR Description status context
  • Graceful fallbacks — skips silently if the template file doesn't exist (404) or has no checklist items; re-throws on unexpected API errors (auth,
    rate limit, 500)
  • Configurable template path — new optional template-path input (defaults to .github/PULL_REQUEST_TEMPLATE.md)
  • Backward compatible — no changes required in caller repos; existing workflows pick this up automatically

Verified in forked repos

Has HTML comments, missing checklist items.
image

Has HTML comments only,
image

Missing checklist items only,
image

Passed,
image

No template,
image

Signed-off-by: Peixin Li <pxLi@nyu.edu>
@pxLi pxLi self-assigned this Mar 24, 2026
@pxLi
pxLi requested a review from a team as a code owner March 24, 2026 06:06
@greptile-apps

greptile-apps Bot commented Mar 24, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR extends the pr-description-check composite action to validate that all required checklist items from the caller repo's PR template are still present in a PR's description, in addition to the existing HTML comment check. Both checks now share a single PR Description commit status context.

Key changes and observations:

  • The previously flagged concern about an unguarded getContent response (directory array or >1MB file) has been addressed — the new type !== 'file' || content == null guard on lines 59–60 handles both cases cleanly before attempting base64 decoding.
  • Checklist item matching correctly accepts - [ ], - [x], and - [X] variants in the PR body, and uses .trim() to handle trailing carriage-returns from CRLF line endings.
  • Graceful fallback for a missing template (HTTP 404) and empty checklist sections (no items found) ensures backward compatibility and no false positives for repos without a template.
  • Passing template-path via process.env.TEMPLATE_PATH rather than direct string interpolation into the script avoids potential script injection, which is the correct pattern for actions/github-script.
  • The core.setFailed call does not interrupt execution (it only sets the process exit code), so createCommitStatus is always reached — this is the intended behavior and is correctly implemented.

Confidence Score: 5/5

  • This PR is safe to merge; the implementation is correct and the previously raised concern has been fully addressed.
  • All edge cases (404, directory listing, large file, no checklist items) are handled gracefully. The regex correctly captures single-line checklist items with CRLF tolerance via .trim(). The core.setFailed/createCommitStatus ordering is intentional and correct. No P0 or P1 issues found. The previously flagged non-file guard issue has been resolved in this revision.
  • No files require special attention.

Important Files Changed

Filename Overview
pr-description-check/action.yml Extends the composite action to validate PR template checklist items alongside the existing HTML comment check. Handles edge cases (404, directory, >1MB file) correctly with guards. Logic is clean and backward-compatible.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A([PR event triggered]) --> B[Fetch PR body and SHA]
    B --> C{PR body contains HTML comment?}
    C -- Yes --> D[errors: has HTML comments]
    C -- No --> E[Continue]
    D --> E

    E --> F[Fetch PR template via getContent API]
    F --> G{HTTP 404?}
    G -- Yes --> H[Skip checklist check]
    G -- No --> I{type is not file or content is null?}
    I -- Yes --> J[Skip checklist check]
    I -- No --> K[Decode base64 to templateContent]

    K --> L[Extract unchecked items from template]
    L --> M{templateItems length > 0?}
    M -- No --> N[Skip checklist check]
    M -- Yes --> O[Extract all items from PR body into Set]
    O --> P[Filter template items not in body Set]
    P --> Q{Missing items found?}
    Q -- Yes --> R[errors: missing checklist items]
    Q -- No --> S[Continue]
    R --> S

    H --> T{Any errors?}
    J --> T
    N --> T
    S --> T

    T -- Yes --> U[core.setFailed with detailed message]
    T -- No --> V[statusDesc = PR description is valid]
    U --> W[createCommitStatus state=failure]
    V --> X[createCommitStatus state=success]
Loading

Reviews (2): Last reviewed commit: "address comments" | Re-trigger Greptile

Comment thread pr-description-check/action.yml
@pxLi pxLi added the enhancement New feature or request label Mar 24, 2026
@pxLi
pxLi merged commit 26b2730 into NVIDIA:main Mar 24, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEA] Enforce PR template checklist completion in pr-description-check

3 participants