-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Introduce /cmd label for labelling pull requests
#9915
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # Command Bot Documentation | ||
|
|
||
| The command bot allows contributors to perform self-service actions on PRs using comment commands. | ||
|
|
||
| ## Available Commands | ||
|
|
||
| ### Label Command (Self-service) | ||
|
|
||
| Add labels to your PR without requiring maintainer intervention: | ||
|
|
||
| ```bash | ||
| /cmd label T1-FRAME # Add single label | ||
| /cmd label T1-FRAME R0-no-crate-publish-required # Add multiple labels | ||
| /cmd label T1-FRAME A2-substantial D3-involved # Add multiple labels | ||
| ``` | ||
|
|
||
| **Available Labels:** | ||
| The bot dynamically fetches all current labels from the repository, ensuring it's always up-to-date. For label meanings and descriptions, see the [official label documentation](https://paritytech.github.io/labels/doc_polkadot-sdk.html). | ||
|
|
||
| **Features**: | ||
| - **Auto-Correction**: Automatically fixes high-confidence typos (e.g., `T1-FRAM` → `T1-FRAME`) | ||
| - **Case Fixing**: Handles case variations (e.g., `I2-Bug` → `I2-bug`) | ||
| - **Smart Suggestions**: For ambiguous inputs, provides multiple options to choose from | ||
|
|
||
| ### Other Commands | ||
|
|
||
| ```bash | ||
| /cmd fmt # Format code (cargo +nightly fmt and taplo) | ||
| /cmd prdoc # Generate PR documentation | ||
| /cmd bench # Run benchmarks | ||
| /cmd update-ui # Update UI tests | ||
| /cmd --help # Show help for all commands | ||
| ``` | ||
|
|
||
| ### Common Flags | ||
|
|
||
| - `--quiet`: Don't post start/end messages in PR | ||
| - `--clean`: Clean up previous bot comments | ||
| - `--image <image>`: Override docker image | ||
|
|
||
| ## How It Works | ||
|
|
||
| 1. **Command Detection**: The bot listens for comments starting with `/cmd` on PRs | ||
| 2. **Permission Check**: Verifies if the user is an organization member | ||
| 3. **Command Execution**: Runs the specified command in a containerized environment | ||
| 4. **Result Handling**: | ||
| - For label commands: Applies labels via GitHub API | ||
| - For other commands: Commits changes back to the PR branch | ||
| 5. **Feedback**: Posts success/failure messages in the PR | ||
|
|
||
| ## Security | ||
|
|
||
| - Organization member check prevents unauthorized usage | ||
| - Commands from non-members run using bot scripts from master branch | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| If a command fails: | ||
| 1. Check the GitHub Actions logs linked in the bot's comment | ||
| 2. Verify the command syntax matches the examples | ||
| 3. Ensure you have permission to perform the action | ||
| 4. For label commands, verify the label names are in the allowed list |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this if condition be OR instead of AND as it mentioned in the error message below?
"Only the PR author or organization members can modify labels"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you are not an org member AND not the pr author, you are authorized. Expressed differently, when you are an org member it resolves to false. If you are not an org member, it checks if you are the author.