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

feat: workflow to add labels based on title and comment #1296

Merged

Conversation

Anmol-Baranwal
Copy link
Collaborator

@rupali-codes

Reference: https://github.com/hoho4190/issue-pr-labeler

Fixes Issue

Closes #1056

About Regex Expression

You can test it here: https://regex101.com/

I am taking two examples, which you must read so that you can properly review the PR.

  • /\bfeat\b/: This regular expression matches the exact word "feat" with word boundaries (\b). It will match strings that contain the word "feat" as a whole word, but not if it's part of another word (e.g., "defeat" or "feature").

  • /feature/i: This regular expression matches the word "feature" (case-insensitive) anywhere within a string. It will match strings that contain "feature" in any combination of uppercase and lowercase letters (e.g., "Feature", "FEATURE", "feature").

What you need to

  1. This is the only label goal: build that I have used since there was none. So, you can create them, or it will automatically be created during the analysis, but it will not be permanently stored in the labels of the repository.
- label: 'goal: build'
    regexs:
      - /build/i
    events: [pull_request]
    targets: [title]
  1. Double check the issue forms, and the labels in the repository, because it will be a huge mess if the label is wrong.

  2. I don't really know how comment would work. I have written a workflow that can read comments on a PR, but is this the description of the issue or PR? I am not sure, so please check at your end.

  - label: 'accessibility'
    regexs:
      - /\baccessibility\b/
      - /accessibility/i
    events: [issues, pull_request] # default
    targets: [title, comment] # default

Changes proposed

  • I have checked issue forms and corresponding labels to properly use the config workflow.
  • I have not made this workflow for analyzing issues, so let me know.
  • I didn't found anything related to adding multiple labels at once, so I have used 1 label for 1 set.
- label: 'chore'
    regexs:
      - /\blink\b/
      - /link/i
    events: [pull_request]
    targets: [title]
  - label: 'goal: new-link'
    regexs:
      - /\blink\b/
      - /link/i
    events: [pull_request]
    targets: [title]

Reference

There are two workflows that I found to implement this:

  1. https://github.com/TimonVS/pr-labeler-action
  2. https://github.com/hoho4190/issue-pr-labeler (used this due to recent release and no issues on the repository)

Note to reviewers

  • Let me know if you need anything.
  • Good luck :)

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Thank you, Anmol-Baranwal, for creating this pull request and contributing to LinksHub! 💗

The maintainers will review this Pull Request and provide feedback as soon as possible! 😇
We appreciate your patience and contribution, Keep up the great work! 😀

@vercel
Copy link

vercel bot commented Jul 14, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
linkshub ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 19, 2023 7:04am

k-deepak04
k-deepak04 previously approved these changes Jul 14, 2023
@Anmol-Baranwal
Copy link
Collaborator Author

@k-deepak04 Did you cross-check all the things properly.

@k-deepak04
Copy link
Contributor

@k-deepak04 Did you cross-check all the things properly.

yes, the code seems okay to me. so merged that i didn't test it though. can we test it without merging?
in one file you have written regex and labels to target the title and in otherworkflow you are using that to tackle the open pr's and add this automatically.

@Anmol-Baranwal
Copy link
Collaborator Author

@k-deepak04 Did you cross-check all the things properly.

yes, the code seems okay to me. so merged that i didn't test it though. can we test it without merging?
in one file you have written regex and labels to target the title and in otherworkflow you are using that to tackle the open pr's and add this automatically.

Yeah, we cannot test it without merging. But we can see if there are repositories that use this to understand the working.

Copy link
Collaborator

@CBID2 CBID2 left a comment

Choose a reason for hiding this comment

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

Looks ok to me. Let's see what the others think.

Copy link
Owner

@rupali-codes rupali-codes left a comment

Choose a reason for hiding this comment

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

looks nice to me, but i wanted to know, if the contributor adds wrong title and then correct that later, will also modify the labels?

@rupali-codes rupali-codes added goal: new-feature New feature or request quick-fix Shouldn't take much time to finish gssoc GirlScript Summer of Code participants level3 Making completely new feature labels Jul 19, 2023
@Anmol-Baranwal
Copy link
Collaborator Author

looks nice to me, but i wanted to know, if the contributor adds wrong title and then correct that later, will also modify the labels?

No, it will only check when the PR/Issue is opened or re-opened.

image

Suppose a contributor changes the title, then the workflow would need to check the comment to see if the title has been changed. However, checking every comment on every issue or PR would not be appropriate, especially if there are 100+ issues. This could lead to a warning from GitHub Actions.

@rupali-codes
Also, please let me know if we need to include issues as well. Currently, the events section only includes pull_request. I can make the necessary changes if we need to include issues, or we can remove this if it's not intended for issues.

issues:
    types:
      - opened
      - edited

Please confirm whether we should include this for issues or not.

@rupali-codes
Copy link
Owner

@Anmol-Baranwal alright, i guess we should keep it to PRs only, as we already adding labels to issues via templates,

@Anmol-Baranwal
Copy link
Collaborator Author

@Anmol-Baranwal alright, i guess we should keep it to PRs only, as we already adding labels to issues via templates,

Done.

@CBID2
Copy link
Collaborator

CBID2 commented Jul 30, 2023

Hey @rupali-codes. Are we going to merge this PR or??

@Anmol-Baranwal
Copy link
Collaborator Author

If you want to see an example, I have contributed the same workflow in another repository.

You can take a look at the recent PR here: https://github.com/Opentek-Org/opentek/pull/569

Based on the title
image

@rupali-codes
Copy link
Owner

@CBID2 lets merge it

@rupali-codes rupali-codes merged commit 04125b4 into rupali-codes:main Aug 1, 2023
2 checks passed
@Anmol-Baranwal Anmol-Baranwal deleted the hack_workflow_analyse_label branch August 1, 2023 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
goal: new-feature New feature or request gssoc GirlScript Summer of Code participants level3 Making completely new feature quick-fix Shouldn't take much time to finish
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Docs workflow for main codebase code and conditions
4 participants