Skip to content

PR review action fixes#13862

Merged
JamesNK merged 8 commits intomainfrom
jamesnk/pr-tracking-action-wip
Jan 14, 2026
Merged

PR review action fixes#13862
JamesNK merged 8 commits intomainfrom
jamesnk/pr-tracking-action-wip

Conversation

@JamesNK
Copy link
Copy Markdown
Member

@JamesNK JamesNK commented Jan 13, 2026

tldr; a workflow that runs every couple of hours and finds PRs that are waiting on feedback. It updates #13834 issue with results

This is a vibed experiment to learn about GH actions, and maybe solve a problem.

Changes:

This pull request makes significant improvements to the pr-review-needed GitHub Actions workflow. The changes enhance the accuracy of PR review tracking, improve performance for large repositories, and make the resulting tracking issue more informative and user-friendly. The workflow now distinguishes between team and community PRs, uses more precise logic for determining when a PR needs review, and presents the data in a clearer format.

Workflow logic and review detection improvements:

  • Refactored the logic for detecting when a PR needs review: now considers the last internal (author/prompter) and external (reviewer) activities, uses timeline events to accurately determine when a PR was marked ready for review, and ignores bot/Copilot activities. This ensures the workflow only flags PRs that are truly waiting on reviewer feedback.
  • Added logic to skip PRs created by bots and treat Copilot PRs as authored by the first non-Copilot assignee, improving author attribution. [1] [2]

Performance and reliability enhancements:

  • Implemented a robust pagination helper (getAllPages) to fetch all relevant data (PRs, comments, reviews, etc.), ensuring the workflow scales to large repositories with many PRs and activities.

User experience and reporting improvements:

  • The workflow now runs every two hours (in addition to manual triggers), ensuring the tracking issue remains up-to-date.
  • The tracking issue now splits PRs into "Team PRs" and "Community Contributions" sections, and uses colored indicators (🔴, 🟡, 🟢) to show the age of each PR needing feedback. The table columns and messages have been updated for clarity.
  • Improved the way PRs are passed between workflow steps (using environment variables) for better reliability. [1] [2]

These changes collectively make the review-tracking process more accurate, scalable, and actionable for the team.

@JamesNK JamesNK added the area-engineering-systems infrastructure helix infra engineering repo stuff label Jan 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 13, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13862

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13862"

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request enhances the pr-review-needed GitHub Actions workflow to more accurately track PRs awaiting reviewer feedback. The workflow now runs every 2 hours (previously manual-only), implements pagination for scalability, filters out bot/Copilot activities from consideration, and presents results in a clearer format with team and community PRs separated and age-based visual indicators.

Changes:

  • Added scheduled execution every 2 hours and improved pagination handling for all API calls
  • Enhanced PR review detection logic with timeline events, internal/external activity tracking, and bot/Copilot filtering
  • Improved issue formatting with team/community split, colored age indicators (🔴🟡🟢), and clearer column headers
Comments suppressed due to low confidence (1)

.github/workflows/pr-review-needed.yml:118

  • Bot PRs are skipped at line 70 with the condition pr.user.login.endsWith('[bot]'), but then lines 108-118 contain logic to handle bot PRs and extract the prompter. This code is unreachable because all bot PRs are filtered out earlier. Either remove the early bot filtering (line 70-72) to allow the bot PR logic to execute, or remove the unreachable bot PR handling code (lines 108-118). Based on the PR description mentioning "treat Copilot PRs as authored by the first non-Copilot assignee", it seems the intent is to keep bot PR handling, so the early filter should be more selective (e.g., only skip certain bots, not Copilot).
              // Skip PRs created by bots
              if (pr.user.login.endsWith('[bot]')) {
                continue;
              }
              
              // Get reviews to check if PR is approved
              const reviews = await getAllPages(github.rest.pulls.listReviews, {
                owner: context.repo.owner,
                repo: context.repo.repo,
                pull_number: pr.number
              });
              
              // Check if there's a current approval by looking at each reviewer's most recent review
              // A reviewer might approve, then later request changes - we need the latest state
              const reviewerStates = new Map();
              for (const review of reviews) {
                // Only consider meaningful review states (not COMMENTED or PENDING)
                if (['APPROVED', 'CHANGES_REQUESTED', 'DISMISSED'].includes(review.state)) {
                  const reviewer = review.user.login.toLowerCase();
                  const existingReview = reviewerStates.get(reviewer);
                  const reviewDate = new Date(review.submitted_at);
                  
                  if (!existingReview || reviewDate > existingReview.date) {
                    reviewerStates.set(reviewer, { state: review.state, date: reviewDate });
                  }
                }
              }
              
              // PR is approved if at least one reviewer's latest state is APPROVED
              const isApproved = Array.from(reviewerStates.values()).some(r => r.state === 'APPROVED');
              if (isApproved) {
                continue;
              }
              
              // Get the PR author
              const prAuthor = pr.user.login;
              
              // For Copilot-created PRs, check if there's a prompter
              // Bot accounts have '[bot]' suffix in their username
              const isBotPr = prAuthor.endsWith('[bot]');
              
              // Get the prompter from the PR body if it's a bot PR
              let prompter = null;
              if (isBotPr && pr.body) {
                // Look for patterns like "Triggered by @username" or "Requested by @username"
                const prompterMatch = pr.body.match(/(?:triggered|requested|prompted)\s+by\s+@(\w+)/i);
                if (prompterMatch) {
                  prompter = prompterMatch[1];
                }
              }

tableContent += '### Community Contributions\n\n';
tableContent += generatePRTable(communityPRs, 'No community PRs currently need review.');

tableContent += '\n_This list is automatically updated every hour._';
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

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

The message says "This list is automatically updated every hour" but the workflow is configured to run every 2 hours (cron: '0 */2 * * *'). The message should be updated to say "every 2 hours" to match the actual schedule.

Suggested change
tableContent += '\n_This list is automatically updated every hour._';
tableContent += '\n_This list is automatically updated every 2 hours._';

Copilot uses AI. Check for mistakes.
@radical
Copy link
Copy Markdown
Member

radical commented Jan 13, 2026

@copilot a PR that has the NO-MERGE label should be skipped

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 13, 2026

@radical I've opened a new pull request, #13880, to work on those changes. Once the pull request is ready, I'll request review from you.

@radical
Copy link
Copy Markdown
Member

radical commented Jan 13, 2026

@copilot In this PR for the workflow, if the PR being considered in the script has the NO-MERGE label then it should be skipped.

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 13, 2026

@radical I've opened a new pull request, #13881, to work on those changes. Once the pull request is ready, I'll request review from you.

@radical
Copy link
Copy Markdown
Member

radical commented Jan 13, 2026

We should also mark PRs that have merge conflicts in the output table.

* Initial plan

* Skip PRs with NO-MERGE label in pr-review-needed workflow

Co-authored-by: radical <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: radical <[email protected]>
@radical
Copy link
Copy Markdown
Member

radical commented Jan 13, 2026

@copilot for any PRs being considered in the workflow, if the PR has merge conflicts then add an emoji like red cross next to the PR title in the generated table.

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 13, 2026

@radical I've opened a new pull request, #13882, to work on those changes. Once the pull request is ready, I'll request review from you.

* Initial plan

* Add merge conflict indicator to PR review tracking

When a PR has merge conflicts (mergeable_state === 'dirty'), a red cross emoji (❌) is now displayed next to the PR title in the generated tracking table. This helps reviewers quickly identify PRs that need conflict resolution before they can be merged.

Co-authored-by: radical <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: radical <[email protected]>
@radical
Copy link
Copy Markdown
Member

radical commented Jan 13, 2026

@copilot In the workflow don't update the tracking issue if the workflow was run via a workflow_dispatch. Also, add this workflow to the list of check_for_changes step to skip CI.

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 13, 2026

@radical I've opened a new pull request, #13883, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 2 commits January 13, 2026 12:28
…to CI skip list (#13883)

* Initial plan

* Skip tracking issue update for manual workflow runs and skip CI for workflow changes

Co-authored-by: radical <[email protected]>

* Output markdown to console for manual workflow runs instead of skipping job

Co-authored-by: radical <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: radical <[email protected]>
@radical
Copy link
Copy Markdown
Member

radical commented Jan 13, 2026

@copilot #12346 has merge conflicts but the script still found "hasMergeConflict":false -
{"number":12346,"title":"Enable Urls to display using FluentIcon","author":"mcumming","url":"https://github.com/dotnet/aspire/pull/12346","authorUrl":"https://github.com/mcumming","updatedAt":"2025-10-24T16:39:32.000Z","isCommunityContribution":false,"hasMergeConflict":false}. #12574 also has merge conflicts as another example.

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 13, 2026

@radical I've opened a new pull request, #13884, to work on those changes. Once the pull request is ready, I'll request review from you.

* Initial plan

* Fix merge conflict detection by fetching individual PR details

Co-authored-by: radical <[email protected]>

* Improve merge conflict detection to handle all mergeable states

Co-authored-by: radical <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: radical <[email protected]>
@JamesNK JamesNK enabled auto-merge (squash) January 14, 2026 02:31
@JamesNK JamesNK merged commit 7e94f78 into main Jan 14, 2026
295 of 296 checks passed
@JamesNK JamesNK deleted the jamesnk/pr-tracking-action-wip branch January 14, 2026 02:40
@dotnet-policy-service dotnet-policy-service bot added this to the 13.2 milestone Jan 14, 2026
@github-actions github-actions bot locked and limited conversation to collaborators Feb 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-engineering-systems infrastructure helix infra engineering repo stuff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants