-
Notifications
You must be signed in to change notification settings - Fork 376
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
Implement GitHub PR Issue Checker Workflow #2336
Conversation
@smog-root is attempting to deploy a commit to the Vivek Prajapati's projects Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughA new GitHub Actions workflow file named Changes
Assessment against linked issues
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 3
🧹 Outside diff range and nitpick comments (1)
.github/workflows/pr-checker.yml (1)
1-5
: Remove unnecessary comment and LGTM for the rest.The workflow name and trigger events are well-defined and appropriate for the task. However, I suggest removing the comment on line 2 as it's not a standard practice in workflow files and doesn't add value to the configuration.
Apply this diff to remove the unnecessary comment:
name: PR Issue Checker - # Created my @smog-root. on: pull_request: types: [opened, edited]
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- .github/workflows/pr-checker.yml (1 hunks)
🧰 Additional context used
🪛 actionlint
.github/workflows/pr-checker.yml
13-13: the runner of "actions/checkout@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
17-17: "github.event.pull_request.body" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions for more details
(expression)
- name: Check PR Description | ||
id: check_pr_description | ||
run: | | ||
PR_DESCRIPTION="${{ github.event.pull_request.body }}" | ||
if [[ -z "$PR_DESCRIPTION" ]]; then | ||
echo "PR description is missing." | ||
exit 1 | ||
fi | ||
|
||
if [[ ! "$PR_DESCRIPTION" =~ Fixes\ #[0-9]+ ]]; then | ||
echo "The PR description should include 'Fixes #<issue-number>' if not addressing any issue." | ||
echo "##[error]Fixes #NEW must be included in the description." | ||
exit 1 | ||
fi | ||
|
||
echo "PR description is valid." |
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.
🛠️ Refactor suggestion
Improve security and flexibility of PR description check.
The PR description check logic is generally good, but there are some security and flexibility improvements to be made:
- Avoid using
github.event.pull_request.body
directly in the inline script for security reasons. - Make the issue reference check more flexible to account for variations like "Closes" or multiple issue references.
- Consider adding a check for the "Fixes #NEW" case mentioned in the PR objectives.
Here's an improved version of the step:
- name: Check PR Description
env:
PR_BODY: ${{ github.event.pull_request.body }}
run: |
if [[ -z "$PR_BODY" ]]; then
echo "PR description is missing."
exit 1
fi
if ! grep -qE "(Fixes|Closes) #([0-9]+|NEW)( *, *#([0-9]+|NEW))*" <<< "$PR_BODY"; then
echo "The PR description should include 'Fixes #<issue-number>' or 'Fixes #NEW'."
echo "##[error]Invalid issue reference format in the description."
exit 1
fi
echo "PR description is valid."
This version:
- Uses an environment variable to pass the PR body, improving security.
- Allows for "Fixes" or "Closes" keywords.
- Supports multiple issue references.
- Includes the "Fixes #NEW" case.
🧰 Tools
🪛 actionlint
17-17: "github.event.pull_request.body" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions for more details
(expression)
- name: Output result | ||
run: echo "All checks passed." |
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.
🛠️ Refactor suggestion
Add label reminder and consider removing redundant output.
The current output step is redundant as the workflow will fail if any previous step fails. Additionally, it doesn't include the reminder about labels mentioned in the PR objectives.
Consider replacing this step with a more useful reminder about labels:
- name: Reminder about labels
run: |
echo "PR checks passed successfully."
echo "Reminder: Please ensure you've added all labels associated with the linked issue to this pull request."
This step provides value by reminding the PR author about the labels while still indicating that all checks have passed.
jobs: | ||
check_pr_description: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 |
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.
Update the checkout action to the latest version.
The job definition and runner selection look good. However, the actions/checkout
action is using an outdated version.
Update the checkout action to the latest version by applying this diff:
steps:
- name: Checkout code
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
This will ensure you're using the most up-to-date and secure version of the action.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
jobs: | |
check_pr_description: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
jobs: | |
check_pr_description: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 |
🧰 Tools
🪛 actionlint
13-13: the runner of "actions/checkout@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Fixes #2309
Usage:
When a pull request is created or edited, the workflow automatically triggers.
The workflow checks for:
Fixes #<issue-number>
orFixes #NEW
).Note: Kindly add all the labels added to the issue, to this PR!
Summary by CodeRabbit