Skip to content

adding a linked pre-triage / linked issue check - #51034

Draft
shawkins wants to merge 2 commits into
keycloak:mainfrom
shawkins:pre-triage-pr
Draft

adding a linked pre-triage / linked issue check#51034
shawkins wants to merge 2 commits into
keycloak:mainfrom
shawkins:pre-triage-pr

Conversation

@shawkins

Copy link
Copy Markdown
Contributor

Refinement of the previous pre-triage check - based in part on #50075 (review)

This removes:

  • any interaction with the DCO check
  • the usage of third-party github actions

As explained on https://github.com/keycloak/keycloak-ibm-team/issues/31#issuecomment-5004145360 this PR reflects the same understanding of issue linking (all closing keywords, optional colon, casing) that github has with the additional checks:

  • the PR description must contain a linked issue
  • the linked issues in the description, commits, and manually linked must all be the same and open issues.
  • only manually linked issues, which can only be manipulated by contributors, may contain references to other repos - or that could be disallowed as well.

Violations to the above result in a comment on the PR highlighting what is wrong, a label is added to the PR, and the workflow fails. Alternatively a label can be added to skip this check.

See the comments in the script for some TODOs and other concerns - additional thoughts:

  • the handling may need to be relaxed for forks
  • could be changed to not run on a draft

From here if you want to be more strict about the number of linked issues, the syntax used, etc. that can be added - but I would avoid assigning special meaning to keywords.

Signed-off-by: Steve Hawkins <shawkins@redhat.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds automated pre-triage validation for issue links in pull requests and commits.

Changes:

  • Validates linked issues for consistency, repository, and open state.
  • Posts failure comments and manages triage labels.
  • Supports bypassing validation through a label.

FAILED=0
ERRORS=""
MARKER="<!-- pre-triage-linked-issues -->"
SKIP_LABEL="skip-issue-check"
Comment on lines +80 to +82
if ! commit_msg=$(gh api "repos/$REPO/git/commits/$sha" --jq '.message' 2>&1); then
add_error "Failed to retrieve commit message for $sha: $commit_msg"
continue
Comment on lines +131 to +132
CLOSING_ISSUES_REFERENCES_RAW=$(
gh api graphql \
fi

# Find matching line: owner/repo#NNN<TAB>true|false
state_line=$(printf '%s\n' "$CLOSING_ISSUES_WITH_STATE" | grep -F -- "^$ref"$'\t' || true)
Comment thread .github/workflows/pre-triage-pr.yml Outdated
Comment thread .github/workflows/pre-triage-pr.yml
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Steven Hawkins <shawkins@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants