Skip to content

Commit 93e6299

Browse files
committed
Sync auto-tag-based-review.yml from .github repo
1 parent 611279d commit 93e6299

File tree

1 file changed

+313
-0
lines changed

1 file changed

+313
-0
lines changed
Lines changed: 313 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,313 @@
1+
name: "Tag-based Code Review"
2+
3+
on:
4+
push:
5+
tags:
6+
- 'e2eweekly'
7+
- 'weeklyreview'
8+
- 'e2e-*'
9+
- 'review-*'
10+
workflow_dispatch:
11+
inputs:
12+
review_type:
13+
description: 'Type of review to perform'
14+
required: true
15+
default: 'e2e'
16+
type: choice
17+
options:
18+
- e2e
19+
- weekly
20+
- full
21+
ai_model:
22+
description: 'AI Model to use for review'
23+
required: false
24+
default: 'gpt-5.1-codex'
25+
type: choice
26+
options:
27+
- gpt-5.1-codex
28+
- gpt-5.1
29+
- gpt-5
30+
- amazonq
31+
- codex
32+
- gemini
33+
34+
permissions:
35+
contents: write
36+
pull-requests: write
37+
issues: write
38+
actions: read
39+
40+
jobs:
41+
tag-based-review:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Checkout code
45+
uses: actions/checkout@main
46+
with:
47+
fetch-depth: 0
48+
49+
- name: Determine Review Type
50+
id: review-type
51+
run: |
52+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
53+
echo "type=${{ inputs.review_type }}" >> $GITHUB_OUTPUT
54+
echo "model=${{ inputs.ai_model }}" >> $GITHUB_OUTPUT
55+
elif [[ "${{ github.ref }}" == *"e2eweekly"* ]] || [[ "${{ github.ref }}" == *"e2e"* ]]; then
56+
echo "type=e2e" >> $GITHUB_OUTPUT
57+
echo "model=gpt-5.1-codex" >> $GITHUB_OUTPUT
58+
elif [[ "${{ github.ref }}" == *"weeklyreview"* ]] || [[ "${{ github.ref }}" == *"review"* ]]; then
59+
echo "type=weekly" >> $GITHUB_OUTPUT
60+
echo "model=gpt-5.1" >> $GITHUB_OUTPUT
61+
else
62+
echo "type=full" >> $GITHUB_OUTPUT
63+
echo "model=gpt-5.1-codex" >> $GITHUB_OUTPUT
64+
fi
65+
66+
- name: Setup Node.js
67+
uses: actions/setup-node@main
68+
with:
69+
node-version: '20'
70+
continue-on-error: true
71+
72+
- name: Setup Python
73+
uses: actions/setup-python@main
74+
with:
75+
python-version: '3.11'
76+
continue-on-error: true
77+
78+
- name: E2E Review with Selected Model
79+
if: steps.review-type.outputs.type == 'e2e'
80+
uses: austenstone/copilot-cli-action@v2
81+
with:
82+
copilot-token: ${{ secrets.COPILOT_TOKEN }}
83+
prompt: |
84+
Perform a comprehensive end-to-end code review using ${{ steps.review-type.outputs.model }}:
85+
86+
**E2E Testing Focus:**
87+
1. Integration Points
88+
- Review all API endpoints and their integrations
89+
- Check database connections and queries
90+
- Verify external service integrations
91+
- Test authentication and authorization flows
92+
93+
2. User Flows
94+
- Identify critical user journeys
95+
- Check for broken workflows
96+
- Verify error handling in user paths
97+
- Test edge cases in user interactions
98+
99+
3. Data Flow Analysis
100+
- Trace data from input to output
101+
- Check data validation at each step
102+
- Verify data transformations
103+
- Identify potential data loss points
104+
105+
4. Performance & Reliability
106+
- Identify performance bottlenecks in E2E scenarios
107+
- Check for race conditions
108+
- Verify timeout handling
109+
- Review retry mechanisms
110+
111+
5. Security in E2E Context
112+
- Verify secure data transmission
113+
- Check authentication at each boundary
114+
- Review authorization for sensitive operations
115+
- Identify injection vulnerabilities
116+
117+
Provide specific findings with file names, line numbers, and actionable recommendations.
118+
continue-on-error: true
119+
120+
- name: Weekly Review with Selected Model
121+
if: steps.review-type.outputs.type == 'weekly'
122+
uses: austenstone/copilot-cli-action@v2
123+
with:
124+
copilot-token: ${{ secrets.COPILOT_TOKEN }}
125+
prompt: |
126+
Perform a comprehensive weekly code review using ${{ steps.review-type.outputs.model }}:
127+
128+
**Weekly Review Scope:**
129+
1. Architecture & Design
130+
- Review overall system architecture
131+
- Identify architectural improvements
132+
- Check design pattern usage
133+
- Verify separation of concerns
134+
135+
2. Code Quality Trends
136+
- Identify code quality improvements/regressions
137+
- Review recent commits for patterns
138+
- Check for technical debt accumulation
139+
- Suggest refactoring opportunities
140+
141+
3. Testing Strategy
142+
- Assess test coverage changes
143+
- Review test quality
144+
- Identify missing test scenarios
145+
- Suggest testing improvements
146+
147+
4. Documentation
148+
- Check if recent changes are documented
149+
- Review README and API documentation
150+
- Verify inline documentation quality
151+
- Identify documentation gaps
152+
153+
5. Dependencies & Security
154+
- Review dependency updates
155+
- Check for security vulnerabilities
156+
- Suggest version upgrades
157+
- Identify deprecated dependencies
158+
159+
6. Performance Analysis
160+
- Review performance-impacting changes
161+
- Identify optimization opportunities
162+
- Check for resource leaks
163+
- Suggest performance improvements
164+
165+
Provide a comprehensive summary with priorities and action items.
166+
continue-on-error: true
167+
168+
- name: Full Review with Selected Model
169+
if: steps.review-type.outputs.type == 'full'
170+
uses: austenstone/copilot-cli-action@v2
171+
with:
172+
copilot-token: ${{ secrets.COPILOT_TOKEN }}
173+
prompt: |
174+
Perform a full comprehensive code review using ${{ steps.review-type.outputs.model }}:
175+
176+
**Complete Code Review:**
177+
1. Code Quality & Architecture
178+
2. Security Analysis
179+
3. Performance Optimization
180+
4. Testing Strategy
181+
5. Documentation Quality
182+
6. Best Practices Adherence
183+
7. E2E Integration
184+
8. API Design
185+
9. Error Handling
186+
10. Maintainability
187+
188+
Provide detailed analysis with specific recommendations.
189+
continue-on-error: true
190+
191+
- name: Generate Review Report
192+
id: generate-report
193+
run: |
194+
echo "## Tag-Based Code Review Report" > /tmp/tag-review-report.md
195+
echo "" >> /tmp/tag-review-report.md
196+
echo "**Review Type:** ${{ steps.review-type.outputs.type }}" >> /tmp/tag-review-report.md
197+
echo "**AI Model:** ${{ steps.review-type.outputs.model }}" >> /tmp/tag-review-report.md
198+
echo "**Triggered by:** ${{ github.event_name }}" >> /tmp/tag-review-report.md
199+
echo "**Tag/Branch:** ${{ github.ref }}" >> /tmp/tag-review-report.md
200+
echo "**Date:** $(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> /tmp/tag-review-report.md
201+
echo "" >> /tmp/tag-review-report.md
202+
203+
# Add repository stats
204+
echo "### Repository Statistics:" >> /tmp/tag-review-report.md
205+
python_files=$(find . -name "*.py" ! -path "*/.venv/*" ! -path "*/node_modules/*" | wc -l)
206+
js_files=$(find . -name "*.js" ! -path "*/node_modules/*" ! -path "*/dist/*" | wc -l)
207+
ts_files=$(find . -name "*.ts" ! -path "*/node_modules/*" ! -path "*/dist/*" | wc -l)
208+
209+
echo "- Python files: $python_files" >> /tmp/tag-review-report.md
210+
echo "- JavaScript files: $js_files" >> /tmp/tag-review-report.md
211+
echo "- TypeScript files: $ts_files" >> /tmp/tag-review-report.md
212+
213+
# Add recent commits
214+
echo "" >> /tmp/tag-review-report.md
215+
echo "### Recent Changes:" >> /tmp/tag-review-report.md
216+
git log --oneline -10 >> /tmp/tag-review-report.md || echo "No recent commits" >> /tmp/tag-review-report.md
217+
218+
cat /tmp/tag-review-report.md
219+
continue-on-error: true
220+
221+
- name: Create Review Issue
222+
uses: actions/github-script@main
223+
with:
224+
github-token: ${{ secrets.GITHUB_TOKEN }}
225+
script: |
226+
const fs = require('fs');
227+
let report = '';
228+
try {
229+
report = fs.readFileSync('/tmp/tag-review-report.md', 'utf8');
230+
} catch (e) {
231+
report = 'Report generation failed';
232+
}
233+
234+
const date = new Date().toISOString().split('T')[0];
235+
const reviewType = '${{ steps.review-type.outputs.type }}';
236+
const model = '${{ steps.review-type.outputs.model }}';
237+
const title = `${reviewType.toUpperCase()} Code Review (${model}) - ${date}`;
238+
239+
const body = `# Tag-Based Code Review Report
240+
241+
${report}
242+
243+
## Review Configuration
244+
245+
- **Review Type:** ${reviewType}
246+
- **AI Model:** ${model}
247+
- **Repository:** ${{ github.repository }}
248+
- **Branch/Tag:** ${{ github.ref }}
249+
- **Commit:** ${{ github.sha }}
250+
- **Triggered by:** ${{ github.event_name }}
251+
252+
## About This Review
253+
254+
This review was triggered by a tag or manual dispatch. The review type determines the focus:
255+
256+
- **E2E Review:** Comprehensive end-to-end testing and integration analysis
257+
- **Weekly Review:** Broad code quality, architecture, and trend analysis
258+
- **Full Review:** Complete analysis covering all aspects
259+
260+
## Action Items
261+
262+
Review the findings above and:
263+
- [ ] Address high-priority security issues
264+
- [ ] Implement suggested architectural improvements
265+
- [ ] Add missing tests for E2E scenarios
266+
- [ ] Update documentation as needed
267+
- [ ] Plan refactoring for technical debt
268+
269+
---
270+
*This issue was automatically generated by the Tag-based Code Review workflow using ${model}.*
271+
`;
272+
273+
// Check for existing issues
274+
const issues = await github.rest.issues.listForRepo({
275+
owner: context.repo.owner,
276+
repo: context.repo.repo,
277+
state: 'open',
278+
labels: ['tag-review', 'automated'],
279+
per_page: 10
280+
});
281+
282+
const recentIssue = issues.data.find(issue => {
283+
const createdAt = new Date(issue.created_at);
284+
const daysSinceCreation = (Date.now() - createdAt) / (1000 * 60 * 60 * 24);
285+
return daysSinceCreation < 7 && issue.title.includes(reviewType);
286+
});
287+
288+
if (recentIssue) {
289+
console.log(`Recent ${reviewType} review issue found: #${recentIssue.number}, updating`);
290+
await github.rest.issues.createComment({
291+
owner: context.repo.owner,
292+
repo: context.repo.repo,
293+
issue_number: recentIssue.number,
294+
body: `## Updated Review (${date})\n\n${report}`
295+
});
296+
} else {
297+
await github.rest.issues.create({
298+
owner: context.repo.owner,
299+
repo: context.repo.repo,
300+
title: title,
301+
body: body,
302+
labels: ['tag-review', reviewType, 'automated', 'code-review', 'needs-review']
303+
});
304+
}
305+
continue-on-error: true
306+
307+
- name: Upload Review Report
308+
uses: actions/upload-artifact@main
309+
with:
310+
name: tag-review-report
311+
path: /tmp/tag-review-report.md
312+
retention-days: 90
313+
continue-on-error: true

0 commit comments

Comments
 (0)