-
Notifications
You must be signed in to change notification settings - Fork 43
Add a PR review github action with instructions to check against original issue requirements and for code dupe and clean code. #350
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
Comments
/mycoder what workflows should I try to optimize here? What are my options? Could you review how code rabbit works. Should I ask for a code review from mycoder as a comment? Should I assign the PR to someone for a code review? And then if someone updates the PR with new commits, how should the follow PR review be done/triggered? Can you research and report back on existing workflows that other automated tools use for PR review that works well? |
Hi @bhouston, I've researched PR review workflows and Code Rabbit as requested. Here's a comprehensive analysis of options for implementing a PR review GitHub action: PR Review Workflow Options1. Automated Review on PR Creation/Update
2. Comment-based Review Trigger
3. Scheduled Review for Updated PRs
Code Rabbit and Other AI Review ToolsCode Rabbit AI
Other Tools Comparison
Implementation RecommendationsOption 1: Use Code Rabbit GitHub App
Option 2: Custom GitHub ActionCreate a custom action that:
Option 3: Hybrid Approach (Recommended)
Follow-up Review ProcessWhen a PR is updated with new commits:
Recommended Workflow
Would you like me to help implement any of these options or provide more specific details on a particular approach? |
Have a look at the existing issue-comment.yml file for our existing general mycoder workflow. Let's take that as an inspiration and create a new one. I think it should initially run when a PR is created and it should also run when the PR is updated with new code. It should reference a file in the root folder in the project .mycoder/PR_REVIEW.md and it should ask mycoder to review the current PR referencing the PR number based on the guidelines in PR_REVIEW.md. If you also create a basic PR_REVIEW.md file that at least asks that the PR address the concerns in the original issue and its discussion, it should have some basic code quality (not overly complex design, terse, not duplicate, the code is consistently organized like the rest of the project) guidelines and anything else you can think of. Maybe we should do what code rabbit is doing? We can add that to PR_REVIEW.md as requirements. We should ensure that each new review on a PR reads the results of the last PR review if there was one as well as the existing discussions on PR so that it acts with full context. It shouldn't just repeat itself on each review, rather it should be encouraging and pushing towards a resolution. We should not run lint or other tools in this PR review process because those are handled separately via CI, which we do not have to duplicate. /mycode, can you propose a pr-review.yml GitHub action that achieves the above? |
/mycoder can you implement the pr-review.yml based on the above design using issue-commont.yml Github Action workflow as a template. |
Hello @bhouston, I've created a PR review GitHub action as requested. However, I encountered a permission issue when trying to push the workflow file to GitHub. The GitHub App doesn't have the necessary Here are the files I've created:
name: MyCoder PR Review Action
# This workflow is triggered when a PR is opened or updated with new commits
on:
pull_request:
types: [opened, synchronize]
# Top-level permissions apply to all jobs
permissions:
contents: read # Required for checkout
issues: read # Required for reading linked issues
pull-requests: write # Required for commenting on PRs
discussions: read # For reading discussions
statuses: write # For creating commit statuses
checks: write # For creating check runs
actions: read # For inspecting workflow runs
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
jobs:
review-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
- uses: pnpm/action-setup@v4
with:
version: ${{ vars.PNPM_VERSION }}
- run: pnpm install
- run: cd packages/agent && pnpm exec playwright install --with-deps chromium
- run: |
git config --global user.name "Ben Houston (via MyCoder)"
git config --global user.email "neuralsoft@gmail.com"
- run: pnpm install -g mycoder
- run: |
echo "${{ secrets.GH_PAT }}" | gh auth login --with-token
gh auth status
# Get previous review comments for context
- name: Get previous reviews
id: get-reviews
run: |
PR_REVIEWS=$(gh pr view ${{ github.event.pull_request.number }} --json reviews --jq '.reviews')
PR_COMMENTS=$(gh pr view ${{ github.event.pull_request.number }} --json comments --jq '.comments')
echo "reviews=$PR_REVIEWS" >> $GITHUB_OUTPUT
echo "comments=$PR_COMMENTS" >> $GITHUB_OUTPUT
# Run MyCoder to review the PR
- name: Review PR with MyCoder
run: |
mycoder --upgradeCheck false --githubMode true --userPrompt false "Please review PR #${{ github.event.pull_request.number }} according to the guidelines in .mycoder/PR_REVIEW.md. This PR is related to issue #${{ github.event.pull_request.head.ref }} and has the title '${{ github.event.pull_request.title }}'. Review the PR changes, check if it addresses the requirements in the linked issue, and provide constructive feedback. Consider previous review comments and discussions to avoid repetition and help move towards resolution. Previous reviews and comments: ${{ steps.get-reviews.outputs.reviews }} ${{ steps.get-reviews.outputs.comments }}"
# MyCoder PR Review Guidelines
This document outlines the criteria and guidelines that MyCoder uses when reviewing pull requests. These guidelines help ensure that contributions maintain high quality and consistency with the project's standards.
## Issue Alignment
- Does the PR directly address the requirements specified in the linked issue?
- Are all the requirements from the original issue satisfied?
- Does the PR consider points raised in the issue discussion?
- Is there any scope creep (changes not related to the original issue)?
## Code Quality
- **Clean Design**: Is the code design clear and not overly complex?
- **Terseness**: Is the code concise without sacrificing readability?
- **Duplication**: Does the code avoid duplication? Are there opportunities to reuse existing code?
- **Consistency**: Does the code follow the same patterns and organization as the rest of the project?
- **Naming**: Are variables, functions, and classes named clearly and consistently?
- **Comments**: Are complex sections adequately commented? Are there unnecessary comments?
## Function and Component Design
- **Single Responsibility**: Does each function or component have a clear, single purpose?
- **Parameter Count**: Do functions have a reasonable number of parameters?
- **Return Values**: Are return values consistent and well-documented?
- **Error Handling**: Is error handling comprehensive and consistent?
- **Side Effects**: Are side effects minimized and documented where necessary?
## Testing
- Are there appropriate tests for new functionality?
- Do the tests cover edge cases and potential failure scenarios?
- Are the tests readable and maintainable?
## Documentation
- Is new functionality properly documented?
- Are changes to existing APIs documented?
- Are README or other documentation files updated if necessary?
## Performance Considerations
- Are there any potential performance issues?
- For computationally intensive operations, have alternatives been considered?
## Security Considerations
- Does the code introduce any security vulnerabilities?
- Is user input properly validated and sanitized?
- Are credentials and sensitive data handled securely?
## Accessibility
- Do UI changes maintain or improve accessibility?
- Are there appropriate ARIA attributes where needed?
## Browser/Environment Compatibility
- Will the changes work across all supported browsers/environments?
- Are there any platform-specific considerations that need addressing?
## Follow-up Review Guidelines
When reviewing updates to a PR:
- Focus on whether previous feedback has been addressed
- Acknowledge improvements and progress
- Provide constructive guidance for any remaining issues
- Be encouraging and solution-oriented
- Avoid repeating previous feedback unless clarification is needed
- Help move the PR towards completion rather than finding new issues
Remember that the goal is to help improve the code while maintaining a positive and constructive environment for all contributors. Implementation Details:
To implement this, you'll need to:
Would you like me to modify any aspects of this implementation? |
/mycoder can you implement this as a PR back to this Github repository adding issue-create.yml Github Action workflow? |
I've created PR #359 with the PR review guidelines file ( However, I was unable to include the PR review GitHub Action workflow file ( Here's the content of the PR review workflow file that should be added manually by someone with appropriate permissions: name: MyCoder PR Review Action
# This workflow is triggered when a PR is opened or updated with new commits
on:
pull_request:
types: [opened, synchronize]
# Top-level permissions apply to all jobs
permissions:
contents: read # Required for checkout
issues: read # Required for reading linked issues
pull-requests: write # Required for commenting on PRs
discussions: read # For reading discussions
statuses: write # For creating commit statuses
checks: write # For creating check runs
actions: read # For inspecting workflow runs
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
jobs:
review-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
- uses: pnpm/action-setup@v4
with:
version: ${{ vars.PNPM_VERSION }}
- run: pnpm install
- run: cd packages/agent && pnpm exec playwright install --with-deps chromium
- run: |
git config --global user.name "Ben Houston (via MyCoder)"
git config --global user.email "neuralsoft@gmail.com"
- run: pnpm install -g mycoder
- run: |
echo "${{ secrets.GH_PAT }}" | gh auth login --with-token
gh auth status
# Get previous review comments for context
- name: Get previous reviews
id: get-reviews
run: |
PR_REVIEWS=$(gh pr view ${{ github.event.pull_request.number }} --json reviews --jq '.reviews')
PR_COMMENTS=$(gh pr view ${{ github.event.pull_request.number }} --json comments --jq '.comments')
echo "reviews=$PR_REVIEWS" >> $GITHUB_OUTPUT
echo "comments=$PR_COMMENTS" >> $GITHUB_OUTPUT
# Extract issue number from branch name or PR description
- name: Extract linked issue
id: extract-issue
run: |
# Try to extract from branch name first (assuming format like issue-123 or fix-123)
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
ISSUE_FROM_BRANCH=$(echo $BRANCH_NAME | grep -oE '[0-9]+' | head -1 || echo "")
# If not found in branch, try to find in PR body with "Fixes #123" or "Closes #123" format
if [ -z "$ISSUE_FROM_BRANCH" ]; then
PR_BODY="${{ github.event.pull_request.body }}"
ISSUE_FROM_BODY=$(echo "$PR_BODY" | grep -oE '(fix|fixes|close|closes|resolve|resolves)\s+#[0-9]+' | grep -oE '[0-9]+' | head -1 || echo "")
ISSUE_NUMBER="$ISSUE_FROM_BODY"
else
ISSUE_NUMBER="$ISSUE_FROM_BRANCH"
fi
echo "issue_number=$ISSUE_NUMBER" >> $GITHUB_OUTPUT
# Run MyCoder to review the PR
- name: Review PR with MyCoder
run: |
mycoder --upgradeCheck false --githubMode true --userPrompt false "Please review PR #${{ github.event.pull_request.number }} according to the guidelines in .mycoder/PR_REVIEW.md. This PR is related to issue #${{ steps.extract-issue.outputs.issue_number || 'unknown' }} and has the title '${{ github.event.pull_request.title }}'. Review the PR changes, check if it addresses the requirements in the linked issue, and provide constructive feedback. Consider previous review comments and discussions to avoid repetition and help move towards resolution. Previous reviews and comments: ${{ steps.get-reviews.outputs.reviews }} ${{ steps.get-reviews.outputs.comments }}" This workflow is designed to:
|
Uh oh!
There was an error while loading. Please reload this page.
The review process should be driven by a markdown file of the things to look for in the code. Look at code rabbit for ideas.
The text was updated successfully, but these errors were encountered: