Repository navigation
chore: add a script that lists open pull requests from low risk to critical #1209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sulimanbenhalim
wants to merge
3
commits into
dev-null-sh:production
Choose a base branch
from
sulimanbenhalim:chore/pr-queue
base: production
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+54
β0
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
92dce56
chore: add a script that lists open pull requests from low risk to crβ¦
sulimanbenhalim ba0ee47
fix: keep check suites from other apps apart so a failing one still cβ¦
sulimanbenhalim 50e3eac
docs: note that the queue script needs gh 2.48 or later and jq
sulimanbenhalim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| #!/usr/bin/env bash | ||
| # | ||
| # Lists open pull requests from low risk to critical, for a maintainer to run with their own gh sign-in. | ||
| # It never runs in a workflow, and it only reads: one GraphQL request per 50 open pull requests. | ||
| # | ||
| # Drafts, conflicts, failing CI and requested changes wait on their authors. The rest is split by | ||
| # what it touches, then each π on a description (not the author's) lifts it one size step. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| gh api graphql --paginate --slurp -f query=' | ||
| query ($endCursor: String) { | ||
| repository(owner: "dev-null-sh", name: "dev-null.sh") { | ||
| pullRequests(states: OPEN, first: 50, after: $endCursor) { | ||
| pageInfo { hasNextPage endCursor } | ||
| nodes { | ||
| number title createdAt isDraft additions deletions changedFiles mergeable reviewDecision | ||
| author { login } | ||
| files(first: 100) { nodes { path } } | ||
| reactions(content: THUMBS_UP, first: 100) { nodes { user { login } } } | ||
| commits(last: 1) { nodes { commit { checkSuites(last: 20) { nodes { conclusion app { slug } workflowRun { workflow { name } } } } } } } | ||
| } | ||
| } | ||
| } | ||
| }' | jq -r ' | ||
| [.[].data.repository.pullRequests.nodes[]] | ||
| | map( | ||
| (.additions + .deletions) as $lines | ||
| | [.files.nodes[].path] as $paths | ||
| | .size = ([10, 50, 250, 1000] | map(select($lines >= .)) | length) | ||
| | .votes = ([.reactions.nodes[].user.login // empty | select(endswith("[bot]") | not)] - [.author.login] | length) | ||
| | ([.commits.nodes[].commit.checkSuites.nodes[]] | group_by(.workflowRun.workflow.name // .app.slug) | map(last.conclusion)) as $suites | ||
| | .approval = any($suites[]; . == "ACTION_REQUIRED") | ||
| | .waiting = if .isDraft then "draft" | ||
| elif .mergeable == "CONFLICTING" then "merge conflicts" | ||
| elif any($suites[]; . == "FAILURE" or . == "TIMED_OUT") then "failing CI" | ||
| elif .reviewDecision == "CHANGES_REQUESTED" then "changes requested" | ||
| else null end | ||
| | .tier = if $lines >= 1000 or .changedFiles > 100 or any($paths[]; test("^(database/migrations|routes|bootstrap|config|patches|\\.github|app/Http/(Middleware|Requests))/|^app/Services/(SshSignatures|SignedRequests)\\.php$|^(composer\\.json|package\\.json|\\.npmrc|bunfig\\.toml|vet\\.json)$|\\.lock$")) then 2 | ||
| elif $lines < 250 and all($paths[]; test("^(resources/(js|css)|tests)/|\\.md$")) then 0 | ||
| else 1 end | ||
| ) | ||
| | (map(select(.waiting == null)) | sort_by(.tier, .size - .votes, .createdAt)) as $ready | ||
| | ( | ||
| ["π’ Low risk: only UI, docs or tests, under 250 lines", "π‘ Review: everything else", "π΄ Critical: data, routes, auth, config, CI or dependencies, or 1000+ lines or over 100 files"] as $titles | ||
| | range(0; 3) as $tier | ||
| | [$ready[] | select(.tier == $tier)] | ||
| | "\n\($titles[$tier]) (\(length))", | ||
| (.[] | " #\(.number) \(["XS", "S", "M", "L", "XL"][.size]) π\(.votes)\(if .approval then " needs CI approval" else "" end) \(.title)") | ||
| ), | ||
| (map(select(.waiting != null)) | "\nβΈ Waiting on the author (\(length))", (group_by(.waiting)[] | " \(.[0].waiting): \(map("#\(.number)") | join(" "))")) | ||
| ' | ||
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Paginate the
reactionsconnection before calculating votes..github/pr-queue.sh:20-31requests onlyreactions(content: THUMBS_UP, first: 100)and counts only.reactions.nodes. A reachable pull request with more than 100 reactions can therefore omit valid non-author, non-bot votes. Its.votesvalue is too low, so its.size - .votesranking key is too high and the pull request can appear lower in its risk group.Paginate the nested
reactionsconnection and combine all reaction pages before applying the existing author and bot exclusions.