-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
KAFKA-17542: Use actions/labeler for automatic PR labeling - part 2 #17260
Conversation
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.
@TaiJuWu thanks for this patch. what about the plan of "tests" label?
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.
@TaiJuWu, thanks for following up with this patch!
Can we create this as a standalone bash script that lives in .github/scripts? I don't like having too much code directly in the workflow definition. This also makes it easier to test locally.
The script inputs (the SHAs to compare) can be env variables. If we need outputs, we can use the stdout "FOO=BAR" notation (see https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-output-parameter).
A few other considerations:
- Should we have other size labels? E.g., "tee-shirt" sizes: small, medium, large, xlarge
- If a PR's size changes after an update, we may need to remove an existing label
- Do we need to exclude any files from this diff sizing? I can't think of any...
.github/workflows/labeler.yml
Outdated
BASE_COMMIT="${{ github.event.pull_request.base.sha }}" | ||
HEAD_COMMIT="${{ github.event.pull_request.head.sha }}" | ||
|
||
summary=$(git diff --stat $BASE_COMMIT $HEAD_COMMIT | tail -n 1) |
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.
Not sure if it helps, but we can use the gh
CLI here.
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.
Thanks. It is very useful.
Sure.
Thanks for information!
I completely agree. To support multiple size labels, we can use PR-size-labeler. However, a limitation is that it requires us to set exactly five labels. |
Please note that while we can use marketplace actions, we must have them approved by ASF Infra team unless it's from GitHub or a verified developer. I think this is a simple enough action that we can roll our own, plus it gives us more flexibility for the labels (e.g., we can start with just "small") |
I don't find any changes as per this PR on mentioned test PR, am I missing something? |
Hi @apoorvmittal10 , thanks for review. By the way, we may use another tool help us to finish this target, you can refere here |
I file a jira for this https://issues.apache.org/jira/browse/INFRA-26158 |
@TaiJuWu I thought we were going to stick with your script for this? The PR-size-labeler is going to add a size label to every PR, which I'm not sure we want. I like the approach you started in this PR for just labeling "minor" PRs |
Oh, sorry for the misunderstanding. |
No worries 😄 . I think we can start with your script and update it as needed. So, to finish this up, we need to
|
Hi @mumrah , |
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.
Thanks for the updates, the script looks good.
I think we should considered a different label than minor
. After all, we may have very serious PRs which only have a few changes :). "Minor" can also convey importance or significance. I suggest we go with "small" which is more accurate.
Thanks for review and suggestion, updated! |
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.
LGTM, thanks @TaiJuWu!
@TaiJuWu thanks for this useful feature! |
|
||
pr_diff=$(gh pr diff $PR_NUM -R $GITHUB_REPOSITORY) | ||
|
||
insertions=$(printf "$pr_diff" | grep '^+' | wc -l) |
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.
It seems that printf tries to parse the content of pr_diff, which may lead to invalid formats (see #17338).
Perhaps we should avoid manually parsing the content and use gh pr view instead. For example:
pr_diff=$(gh pr view $PR_NUM -R $GITHUB_REPOSITORY --json additions,deletions)
insertions=$(echo "$pr_diff" | jq -r '.insertions')
deletions=$(echo "$pr_diff" | jq -r '.deletions')
total_changes=$((insertions + deletions))
@TaiJuWu WDYT? could you open a MINOR to fix it?
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.
Thanks for your remind, will update.
Reviewers: Chia-Ping Tsai <[email protected]>, David Arthur <[email protected]>
Jira: https://issues.apache.org/jira/browse/KAFKA-17542
test on: TaiJuWu#11
Committer Checklist (excluded from commit message)