Skip to content

feat: add AI code review with GitHub Copilot #5

feat: add AI code review with GitHub Copilot

feat: add AI code review with GitHub Copilot #5

name: 🎨 Coding Standards Check
on:
pull_request:
types: [opened, synchronize]
push:
branches: [main, master]
permissions:
contents: read
pull-requests: write
checks: write
jobs:
coding-standards:
name: πŸ” Style & Standards
runs-on: ubuntu-latest
steps:
- name: πŸ“₯ Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: πŸ’Ž Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3.5'
bundler-cache: true
- name: 🎨 RuboCop Analysis
uses: reviewdog/action-rubocop@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
rubocop_version: gemfile
rubocop_extensions: rubocop-rspec:gemfile rubocop-performance:gemfile rubocop-factory_bot:gemfile
reporter: github-pr-review
fail_on_error: false
filter_mode: added
rubocop_flags: '--display-cop-names --format github'
- name: πŸ“Š Generate Standards Report
if: github.event_name == 'pull_request'
run: |
echo "## 🎨 Coding Standards Analysis" > standards-report.md
echo "" >> standards-report.md
# Run RuboCop and capture results
if bundle exec rubocop --format json --out rubocop-results.json; then
echo "βœ… **All coding standards checks passed!**" >> standards-report.md
echo "" >> standards-report.md
echo "No RuboCop offenses found in this PR." >> standards-report.md
else
# Parse JSON results for summary
total_files=$(jq '.summary.target_file_count' rubocop-results.json 2>/dev/null || echo "unknown")
offense_count=$(jq '.summary.offense_count' rubocop-results.json 2>/dev/null || echo "unknown")
echo "⚠️ **Found $offense_count coding standard violations across $total_files files**" >> standards-report.md
echo "" >> standards-report.md
echo "### Most Common Issues:" >> standards-report.md
# Get top cop violations
jq -r '.files[].offenses[].cop_name' rubocop-results.json 2>/dev/null | sort | uniq -c | sort -nr | head -5 | while read count cop; do
echo "- **$cop**: $count occurrences" >> standards-report.md
done
echo "" >> standards-report.md
echo "πŸ’‘ **Quick Fix Tips:**" >> standards-report.md
echo "- Run \`bundle exec rubocop --auto-correct\` to fix auto-correctable issues" >> standards-report.md
echo "- Check individual file comments above for specific violations" >> standards-report.md
fi
echo "" >> standards-report.md
echo "---" >> standards-report.md
echo "_Standards enforced by [RuboCop](https://rubocop.org/) β€’ View [our style guide](.rubocop.yml)_" >> standards-report.md
- name: πŸ’¬ Update PR Comment
if: github.event_name == 'pull_request'
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body-path: standards-report.md
edit-mode: replace
comment-author: 'github-actions[bot]'
body-includes: '🎨 Coding Standards Analysis'