8000 GH Actions label adjustment, fix permissions and enable auto quarter labels by igorpecovnik · Pull Request #8078 · armbian/build · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

GH Actions label adjustment, fix permissions and enable auto quarter labels #8078

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

Merged
merged 2 commits into from
Apr 12, 2025

Conversation

igorpecovnik
Copy link
Member
@igorpecovnik igorpecovnik commented Apr 12, 2025

Description

In title.

How Has This Been Tested?

  • Tested on fork

Check list

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

Copy link
Contributor
coderabbitai bot commented Apr 12, 2025

Walkthrough

The changes update the GitHub Actions workflow defined in the .github/workflows/pr-auto-labeler.yml file by adding the issues: write permission to three jobs: label-remove, label-category, and label-size. This update enables these jobs to manage labels on issues. A new job named label-by-date has been introduced, which also includes the issues: write permission and is designed to label pull requests based on their creation date. Additionally, the label- 8000 remove job has been restructured to check for the "Ready to merge" label before removal. The label-category and label-size jobs have been updated to include a checkout step and have standardized names. The triggering conditions for the existing jobs remain unchanged, as they still respond to the opened, reopened, and synchronize events associated with pull requests.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0947985 and a75e978.

📒 Files selected for processing (1)
  • .github/workflows/pr-auto-labeler.yml (2 hunks)
🔇 Additional comments (7)
.github/workflows/pr-auto-labeler.yml (7)

13-18: Global Permissions Update

The global permissions now include issues: write along with the existing settings. This update is essential for enabling label addition and removal across the workflow.


26-35: Label Remove: Checkout and Label Check

The checkout step and the subsequent use of the GitHub CLI to check for the "Ready to merge" label are well implemented. The command cleanly extracts the label information and correctly sets the output variable.


36-42: Label Remove: Conditional Removal Step

The conditional check (if: steps.check.outputs.has_label == 'true') combined with the use of PauMAVA/add-remove-label-action@v1.0.3 ensures that the "Ready to merge" label is removed only when present. The configuration is clear and consistent with the workflow’s objectives.


45-57: Label Category: Repository Checkout and Labeling

Including the checkout step before applying labels based on the .github/labeler.yml configuration is a good addition. The use of actions/labeler@v5 is appropriate for this purpose.


59-75: Label Size: Size Label Job Setup

The "Size Label" job is correctly set up using pascalgn/size-label-action@v0.5.5 with proper environment variable configuration and size thresholds. This segment aligns well with the intended automatic size labeling process.


82-107: Label by Date: Quarter Label Determination

The script to determine the quarter label is clear:

  • It extracts the month from PR_CREATED_AT using the date command and sed to remove leading zeros.
  • The conditional logic then assigns a label based on the month value (e.g., if the month is less than or equal to 2 or equals 12, it sets LABEL="02").

While the logic is clear, please verify that grouping December (month 12) with the condition for months ≤2 is intentional and correctly reflects the intended quarterly categorization.


108-113: Label by Date: Adding the Quarter Label

The final step uses PauMAVA/add-remove-label-action@v1.0.3 to apply the quarter label to the pull request. This mirrors the approach used in other jobs and is consistent with the overall design of the workflow.


🪧 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 plan to trigger planning for file edits and PR creation.
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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 size/small PR with less then 50 lines Needs review Seeking for review GitHub Actions GitHub Actions code labels Apr 12, 2025
@igorpecovnik igorpecovnik added 05 Milestone: Second quarter release and removed 05 Milestone: Second quarter release labels Apr 12, 2025
@igorpecovnik igorpecovnik reopened this Apr 12, 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 (1)
.github/workflows/pr-auto-labeler.yml (1)

66-106: New label-by-date job: Review and clarify quarter labeling logic.
A new job has been introduced to label pull requests based on their creation date. The job successfully extracts the month from the PR creation timestamp and assigns a label based on conditional checks. However, the conditional logic assigns labels using non-standard quarter markers (e.g., "02" for January, February, and December; "05" for March–May; "08" for June–August; and "11" for September–November).

  • Recommendation: If this mapping is intentional, consider adding an inline comment or documentation note explaining the rationale behind these specific label values. This will help future maintainers understand the grouping logic.
  • The use of the GitHub CLI for authentication and label management is appropriate.
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e14dcdc and ef05759.

📒 Files selected for processing (1)
  • .github/workflows/pr-auto-labeler.yml (4 hunks)
🔇 Additional comments (3)
.github/workflows/pr-auto-labeler.yml (3)

11-15: Added issues: write permission in label-remove job.
The addition of issues: write alongside the existing permissions is correct and enables the PauMAVA/add-remove-label-action to modify labels on issues.


27-32: Added issues: write permission in label-category job.
This change correctly complements the other permissions to allow label management with the add/remove label action.


43-48: Added issues: write permission in label-size job.
The updated permissions ensure that the size label action can properly add or remove labels, which aligns with the overall PR objective.

@github-actions github-actions bot added size/medium PR with more then 50 and less then 250 lines and removed size/small PR with less then 50 lines labels Apr 12, 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/workflows/pr-auto-labeler.yml (3)

21-37: Label Check and Removal Steps in "label-remove" Job
The step that checks for the "Ready to merge" label uses a combination of curl, jq, and grep to count label occurrences, then writes the result to the GitHub Actions output. This implementation is effective. Consider adding error handling for the API call (e.g., checking if the curl call fails or if the JSON parsing returns an error) to make the workflow more robust.


91-121: Implementation of Labeling Based on Creation Date
The steps under the "label-by-date" job perform the following actions:

  • Set environment variables for the GitHub token, PR creation date, issue number, and repository.
  • Log the PR creation date and extract the numeric month using date with sed—a reliable approach on Ubuntu runners.
  • Determine the label via a series of conditional checks:
    • If the month is less than or equal to 2 or equal to 12, the label is set to "02".
    • Else if the month is less than or equal to 5, the label becomes "05".
    • Else if the month is less than or equal to 8, it sets "08".
    • Otherwise, it uses "11".

Points to Verify & Consider:

  • Quarter Logic Verification: The grouping of December (12) with months 1 and 2 to yield label "02" may be unconventional given standard quarter divisions. Please verify that this grouping is intentional.
  • Readability Enhancement: For improved maintainability, consider refactoring the if-elif block into a case statement.
  • Error Handling: It might be beneficial to add error handling for the GitHub CLI commands (gh label create and gh issue edit) to gracefully handle failures.

101-114: Optional: Refactor Quarter Determination Logic Using a Case Statement
For improved clarity and maintainability, you might refactor the month-to-label mapping as follows:

-          if [ "$MONTH" -le 2 ] || [ "$MONTH" -eq 12 ]; then
-            LABEL="02"
-          elif [ "$MONTH" -le 5 ]; then
-            LABEL="05"
-          elif [ "$MONTH" -le 8 ]; then
-            LABEL="08"
-          else
-            LABEL="11"
-          fi
+          case $MONTH in
+            12|1|2)
+              LABEL="02"
+              ;;
+            3|4|5)
+              LABEL="05"
+              ;;
+            6|7|8)
+              LABEL="08"
+              ;;
+            9|10|11)
+              LABEL="11"
+              ;;
+            *)
+              echo "Unexpected month value: $MONTH" && exit 1
+              ;;
+          esac

This adjustment enhances readability while preserving the current logic.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ef05759 and 0947985.

📒 Files selected for processing (1)
  • .github/workflows/pr-auto-labeler.yml (4 hunks)
🔇 Additional comments (4)
.github/workflows/pr-auto-labeler.yml (4)

11-15: Update Permissions in "label-remove" Job
The addition of the issues: write permission in the "label-remove" job enables the PauMAVA/add-remove-label-action to modify labels on issues. This change correctly aligns with the PR objective.


44-47: Update Permissions in "label-category" Job
The update to include issues: write permission in the "label-category" job ensures that the associated action can manage labels correctly. This change is straightforward and meets the intended requirements.


60-63: Update Permissions in "label-size" Job
Adding the issues: write permission to the "label-size" job similarly empowers the action to add or remove labels as needed. This update is properly aligned with the overall PR objective.


82-88: Introduction of the "label-by-date" Job
The new "label-by-date" job is configured with the necessary permissions (contents: read and issues: write) and runs on ubuntu-latest. This addition meets the PR objective of enabling label modifications based on the pull request creation date.

@igorpecovnik igorpecovnik changed the title GH Actions: adjust permissions in order to change labels on PR GH Actions label adjustment, fix permissions and enable auto quarter labels Apr 12, 2025
@igorpecovnik igorpecovnik merged commit 1684d06 into main Apr 12, 2025
1 check passed
@igorpecovnik igorpecovnik deleted the labeller branch April 12, 2025 17:42
CelestialCrafter pushed a commit to CelestialCrafter/armbian-build that referenced this pull request May 11, 2025
…labels (armbian#8078)

* GH Actions: adjust permissions in order to change labels on PR
* Add label by date, check if "Read to merge is present", fix bugs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GitHub Actions GitHub Actions code Needs review Seeking for review size/medium PR with more then 50 and less then 250 lines
Development

Successfully merging this pull request may close these issues.

1 participant
0