Skip to content

Commit a49df55

Browse files
committed
Sync auto-amazonq-review.yml from .github repo
1 parent 91bfce8 commit a49df55

File tree

1 file changed

+277
-0
lines changed

1 file changed

+277
-0
lines changed
Lines changed: 277 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,277 @@
1+
name: "AmazonQ Review after GitHub Copilot"
2+
3+
on:
4+
# Triggered when GitHub Copilot workflows complete
5+
workflow_run:
6+
workflows:
7+
- "Periodic Code Cleanliness Review"
8+
- "Comprehensive Test Review with Playwright"
9+
- "Code Functionality and Documentation Review"
10+
- "Org-wide: Copilot Playwright Test, Review, Auto-fix, PR, Merge"
11+
- "Complete CI/CD Agent Review Pipeline"
12+
types:
13+
- completed
14+
workflow_dispatch:
15+
16+
permissions:
17+
contents: write
18+
pull-requests: write
19+
issues: write
20+
actions: read
21+
22+
jobs:
23+
wait-for-copilot-agents:
24+
runs-on: ubuntu-latest
25+
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@main
29+
30+
- name: Wait for any pending Copilot PRs
31+
uses: actions/github-script@main
32+
with:
33+
github-token: ${{ secrets.GITHUB_TOKEN }}
34+
script: |
35+
// Wait a bit for Copilot agents to potentially create PRs
36+
console.log('Waiting for Copilot agents to complete...');
37+
await new Promise(resolve => setTimeout(resolve, 30000)); // 30 second delay
38+
39+
// Check for recent Copilot PRs
40+
const prs = await github.rest.pulls.list({
41+
owner: context.repo.owner,
42+
repo: context.repo.repo,
43+
state: 'open',
44+
sort: 'created',
45+
direction: 'desc',
46+
per_page: 10
47+
});
48+
49+
const copilotPRs = prs.data.filter(pr =>
50+
pr.title.includes('Copilot') ||
51+
pr.head.ref.includes('copilot') ||
52+
pr.user.login === 'github-actions[bot]'
53+
);
54+
55+
if (copilotPRs.length > 0) {
56+
console.log(`Found ${copilotPRs.length} recent Copilot PRs`);
57+
copilotPRs.forEach(pr => {
58+
console.log(` - PR #${pr.number}: ${pr.title}`);
59+
});
60+
} else {
61+
console.log('No recent Copilot PRs found');
62+
}
63+
64+
amazonq-code-review:
65+
runs-on: ubuntu-latest
66+
needs: wait-for-copilot-agents
67+
steps:
68+
- name: Checkout code
69+
uses: actions/checkout@main
70+
with:
71+
fetch-depth: 0
72+
73+
- name: Setup AWS credentials for Amazon Q
74+
uses: aws-actions/configure-aws-credentials@main
75+
with:
76+
aws-region: us-east-1
77+
# Note: AWS credentials should be configured in repository secrets
78+
# AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
79+
continue-on-error: true
80+
81+
- name: Prepare code for Amazon Q review
82+
id: prepare
83+
run: |
84+
echo "## Amazon Q Code Review Preparation" > /tmp/amazonq-prep.md
85+
echo "" >> /tmp/amazonq-prep.md
86+
echo "Repository: ${{ github.repository }}" >> /tmp/amazonq-prep.md
87+
echo "Branch: ${{ github.ref_name }}" >> /tmp/amazonq-prep.md
88+
echo "Triggered by: ${{ github.event.workflow_run.name || 'Manual trigger' }}" >> /tmp/amazonq-prep.md
89+
echo "" >> /tmp/amazonq-prep.md
90+
91+
# Get list of recent changes
92+
echo "### Recent Changes:" >> /tmp/amazonq-prep.md
93+
git log --oneline -10 >> /tmp/amazonq-prep.md || echo "No recent commits" >> /tmp/amazonq-prep.md
94+
95+
echo "" >> /tmp/amazonq-prep.md
96+
echo "### Files Changed Recently:" >> /tmp/amazonq-prep.md
97+
git diff --name-only HEAD~5..HEAD 2>/dev/null >> /tmp/amazonq-prep.md || echo "No changes in last 5 commits" >> /tmp/amazonq-prep.md
98+
99+
cat /tmp/amazonq-prep.md
100+
101+
- name: Run Amazon Q Code Review
102+
id: amazonq
103+
run: |
104+
echo "Running Amazon Q code review..."
105+
106+
# Create review report
107+
echo "## Amazon Q Code Review Report" > /tmp/amazonq-report.md
108+
echo "" >> /tmp/amazonq-report.md
109+
echo "**Review Date:** $(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> /tmp/amazonq-report.md
110+
echo "" >> /tmp/amazonq-report.md
111+
112+
# Note: This is a placeholder for actual Amazon Q integration
113+
# Amazon Q CLI or SDK integration would go here
114+
# For now, we'll create a comprehensive analysis structure
115+
116+
echo "### Code Quality Assessment" >> /tmp/amazonq-report.md
117+
echo "" >> /tmp/amazonq-report.md
118+
echo "Following the GitHub Copilot agent reviews, Amazon Q provides additional insights:" >> /tmp/amazonq-report.md
119+
echo "" >> /tmp/amazonq-report.md
120+
121+
# Analyze code structure
122+
echo "#### Code Structure Analysis" >> /tmp/amazonq-report.md
123+
find . -type f \( -name "*.py" -o -name "*.js" -o -name "*.ts" -o -name "*.java" -o -name "*.go" \) \
124+
! -path "*/node_modules/*" \
125+
! -path "*/.venv/*" \
126+
! -path "*/dist/*" \
127+
! -path "*/build/*" \
128+
| wc -l > /tmp/file_count.txt
129+
130+
FILE_COUNT=$(cat /tmp/file_count.txt)
131+
echo "- Total source files analyzed: $FILE_COUNT" >> /tmp/amazonq-report.md
132+
echo "" >> /tmp/amazonq-report.md
133+
134+
echo "#### Security Considerations" >> /tmp/amazonq-report.md
135+
echo "- Credential scanning: Check for hardcoded secrets" >> /tmp/amazonq-report.md
136+
echo "- Dependency vulnerabilities: Review package versions" >> /tmp/amazonq-report.md
137+
echo "- Code injection risks: Validate input handling" >> /tmp/amazonq-report.md
138+
echo "" >> /tmp/amazonq-report.md
139+
140+
echo "#### Performance Optimization Opportunities" >> /tmp/amazonq-report.md
141+
echo "- Algorithm efficiency: Review computational complexity" >> /tmp/amazonq-report.md
142+
echo "- Resource management: Check for memory leaks and resource cleanup" >> /tmp/amazonq-report.md
143+
echo "- Caching opportunities: Identify repeated computations" >> /tmp/amazonq-report.md
144+
echo "" >> /tmp/amazonq-report.md
145+
146+
echo "#### Architecture and Design Patterns" >> /tmp/amazonq-report.md
147+
echo "- Design patterns usage: Verify appropriate pattern application" >> /tmp/amazonq-report.md
148+
echo "- Separation of concerns: Check module boundaries" >> /tmp/amazonq-report.md
149+
echo "- Dependency management: Review coupling and cohesion" >> /tmp/amazonq-report.md
150+
echo "" >> /tmp/amazonq-report.md
151+
152+
echo "### Integration with Previous Reviews" >> /tmp/amazonq-report.md
153+
echo "" >> /tmp/amazonq-report.md
154+
echo "This review complements the GitHub Copilot agent findings with:" >> /tmp/amazonq-report.md
155+
echo "- Additional security analysis" >> /tmp/amazonq-report.md
156+
echo "- AWS best practices recommendations" >> /tmp/amazonq-report.md
157+
echo "- Performance optimization suggestions" >> /tmp/amazonq-report.md
158+
echo "- Enterprise architecture patterns" >> /tmp/amazonq-report.md
159+
echo "" >> /tmp/amazonq-report.md
160+
161+
echo "### Next Steps" >> /tmp/amazonq-report.md
162+
echo "" >> /tmp/amazonq-report.md
163+
echo "1. Review findings from both GitHub Copilot and Amazon Q" >> /tmp/amazonq-report.md
164+
echo "2. Prioritize issues based on severity and impact" >> /tmp/amazonq-report.md
165+
echo "3. Create action items for high-priority findings" >> /tmp/amazonq-report.md
166+
echo "4. Schedule follow-up reviews for resolved items" >> /tmp/amazonq-report.md
167+
echo "" >> /tmp/amazonq-report.md
168+
169+
# Note: Actual Amazon Q integration would use AWS SDK or CLI
170+
# Example (when Amazon Q API is available):
171+
# aws codewhisperer review --repository-path . --output json > /tmp/amazonq-results.json
172+
# Or use Amazon Q Developer CLI when available
173+
174+
cat /tmp/amazonq-report.md
175+
continue-on-error: true
176+
177+
- name: Create Amazon Q Review Issue
178+
uses: actions/github-script@main
179+
with:
180+
github-token: ${{ secrets.GITHUB_TOKEN }}
181+
script: |
182+
const fs = require('fs');
183+
const report = fs.readFileSync('/tmp/amazonq-report.md', 'utf8');
184+
185+
const date = new Date().toISOString().split('T')[0];
186+
const title = `Amazon Q Code Review - ${date}`;
187+
188+
const body = `# Amazon Q Code Review Report
189+
190+
This review was triggered after GitHub Copilot agent workflows completed.
191+
192+
${report}
193+
194+
## Review Context
195+
196+
- **Triggered by:** ${{ github.event.workflow_run.name || 'Manual workflow dispatch' }}
197+
- **Repository:** ${{ github.repository }}
198+
- **Branch:** ${{ github.ref_name }}
199+
- **Commit:** ${{ github.sha }}
200+
201+
## Related Reviews
202+
203+
Check for related issues with these labels:
204+
- \`code-cleanliness\` - Code structure and organization
205+
- \`test-coverage\` - Test quality and Playwright usage
206+
- \`documentation\` - Documentation completeness
207+
208+
## Instructions for Amazon Q Integration
209+
210+
To enable full Amazon Q integration:
211+
212+
1. **Set up AWS credentials** in repository secrets:
213+
- \`AWS_ACCESS_KEY_ID\`
214+
- \`AWS_SECRET_ACCESS_KEY\`
215+
216+
2. **Install Amazon Q Developer CLI** (when available):
217+
- Follow AWS documentation for Amazon Q setup
218+
- Configure repository access
219+
220+
3. **Enable Amazon CodeWhisperer** for security scanning
221+
222+
4. **Configure custom review rules** based on your needs
223+
224+
## Action Items
225+
226+
- [ ] Review Amazon Q findings
227+
- [ ] Compare with GitHub Copilot recommendations
228+
- [ ] Prioritize and assign issues
229+
- [ ] Implement high-priority fixes
230+
- [ ] Update documentation as needed
231+
232+
---
233+
*This issue was automatically generated by the Amazon Q Review workflow.*
234+
`;
235+
236+
// Check for existing Amazon Q review issues
237+
const issues = await github.rest.issues.listForRepo({
238+
owner: context.repo.owner,
239+
repo: context.repo.repo,
240+
state: 'open',
241+
labels: ['amazon-q', 'automated'],
242+
per_page: 10
243+
});
244+
245+
const recentIssue = issues.data.find(issue => {
246+
const createdAt = new Date(issue.created_at);
247+
const daysSinceCreation = (Date.now() - createdAt) / (1000 * 60 * 60 * 24);
248+
return daysSinceCreation < 7;
249+
});
250+
251+
if (recentIssue) {
252+
console.log(`Recent issue found: #${recentIssue.number}, updating`);
253+
await github.rest.issues.createComment({
254+
owner: context.repo.owner,
255+
repo: context.repo.repo,
256+
issue_number: recentIssue.number,
257+
body: `## Updated Review (${date})\n\n${report}`
258+
});
259+
} else {
260+
await github.rest.issues.create({
261+
owner: context.repo.owner,
262+
repo: context.repo.repo,
263+
title: title,
264+
body: body,
265+
labels: ['amazon-q', 'automated', 'code-review', 'needs-review']
266+
});
267+
}
268+
269+
- name: Upload Amazon Q Report
270+
uses: actions/upload-artifact@main
271+
with:
272+
name: amazonq-review-report
273+
path: |
274+
/tmp/amazonq-report.md
275+
/tmp/amazonq-prep.md
276+
retention-days: 90
277+
continue-on-error: true

0 commit comments

Comments
 (0)