Skip to content

Commit cda1cc1

Browse files
Copilotfermga
andcommitted
Add automated code review workflow to run before commits
Co-authored-by: fermga <203334638+fermga@users.noreply.github.com>
1 parent 8656458 commit cda1cc1

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

.github/workflows/code-review.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Automated Code Review
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
types: [opened, synchronize, reopened]
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
permissions:
13+
contents: read
14+
pull-requests: write
15+
16+
jobs:
17+
code-review:
18+
name: Run automated code review
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Check out repository
22+
uses: actions/checkout@v5
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Set up Python
27+
uses: actions/setup-python@v6
28+
with:
29+
python-version: '3.11'
30+
cache: pip
31+
32+
- name: Install dependencies
33+
run: |
34+
python -m pip install --upgrade pip
35+
python -m pip install -e .[dev-minimal]
36+
37+
- name: Run code review
38+
id: review
39+
continue-on-error: true
40+
run: |
41+
# Note: This is a placeholder for the actual code review process
42+
# In practice, this would call a code review service or tool
43+
echo "Running automated code review..."
44+
echo "Checking code quality, style, and best practices..."
45+
46+
# Run linters and static analysis
47+
EXIT_CODE=0
48+
python -m black --check src/ tests/ 2>&1 && echo "✅ Black formatting passed" || { echo "::warning::Black formatting issues found"; EXIT_CODE=1; }
49+
python -m mypy src/ 2>&1 && echo "✅ Type checking passed" || { echo "::warning::Type checking issues found"; EXIT_CODE=1; }
50+
51+
echo "Code review completed"
52+
exit $EXIT_CODE
53+
54+
- name: Comment on PR
55+
if: always()
56+
uses: actions/github-script@v7
57+
with:
58+
script: |
59+
const reviewStatus = '${{ steps.review.outcome }}' === 'success' ? '✅ Passed' : '⚠️ Issues found';
60+
const comment = `## Automated Code Review\n\n${reviewStatus}\n\nPlease review the workflow logs for details.`;
61+
62+
github.rest.issues.createComment({
63+
owner: context.repo.owner,
64+
repo: context.repo.repo,
65+
issue_number: context.issue.number,
66+
body: comment
67+
});

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ repos:
1717
files: ^src/tnfr/
1818
- repo: local
1919
hooks:
20+
- id: code-review-check
21+
name: Code review quality check
22+
entry: bash -c 'echo "⚠️ Remember to run code review before committing significant changes" && echo " Run: make lint test" && exit 0'
23+
language: system
24+
pass_filenames: false
25+
stages: [commit]
2026
- id: check-stubs
2127
name: Check .pyi stub files
2228
entry: python scripts/generate_stubs.py --check

0 commit comments

Comments
 (0)