8000 adding a linked pre-triage / linked issue check by shawkins · Pull Request #51034 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

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

Open
shawkins wants to merge 5 commits into
keycloak:mainfrom
shawkins:pre-triage-pr
Open

shawkins wants to merge 5 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.

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.

Comment thread .github/workflows/pre-triage-pr.yml Outdated
FAILED=0
ERRORS=""
MARKER="<!-- pre-triage-linked-issues -->"
SKIP_LABEL="skip-issue-check"
Comment thread .github/workflows/pre-triage-pr.yml Resolved
Comment thread .github/workflows/pre-triage-pr.yml Resolved
Comment thread .github/workflows/pre-triage-pr.yml Resolved
Comment thread .github/workflows/pre-triage-pr.yml Resolved
Comment thread .github/workflows/pre-triage-pr.yml Resolved
@shawkins
shawkins commented Sep 9, 2026
Copy link
Copy Markdown
Contributor Author

Based upon the meeting and initial copilot reviews, I've updated this more.

  • PRs are required to have at least 1 linked open issue that exists in the Keycloak repository. It must be present in both the description and the commit messages.

  • If there is no linked issue, linked to a closed issue, linked to non-issues, or linked to issues in another repo, then the pr will be marked as status/waiting-for-author and a comment added which points out what is wrong and links to the contributing guide.

    • the only exception to this is if a closed issue is marked as "status/expired-by-bot" - if there are no other problems, a status/issue-expired label will be added
  • The detection of linked issues is still based upon the github keywords, as described in the PR description

  • There is now also a workflow for closing or reopening issues. If an issue is closed, and not via expiration, then all linked PRs will be closed. If the issue is marked as expired, then the linked prs are marked as status/issue-expired. If an expired issue is reopened, then the status/expired-by-bot label will be removed from linked prs.

  • no special accommodation is yet being made for drafts

Not part of this PR - a timed job would then be responsible for checking for the status/waiting-for-author label and auto-closing if that label has existed for more than X amount of time. I would suggest deferring that work in any case just to ensure that the labeling and limited closing of this PR is working as expected.

WDYT @stianst @vmuzikar

@shawkins shawkins mentioned this pull request Sep 26, 2026
@ahus1
ahus1 commented Sep 30, 2026
Copy link
Copy Markdown
Member

Thanks for the PR. A general comment: It would be nice to have those scripts as real shell scripts, possibly with a dry-run mode to be able to run them as a developer in a more simple way.

shawkins and others added 4 commits November 4, 2026 14:55
Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Steven Hawkins <shawkins@redhat.com>
tweaking the pre-triage logic

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Signed-off-by: Steve Hawkins <shawkins@redhat.com>
@shawkins
shawkins marked this pull request as ready for review November 25, 2026 15:26
@shawkins
shawkins requested a review from a team as a code owner November 25, 2026 15:26
Copilot AI balanced review requested due to automatic review settings November 25, 2026 15:26
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Comment thread .github/scripts/issue-closure.sh Resolved
Comment thread .github/scripts/issue-closure.sh Resolved
Comment thread .github/scripts/pre-triage-pr.sh Resolved
Comment thread .github/scripts/issue-closure.sh Resolved
printf '%s\n' "$text" | perl -ne '
# Match GitHub closing keywords followed by a same-repo (#NNN),
# cross-repo (owner/repo#NNN), or URL issue reference.
while (/(?i:\b(?:close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved)\b):?[ \t]+(?:(?:(?<cro>[\w-]+)\/(?<crr>[\w-]+)#)|#|(?:https:\/\/github\.com\/(?<urlo>[\w-]+)\/(?<urlr>[\w-]+)\/issues\/))(?<num>\d+)\b/g) {
also restricting to the main repo

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Copilot AI balanced review requested due to automatic review settings December 4, 2026 14:37
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.

🟡 Changes recommended

Case-sensitive repository matching, incorrect linked-issue state and expiration handling, and incomplete label pagination can reject valid references, mislabel PRs, or close exempt PRs.

3 open issues
4 previously missed issues

In code that hasn't changed since last review

Medium severity Recompute expiration across all linked issues

.github/​scripts/​issue-closure.sh:164

Reopening one issue unconditionally clears the PR's expired-issue label, even when another linked issue remains closed with status/expired-by-bot. Recompute expiration across all linked issues before removing the label, matching the aggregate check in pre-triage-pr.sh.

Medium severity Paginate labels before checking exemptions

.github/​scripts/​issue-closure.sh:189

These labels come from labels(first: 20), so skip-issue-check is ignored if it falls beyond that page and an exempt PR can be closed. Fetch all labels with pagination before deciding whether to close the PR.

Medium severity Check external issue state before exemption

.github/​scripts/​pre-triage-pr.sh:199

The cross-repository exemption skips the issue-state check as well as description consistency. A PR with a valid local issue and a manually linked, closed external issue therefore passes, contrary to the requirement that all linked issues be open; validate state before applying the cross-repository exemption.

Medium severity Compare repository names case-insensitively

.github/​scripts/​pre-triage-pr.sh:212

Repository names are case-insensitive on GitHub, but this comparison rejects valid references such as Closes https://github.com/Keycloak/Keycloak/issues/123 as cross-repository links. Normalize repository casing in extracted references and comparisons before checking membership against the canonical GraphQL references.

4 resolved since last review

Review effort: Balanced

my $owner = ($+{cro} // $+{urlo} // "");
my $repo = ($+{crr} // $+{urlr} // "");
my $num = $+{num};
if (!$owner || "$owner/$repo" eq "'$REPO'") {
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.

3 participants

0