Skip to content
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

Merged
merged 11 commits into from
Oct 4, 2024

Conversation

TaiJuWu
Copy link
Contributor

@TaiJuWu TaiJuWu commented Sep 24, 2024

Jira: https://issues.apache.org/jira/browse/KAFKA-17542
test on: TaiJuWu#11

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@github-actions github-actions bot added the build Gradle build or GitHub Actions label Sep 24, 2024
@TaiJuWu TaiJuWu marked this pull request as ready for review September 24, 2024 09:04
Copy link
Member

@chia7712 chia7712 left a 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?

.github/workflows/labeler.yml Outdated Show resolved Hide resolved
Copy link
Member

@mumrah mumrah left a 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:

  1. Should we have other size labels? E.g., "tee-shirt" sizes: small, medium, large, xlarge
  2. If a PR's size changes after an update, we may need to remove an existing label
  3. Do we need to exclude any files from this diff sizing? I can't think of any...

Comment on lines 38 to 41
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)
Copy link
Member

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.

https://cli.github.com/manual/gh_pr_diff

Copy link
Contributor Author

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.

@TaiJuWu
Copy link
Contributor Author

TaiJuWu commented Sep 24, 2024

@TaiJuWu thanks for this patch. what about the plan of "tests" label?

Hi @chia7712 , the test label are supported in last PR here
I think it meets your requirement.

@TaiJuWu
Copy link
Contributor Author

TaiJuWu commented Sep 24, 2024

@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.

Sure.

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).

Thanks for information!

A few other considerations:

  1. Should we have other size labels? E.g., "tee-shirt" sizes: small, medium, large, xlarge
  2. If a PR's size changes after an update, we may need to remove an existing label
  3. Do we need to exclude any files from this diff sizing? I can't think of any...

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.

@mumrah
Copy link
Member

mumrah commented Sep 25, 2024

To support multiple size labels, we can use PR-size-labeler

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")

@apoorvmittal10
Copy link
Collaborator

test on: TaiJuWu#10

I don't find any changes as per this PR on mentioned test PR, am I missing something?

@TaiJuWu
Copy link
Contributor Author

TaiJuWu commented Sep 26, 2024

test on: TaiJuWu#10

I don't find any changes as per this PR on mentioned test PR, am I missing something?

Hi @apoorvmittal10 , thanks for review.
This tes PR only shows the action can label mirror automatically as below.
image

By the way, we may use another tool help us to finish this target, you can refere here

@TaiJuWu
Copy link
Contributor Author

TaiJuWu commented Sep 27, 2024

To support multiple size labels, we can use PR-size-labeler

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 file a jira for this https://issues.apache.org/jira/browse/INFRA-26158

@mumrah
Copy link
Member

mumrah commented Sep 27, 2024

@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

@TaiJuWu
Copy link
Contributor Author

TaiJuWu commented Sep 27, 2024

@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.
If we only need a mirror label, we will have to write our own script, as the PR-size-labeler cannot be used in this case.
I'm also not entirely sure which solution is the best for us. We can start with just the mirror and consider using the PR-size-labeler in the future if necessary.

@mumrah
Copy link
Member

mumrah commented Sep 28, 2024

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

  1. Move the bash into a script
  2. Change the label name to minor (not mirror)
  3. Address @chia7712's question about the "test" label. If this is too complex we can create a new JIRA for it and work on it later

@TaiJuWu TaiJuWu marked this pull request as draft September 30, 2024 04:26
@TaiJuWu
Copy link
Contributor Author

TaiJuWu commented Sep 30, 2024

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

  1. Move the bash into a script
  2. Change the label name to minor (not mirror)
  3. Address @chia7712's question about the "test" label. If this is too complex we can create a new JIRA for it and work on it later

Hi @mumrah ,
[1] and [2] are finished. I will check [3] with @chia7712 to ensure that the current test label is functioning properly.

@TaiJuWu TaiJuWu marked this pull request as ready for review September 30, 2024 05:59
Copy link
Member

@mumrah mumrah left a 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.

@TaiJuWu
Copy link
Contributor Author

TaiJuWu commented Sep 30, 2024

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!

Copy link
Member

@mumrah mumrah left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @TaiJuWu!

@mumrah mumrah merged commit 529095b into apache:trunk Oct 4, 2024
2 checks passed
@chia7712
Copy link
Member

chia7712 commented Oct 4, 2024

@TaiJuWu thanks for this useful feature!

@TaiJuWu TaiJuWu deleted the labeler branch October 4, 2024 21:56

pr_diff=$(gh pr diff $PR_NUM -R $GITHUB_REPOSITORY)

insertions=$(printf "$pr_diff" | grep '^+' | wc -l)
Copy link
Member

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?

Copy link
Contributor Author

@TaiJuWu TaiJuWu Oct 6, 2024

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.

tedyu pushed a commit to tedyu/kafka that referenced this pull request Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Gradle build or GitHub Actions ci-approved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants