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

Add Auto-Labeling for Issues using GitHub Actions #5136

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Vineet1101
Copy link
Contributor

This pr is to add automation in adding labels to issue in the p4c repo. I have used github actions to implement this
Here's a demo video

Screencast.from.2025-02-20.10-31-12.mp4

Signed-off-by: Vineet1101 <Vineetgoel692@gmail.com>
I, Vineet1101 <Vineetgoel692@gmail.com>, hereby add my Signed-off-by to this commit: 796accb

Signed-off-by: Vineet1101 <Vineetgoel692@gmail.com>
@Vineet1101
Copy link
Contributor Author

@fruffy @jafingerhut please review this pr

@fruffy fruffy added the infrastructure Topics related to code style and build and test infrastructure. label Feb 20, 2025

// Define keyword-label mapping
const labelMappings = {
"bug": "bug",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's use brackets here, eg [frontend]. Is this case insensitive? Also do not use the body. The title is good enough. Otherwise you will get many, many false positives with this approach.

Also, only use labels that make sense. For example, why would someone tag their issue [duplicate] or [question]?

There are some other ones which are useful.

[P4Testgen] -> p4tools tag.
[P4Smith] -> p4tools tag.
[P4tools] -> p4tools tag.

In general, try to take a look at how the labels are currently used for issues and try to reflect this mapping.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fruffy I don't get what exactly you mean by [frontend] like the actions should check for [bug] in the title instead of bug??
Yes it is case sensitive but I have updated the code so now it is case insensitive and I have also included more labels

Copy link
Collaborator

Choose a reason for hiding this comment

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

For example, this PR uses frontend and the label is core.
#5133

Because the frontend, midend, parser, etc are all part of the compiler core.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so if we apply [frontend] like this I think it will not work properly as many people will not mention [] while writing the title for their issue

Copy link
Collaborator

Choose a reason for hiding this comment

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

Well, we can use frontend or front end in the title, but we have to be careful about false positives. [Frontend] is rather safe.

Another example is this issue:

#5138

This issue can be tagged tofino and bug because it has a compiler bug label and tofino in the title.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about we apply regex to match exactly from the tittle. For false positive maybe we can use a priority list so that the one's with higher priority gets label and one more thing I would like to ask is I don't get your point with [Frontend] I mean while writing the title of a issue people will simple write frontend they will not enclose it in brackets.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

one more solution that I can think is using weighted keyword matching
const labelMappings = { "compiler-core": { keywords: ["frontend", "midend", "parser", "backend"], threshold: 1 }, "networking": { keywords: ["dpdk", "ebpf", "switching"], threshold: 1 }, };

in this if threshold crosses 1 the compiler-core will get applied if not then parser or whatever written in the title will get applied. We can apply strict checking using regex to avoid false positive.
What are your thoughts on this idea @fruffy

Copy link
Collaborator

Choose a reason for hiding this comment

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

mean while writing the title of a issue people will simple write frontend they will not enclose it in brackets.

A lot of developers actually do this. Especially once a keyword will automatically lead to labelling.

What are your thoughts on this idea @fruffy

Multiple labels are actually ok. I would take a look at the current labels we have and then decide how these should be assigned. Feel also free to ask on what these labels mean.

This could also be part of documentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok for now I will add brackets also and once you have checked and decided tell me I will make changes according to that. I think we should also mention somewhere this thing in docs or something that one should use [] to auto add labels

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, let's do that!

@Vineet1101 Vineet1101 requested a review from fruffy February 21, 2025 08:46
Signed-off-by: Vineet1101 <Vineetgoel692@gmail.com>
"[p4c]": "p4c",
"[bmv2]": "bmv2",
"[compiler]": "compiler",
"[test]": "testing",
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not a label.

"[feature]": "enhancement",
"[docs]": "documentation",
"[dpdk]": "dpdk",
"[p4c]": "p4c",
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is also not an existing label.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have removed that non existing labels

"[bug]": "bug",
"[error]": "bug",
"[fix]": "bug",
"[feature]": "enhancement",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could also be feat

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you mean in addition to [feature] we should also add [feat] and both will map to enhancement??

Copy link
Collaborator

Choose a reason for hiding this comment

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

For example, yes. You could have multiple variants.

"[Tofino]":"tofino",
"[p4tc]": "p4tc",
"[p4fmt]": "p4fmt",
"[core]":"core",
Copy link
Collaborator

Choose a reason for hiding this comment

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

This list is missing some more labels:

https://github.com/p4lang/p4c/issues/labels

Copy link
Contributor Author

@Vineet1101 Vineet1101 Feb 23, 2025

Choose a reason for hiding this comment

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

Screenshot from 2025-02-23 09-51-55
Screenshot from 2025-02-23 10-07-59
Screenshot from 2025-02-23 10-07-45

Do i need to add them in the auto label list????

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fruffy can you please clear this doubts so that I can make changes accordingly

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am currently traveling with limited access to internet. I will give this a thorough look later. run-xyz you do not need to map.

For the other labels you should take a look at the issues that are being tagged with them and see whether you can find a mapping that works.

@Vineet1101
Copy link
Contributor Author

@fruffy any suggestions you would like to give

I will give this a thorough look later. run-xyz you do not need to map.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure Topics related to code style and build and test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants