Skip to content

Comments

Apply labels automatically at issue creation ,issue no.888#968

Merged
arkid15r merged 6 commits intoOWASP:mainfrom
srinjoy933:srinjoy933/issue#888
Mar 2, 2025
Merged

Apply labels automatically at issue creation ,issue no.888#968
arkid15r merged 6 commits intoOWASP:mainfrom
srinjoy933:srinjoy933/issue#888

Conversation

@srinjoy933
Copy link
Contributor

@srinjoy933 srinjoy933 commented Mar 1, 2025

Resolves #888

I made several updates to automate issue labeling and improve workflow efficiency. First, I modified labeler.yml to support automatic label assignment based on issue titles and descriptions, ensuring that issues are categorized correctly. Then, I updated the bug_report.md and feature_request.md files inside the .github/ISSUE_TEMPLATE/ folder. In bug_report.md, I added labels: ['bug'] so that all bug reports automatically receive the "bug" label, and I included a checkbox for contributors to indicate whether they will work on fixing the issue. Similarly, in feature_request.md, I added labels: ['enhancement'] to assign the "enhancement" label to new feature requests, along with a checkbox for contributors to confirm if they plan to implement the feature. Additionally, I created a new GitHub Actions workflow (auto-label.yml) inside .github/workflows/, which automatically applies labels to issues based on specific keywords found in the issue title and body. This workflow ensures that issues are categorized even if they are not created using predefined templates.

@srinjoy933 srinjoy933 requested a review from arkid15r as a code owner March 1, 2025 18:51
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 1, 2025

Summary by CodeRabbit

  • Documentation
    • Updated issue templates for bug reports and feature requests with default labels and clear checkbox options to improve guidance during submission.
  • New Features
    • Introduced an automated issue labeling system that categorizes new or edited issues based on their content.

Walkthrough

The pull request updates two GitHub issue templates and introduces a new workflow. The issue templates for bug reports and feature requests have their labels field changed from an empty string to an array containing specific labels (['bug'] for bug reports and ['enhancement'] for feature requests). Additionally, the format for indicating whether the reporter intends to work on the issue has been modified to a checklist format. A new GitHub Actions workflow has been added to automatically label issues based on the content of their titles and bodies.

Changes

Files Change Summary
.github/ISSUE_TEMPLATE/{bug_report.md,feature_request.md} Updated labels from an empty string to an array (['bug'] for bug reports, ['enhancement'] for feature requests); added a question about reporter intention with checklist options
.github/workflows/label-issues.yaml Added a new GitHub Actions workflow that analyzes issue titles and bodies for keywords and applies corresponding labels via the GitHub API

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6d521e9 and 13ca039.

📒 Files selected for processing (1)
  • .github/workflows/label-issues.yaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/label-issues.yaml

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added docs Improvements or additions to documentation ci labels Mar 1, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
.github/labeler.yml (1)

18-22: Remove trailing spaces.
A static analysis note indicates trailing whitespace on line 20. Removing these extra spaces will help ensure compliance with YAML linting rules.

.github/workflows/auto-label.yml (2)

11-11: Update GitHub Script Action Version.
Static analysis indicates that actions/github-script@v6 is outdated. Please consider updating to a more recent version (for example, v6.1.0 or later) to take advantage of improvements and security fixes.

🧰 Tools
🪛 actionlint (1.7.4)

11-11: the runner of "actions/github-script@v6" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


20-20: Remove trailing spaces.
Trailing whitespace is detected on this line. Removing it will improve the YAML formatting and prevent linting issues.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 20-20: trailing spaces

(trailing-spaces)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 126b0b1 and 727dc98.

📒 Files selected for processing (4)
  • .github/ISSUE_TEMPLATE/bug_report.md (2 hunks)
  • .github/ISSUE_TEMPLATE/feature_request.md (2 hunks)
  • .github/labeler.yml (2 hunks)
  • .github/workflows/auto-label.yml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/auto-label.yml

11-11: the runner of "actions/github-script@v6" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 YAMLlint (1.35.1)
.github/workflows/auto-label.yml

[error] 20-20: trailing spaces

(trailing-spaces)

🔇 Additional comments (9)
.github/labeler.yml (4)

1-9: Verify the renaming of the key to "bbackend".
The original key was likely "backend", and it has been intentionally renamed to "bbackend". Please confirm that this change is deliberate and that any downstream configurations or integrations referencing the previous key are updated accordingly.


83-86: New "bug" label configuration added.
The new section for bugs defines keywords for both the title and the body. These keywords appear reasonable for capturing bug-related issues. Please verify that these keywords fully cover your expected patterns.


87-90: New "enhancement" label configuration added.
The configuration for enhancements, with keywords in both title and body, should help in automatically labeling feature requests. Confirm that the lists are sufficiently comprehensive for your use cases.


91-93: New "question" label configuration added.
This section will help capture issues or queries that are phrased as questions. The keywords here are clear and support the intended categorization.

.github/ISSUE_TEMPLATE/feature_request.md (2)

5-5: Default label set to "enhancement".
Changing the labels field to ['enhancement'] ensures that feature requests are automatically categorized. This aligns well with the updated labeling strategy.


18-20: Added checkbox for implementation intention.
The new question and checkbox options ("Are you going to work on implementing this?") are a useful addition to prompt contributor engagement. This helps clarify if the reporter intends to take on the feature work.

.github/workflows/auto-label.yml (1)

13-36: Review the auto-labeling logic.
The script clearly defines a mapping of keywords to labels and iterates through both the issue title and body to apply these labels. This logic should effectively automate the labeling process as intended. Verify that the chosen keywords and the matching logic meet your project's categorization needs.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 20-20: trailing spaces

(trailing-spaces)

.github/ISSUE_TEMPLATE/bug_report.md (2)

6-6: Default bug label set to ['bug'].
Updating the labels field to ['bug'] ensures that all bug reports are automatically tagged with the correct label, enhancing issue management.


24-26: Added checklist for fix intent.
The reformatted question "Are you going to work on fixing this?" with checkboxes improves clarity regarding contributor involvement on bug fixes. This clear prompt can help streamline issue triaging.

Copy link
Collaborator

@arkid15r arkid15r 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 adding this

@srinjoy933 srinjoy933 requested a review from arkid15r March 1, 2025 21:50
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/auto-label.yml (1)

16-27: Improve Robustness by Handling Potential Null issue.body

The script directly calls toLowerCase() on issue.body, which may lead to a runtime error if issue.body is null. Consider initializing a variable for body with a null-check before transforming the text. This ensures robustness in cases where the issue body might not be provided.

-            const issue = context.payload.issue;
-            const keywords = {
-              "bug": ["error", "failure", "not working"],
-              "enhancement": ["add", "feature request", "improve"],
-              "question": ["clarification", "help", "how to"]
-            };
+            const issue = context.payload.issue;
+            const title = issue.title.toLowerCase();
+            const body = issue.body ? issue.body.toLowerCase() : "";
+            const keywords = {
+              "bug": ["error", "failure", "not working"],
+              "enhancement": ["add", "feature request", "improve"],
+              "question": ["clarification", "help", "how to"]
+            };
 
-              if (words.some(word => issue.title.toLowerCase().includes(word) || issue.body.toLowerCase().includes(word))) {
+              if (words.some(word => title.includes(word) || body.includes(word))) {
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 727dc98 and a193a57.

📒 Files selected for processing (3)
  • .github/ISSUE_TEMPLATE/bug_report.md (2 hunks)
  • .github/ISSUE_TEMPLATE/feature_request.md (2 hunks)
  • .github/workflows/auto-label.yml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • .github/ISSUE_TEMPLATE/feature_request.md
  • .github/ISSUE_TEMPLATE/bug_report.md
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/auto-label.yml

13-13: the runner of "actions/github-script@v6" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🔇 Additional comments (3)
.github/workflows/auto-label.yml (3)

1-7: Workflow Trigger Definition is Clear and Concise

The workflow triggers correctly on issue events (both "edited" and "opened"). This ensures that the labeling is applied both during issue creation and subsequent modifications.


8-12: Job and Step Configuration Looks Solid

The job setup under jobs: and the step configuration for applying labels are well-defined and readable. Using ubuntu-latest is appropriate for this action.


30-37: Label Addition Logic is Correct

The conditional check for non-empty labels and the subsequent API call to append labels to the issue are implemented properly. This ensures that only relevant labels are applied.

@arkid15r arkid15r enabled auto-merge March 2, 2025 02:19
arkid15r
arkid15r previously approved these changes Mar 2, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/label-issues.yaml (1)

16-26: Improve Null Safety for Issue Fields
To avoid potential runtime errors when calling toLowerCase(), consider assigning issue.title and issue.body to variables with fallback defaults (e.g., an empty string). This change will also reduce redundant function calls.

Suggested diff:

-            const issue = context.payload.issue;
-            const keywords = {
-              "bug": ["error", "failure", "not working"],
-              "enhancement": ["add", "feature request", "improve"],
-              "question": ["clarification", "help", "how to"]
-            };
+            const issue = context.payload.issue;
+            const issueTitle = issue.title ? issue.title.toLowerCase() : "";
+            const issueBody = issue.body ? issue.body.toLowerCase() : "";
+            const keywords = {
+              "bug": ["error", "failure", "not working"],
+              "enhancement": ["add", "feature request", "improve"],
+              "question": ["clarification", "help", "how to"]
+            };

Also, modify the condition on line 25 as follows:

-              if (words.some(word => issue.title.toLowerCase().includes(word) || issue.body.toLowerCase().includes(word))) {
+              if (words.some(word => issueTitle.includes(word) || issueBody.includes(word))) {
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a193a57 and 6d521e9.

📒 Files selected for processing (1)
  • .github/workflows/label-issues.yaml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/label-issues.yaml

13-13: the runner of "actions/github-script@v6" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🔇 Additional comments (1)
.github/workflows/label-issues.yaml (1)

29-37: Label Addition Logic Verification
The script correctly collects applicable labels and calls GitHub’s API to add these labels to the issue. This implementation meets the objective of auto-labeling issues based on their content.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 2, 2025

@arkid15r arkid15r added this pull request to the merge queue Mar 2, 2025
Merged via the queue into OWASP:main with commit 5ba7b39 Mar 2, 2025
18 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Mar 4, 2025
shdwcodr pushed a commit to shdwcodr/Nest that referenced this pull request Jun 5, 2025
* Apply labels aApply labels automatically at issue creation #888utomatically at issue creation, issue OWASP#888

* Update code

* Update code

* Update code

---------

Co-authored-by: Arkadii Yakovets <arkadii.yakovets@owasp.org>
Co-authored-by: Arkadii Yakovets <2201626+arkid15r@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci docs Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Apply labels automatically at issue creation

2 participants