workflows/reviewers: request owners and maintainers at once

Instead of requesting owners and maintainer separately, each with their
own limit of 10 review requests, we now run this together. This unties
the logic and allows easier refactoring. Also, it gives us a consistent
threshold of when not to request reviews anymore, which I set to 15.
Before, this could have been anything between 10 and 20, depending on
how the reviewers distributed over owners and maintainers.
This commit is contained in:
Wolfgang Walther 2025-11-01 10:52:38 +01:00
parent 9947f42e88
commit b2d1946eb2
No known key found for this signature in database
GPG key ID: B39893FA5F65CAE1
3 changed files with 7 additions and 10 deletions

View file

@ -69,15 +69,14 @@ jobs:
GH_TOKEN: ${{ steps.app-token.outputs.token }} GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: gh api /rate_limit | jq run: gh api /rate_limit | jq
- name: Requesting code owner reviews - name: Determining code owner reviews
if: steps.app-token.outputs.token if: steps.app-token.outputs.token
env: env:
GH_TOKEN: ${{ steps.app-token.outputs.token }} GH_TOKEN: ${{ steps.app-token.outputs.token }}
REPOSITORY: ${{ github.repository }} REPOSITORY: ${{ github.repository }}
NUMBER: ${{ github.event.number }} NUMBER: ${{ github.event.number }}
# Don't do anything on draft PRs run: |
DRY_MODE: ${{ github.event.pull_request.draft && '1' || '' }} result/bin/request-code-owner-reviews.sh "$REPOSITORY" "$NUMBER" ci/OWNERS > owners.txt
run: result/bin/request-code-owner-reviews.sh "$REPOSITORY" "$NUMBER" ci/OWNERS
- name: Log current API rate limits (app-token) - name: Log current API rate limits (app-token)
if: ${{ steps.app-token.outputs.token }} if: ${{ steps.app-token.outputs.token }}
@ -149,7 +148,7 @@ jobs:
GH_TOKEN: ${{ github.token }} GH_TOKEN: ${{ github.token }}
run: gh api /rate_limit | jq run: gh api /rate_limit | jq
- name: Requesting maintainer reviews - name: Requesting reviews
if: ${{ steps.app-token.outputs.token }} if: ${{ steps.app-token.outputs.token }}
env: env:
GH_TOKEN: ${{ github.token }} GH_TOKEN: ${{ github.token }}
@ -164,6 +163,7 @@ jobs:
# There appears to be no API to request reviews based on GitHub IDs # There appears to be no API to request reviews based on GitHub IDs
jq -r 'keys[]' comparison/maintainers.json \ jq -r 'keys[]' comparison/maintainers.json \
| while read -r id; do gh api /user/"$id" --jq .login; done \ | while read -r id; do gh api /user/"$id" --jq .login; done \
| cat owners.txt - \
| GH_TOKEN="$APP_GH_TOKEN" result/bin/request-reviewers.sh "$REPOSITORY" "$NUMBER" "$AUTHOR" | GH_TOKEN="$APP_GH_TOKEN" result/bin/request-reviewers.sh "$REPOSITORY" "$NUMBER" "$AUTHOR"
- name: Log current API rate limits (app-token) - name: Log current API rate limits (app-token)

View file

@ -31,8 +31,6 @@ prRepo=$(jq -r .head.repo.full_name <<< "$prInfo")
log "PR repo: $prRepo" log "PR repo: $prRepo"
prBranch=$(jq -r .head.ref <<< "$prInfo") prBranch=$(jq -r .head.ref <<< "$prInfo")
log "PR branch: $prBranch" log "PR branch: $prBranch"
prAuthor=$(jq -r .user.login <<< "$prInfo")
log "PR author: $prAuthor"
extraArgs=() extraArgs=()
if pwdRepo=$(git rev-parse --show-toplevel 2>/dev/null); then if pwdRepo=$(git rev-parse --show-toplevel 2>/dev/null); then
@ -56,5 +54,4 @@ git -C "$tmp/nixpkgs.git" fetch --no-tags fork "$prBranch"
headRef=$(git -C "$tmp/nixpkgs.git" rev-parse refs/remotes/fork/"$prBranch") headRef=$(git -C "$tmp/nixpkgs.git" rev-parse refs/remotes/fork/"$prBranch")
log "Requesting reviews from code owners" log "Requesting reviews from code owners"
"$SCRIPT_DIR"/get-code-owners.sh "$tmp/nixpkgs.git" "$ownersFile" "$baseBranch" "$headRef" | \ "$SCRIPT_DIR"/get-code-owners.sh "$tmp/nixpkgs.git" "$ownersFile" "$baseBranch" "$headRef"
"$SCRIPT_DIR"/request-reviewers.sh "$baseRepo" "$prNumber" "$prAuthor"

View file

@ -68,7 +68,7 @@ for user in "${!users[@]}"; do
fi fi
done done
if [[ "${#users[@]}" -gt 10 ]]; then if [[ "${#users[@]}" -gt 15 ]]; then
log "Too many reviewers (${!users[*]}), skipping review requests" log "Too many reviewers (${!users[*]}), skipping review requests"
exit 0 exit 0
fi fi