-
-
Notifications
You must be signed in to change notification settings - Fork 208
ci: review request maintainers #1053
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
base: master
Are you sure you want to change the base?
Conversation
1a83bd1
to
723b7b1
Compare
- id: get-maintainers | ||
# yamllint disable rule:line-length | ||
run: | | ||
existing_reviewers=$(curl -s "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/requested_reviewers") | ||
to_ping="" | ||
|
||
for file in $(jq -r '.[]' <<<"${{ steps.changed-files.outputs.files }}"); do | ||
for gh_id in ${jq -r '.[$file][]' result/gh_ids.json}; do | ||
if [ $gh_id == "${{ github.event.pull_request.user.login }}" || $gh_id == $(echo "$existing_reviewers" | jq -r ".users[].login") ]; then | ||
continue | ||
fi | ||
to_ping+="$gh_id," | ||
done | ||
done | ||
|
||
echo "::set-output name=to-ping::$to_ping" | ||
# yamllint enable rule:line-length |
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.
To reduce needless maintainer pings, certain scenarios should be conservatively filtered out. For example, when a PR touches many modules, their module maintainers should not be pinged because the PR might be a simple refactor. The safest criteria is when a PR touches only a single module.
Consider taking inspiration from the heuristics I implemented in #749.
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.
Alternatively, put a maximum limit on the number of maintainers, so that we still allow cases where all the modules of a particular maintainer were changed.
When this is complete we can also remove the "Maintainer CC" section from the pull request template |
723b7b1
to
9331f7d
Compare
anyone know why this error is happening?
|
9331f7d
to
c36cba3
Compare
runs-on: ubuntu-24.04 | ||
if: github.repository_owner == 'danth' | ||
steps: | ||
- uses: actions/[email protected] |
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.
Related: #1074
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.
I don't believe that's an issue when it's pull_request
, only with pull_request_target
. I should probably change it to pull_request_target
tho.
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.
Note that pull_request_target
gets some extra permissions on the token, which can be risky. See the warning here.
53a468b
to
94ebde1
Compare
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.
To avoid string injections, we should use environment variables:
env:
GH_REPO: ${{ github.repository }}
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
PR_NUMBER: ${{ github.event.pull_request.number }}
The Bash code could be polished to something like the following partially (not on GitHub) tested:
MAX_MAINTAINERS=5
existing_reviewers="$(
curl \
--silent \
"https://api.github.com/repos/$GH_REPO/pulls/$PR_NUMBER/requested_reviewers" |
jq --raw-output [.users[].login]
)"
to_ping=()
jq --raw-output '.[]' <<<"$CHANGED_FILES" | while read -r file; do
jq --arg file "$file" --raw-output '.[$file][]' result/gh_ids.json |
while read -r gh_id;
do
# Do not request the original author or already requested reviewers.
if [[ "$gh_id" == "$PR_AUTHOR" || "$existing_reviewers" =~ $gh_id ]]; then
continue
fi
to_ping+=("$gh_id")
done
done
if ((${#to_ping[@]} > 0 && ${#to_ping[@]} <= MAX_MAINTAINERS)); then
printf '%s\n' "::set-output name=to-ping::$(printf '%s,' "${to_ping[@]}")"
fi
The current "$existing_reviewers" =~ $gh_id
check is fragile and should be replaced with a jq
command.
Co-authored-by: NAHO <[email protected]>
94ebde1
to
377c4e2
Compare
very janky and probably doesn't work