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 github action to assign milestone automatically #16779

Merged
merged 4 commits into from
Aug 5, 2024

Conversation

seanbudd
Copy link
Member

@seanbudd seanbudd commented Jul 1, 2024

Link to issue number:

None

Summary of the issue:

NV Access has a server side script to automatically assign milestones to closed issues and PRs. This script has been malfunctioning for some time meaning we are not tracking which release issues are closed in.

Description of user facing changes

Description of development approach

Used copilot to generate a github action to assign milestones.

Testing strategy

Manual testing

Known issues with pull request:

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

Summary by CodeRabbit

  • New Features
    • Introduced an automated workflow that assigns a default milestone to closed issues and pull requests for improved project management and organization.

@seanbudd seanbudd added this to the 2024.4 milestone Jul 1, 2024
@seanbudd seanbudd added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label Jul 2, 2024
@seanbudd seanbudd force-pushed the autoMilestoneAction branch from fd2cee3 to 9b3e6b0 Compare August 2, 2024 07:21
@seanbudd seanbudd marked this pull request as ready for review August 2, 2024 07:21
@seanbudd seanbudd requested a review from a team as a code owner August 2, 2024 07:21
@seanbudd seanbudd requested a review from michaelDCurran August 2, 2024 07:21
Copy link
Contributor

coderabbitai bot commented Aug 2, 2024

Walkthrough

This update introduces a new GitHub Actions workflow designed to automatically assign a default milestone to closed issues and pull requests. Triggered upon closure, the workflow checks if a milestone is already set and assigns a specified milestone if none is present, improving project tracking and organization.

Changes

Files Change Summary
.github/workflows/assign-milestone-on-close.yml Added a workflow to assign a default milestone to closed issues and pull requests when none is set.

Sequence Diagram(s)

sequenceDiagram
    participant GitHub
    participant Workflow
    participant API

    GitHub->>Workflow: Trigger on issue/pull request close
    Workflow->>API: Check if milestone is set
    API-->>Workflow: Milestone status
    alt Milestone not set
        Workflow->>API: Assign default milestone
    end
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

@seanbudd seanbudd requested review from SaschaCowley and gerald-hartig and removed request for michaelDCurran August 2, 2024 07:24
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

Comment on lines 3 to 5
env:
MILESTONE_ID: 1

Copy link
Contributor

@coderabbitai coderabbitai bot Aug 2, 2024

Choose a reason for hiding this comment

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

Parameterize or document the milestone ID.

The milestone ID is hardcoded to 1. This should either be parameterized to allow flexibility or documented to ensure it is updated appropriately during release cycles.

env:
  MILESTONE_ID: ${{ secrets.MILESTONE_ID }}

Ensure to add MILESTONE_ID to the repository secrets.

Copy link
Member Author

Choose a reason for hiding this comment

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

this should be an environment variable not a secret

Copy link
Contributor

Choose a reason for hiding this comment

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

@seanbudd, understood. You can set the MILESTONE_ID as an environment variable in the workflow file. Here's an updated snippet for the workflow:

name: Assign Milestone on Close

env:
  MILESTONE_ID: 1  # Update this value as needed for each release cycle

This ensures that the milestone ID can be easily updated during release cycles without requiring it to be a secret.


Learnings added
Learnt from: seanbudd
PR: nvaccess/nvda#16779
File: .github/workflows/assign-milestone-on-close.yml:0-0
Timestamp: 2024-08-02T07:28:45.462Z
Learning: For the GitHub Actions workflow in the NVDA repository, use environment variables for configuration values like `MILESTONE_ID` instead of secrets.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Copy link
Member Author

Choose a reason for hiding this comment

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

can you make this so it's an environment variable set through GitHub, not hard coded

Copy link
Contributor

Choose a reason for hiding this comment

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

"""

"""

@seanbudd, understood. You can set the MILESTONE_ID as an environment variable through GitHub's repository settings. Here’s how you can do it:

  1. Go to your repository on GitHub.
  2. Click on the "Settings" tab.
  3. In the left sidebar, click on "Environments".
  4. Create a new environment or select an existing one.
  5. Add the MILESTONE_ID environment variable with the appropriate value.

Then, in your workflow file, you can reference this environment variable as follows:

name: Assign Milestone on Close

env:
  MILESTONE_ID: ${{ vars.MILESTONE_ID }}

This ensures that the MILESTONE_ID is managed through GitHub's environment settings, providing flexibility and ease of updates.


Learnings added
Learnt from: seanbudd
PR: nvaccess/nvda#16779
File: .github/workflows/assign-milestone-on-close.yml:0-0
Timestamp: 2024-08-02T07:28:45.462Z
Learning: For the GitHub Actions workflow in the NVDA repository, use environment variables for configuration values like `MILESTONE_ID` instead of secrets and set them through GitHub's environment settings for better management.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


Learnings used
Learnt from: seanbudd
PR: nvaccess/nvda#16779
File: .github/workflows/assign-milestone-on-close.yml:0-0
Timestamp: 2024-08-02T07:28:45.632Z
Learning: For the GitHub Actions workflow in the NVDA repository, use environment variables for configuration values like `MILESTONE_ID` instead of secrets.

Copy link
Member

@SaschaCowley SaschaCowley left a comment

Choose a reason for hiding this comment

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

This looks reasonable to me, though I've never worked on GitHub scripting before, so I can't be confident.

@XLTechie
Copy link
Collaborator

XLTechie commented Aug 2, 2024 via email

@seanbudd
Copy link
Member Author

seanbudd commented Aug 4, 2024

@XLTechie - I don't think so, no. We want to update this manually when we update build_version and start the new release cycle. I don't envision a simple programmatic way to determine if the PR we are merging is starting a new release cycle.

@seanbudd seanbudd merged commit a8d39d0 into master Aug 5, 2024
4 checks passed
@seanbudd seanbudd deleted the autoMilestoneAction branch August 5, 2024 01:12
seanbudd added a commit that referenced this pull request Aug 8, 2024
…#16974)

Fixup #16779

Summary of the issue:
The GitHub actions to assign milestones to closed issues and PRs is failing for community PRs.
This is because the action is looking in the forks repository for the milestone ID environment variable.

Description of user facing changes
Fixes assigning milestones to community contributions

Description of development approach
using the pull_request_target event rather than pull_request, uses the target (i.e. this) repositories environment variables.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants