|
1 | 1 | name: "Periodic Code Cleanliness Review" |
| 2 | +uto-amazonq-review.properties.json |
2 | 3 |
|
| 4 | +uto-amazonq-review.properties.json |
3 | 5 | on: |
| 6 | +uto-amazonq-review.properties.json |
4 | 7 | schedule: |
| 8 | +uto-amazonq-review.properties.json |
5 | 9 | # Run every 12 hours (at 00:00 and 12:00 UTC) |
| 10 | +uto-amazonq-review.properties.json |
6 | 11 | - cron: '0 0,12 * * *' |
| 12 | +uto-amazonq-review.properties.json |
7 | 13 | workflow_dispatch: # Allow manual trigger |
| 14 | +uto-amazonq-review.properties.json |
8 | 15 |
|
| 16 | +uto-amazonq-review.properties.json |
9 | 17 | permissions: |
| 18 | +uto-amazonq-review.properties.json |
10 | 19 | contents: write |
| 20 | +uto-amazonq-review.properties.json |
11 | 21 | pull-requests: write |
| 22 | +uto-amazonq-review.properties.json |
12 | 23 | issues: write |
| 24 | +uto-amazonq-review.properties.json |
13 | 25 |
|
| 26 | +uto-amazonq-review.properties.json |
14 | 27 | jobs: |
| 28 | +uto-amazonq-review.properties.json |
15 | 29 | code-cleanliness-review: |
16 | | - runs-on: ubuntu-latest |
| 30 | +uto-amazonq-review.properties.json |
| 31 | + runs-on: self-hosted |
| 32 | +uto-amazonq-review.properties.json |
17 | 33 | steps: |
| 34 | +uto-amazonq-review.properties.json |
18 | 35 | - name: Checkout code |
| 36 | +uto-amazonq-review.properties.json |
19 | 37 | uses: actions/checkout@main |
| 38 | +uto-amazonq-review.properties.json |
20 | 39 | with: |
| 40 | +uto-amazonq-review.properties.json |
21 | 41 | fetch-depth: 0 # Full history for better analysis |
| 42 | +uto-amazonq-review.properties.json |
22 | 43 |
|
| 44 | +uto-amazonq-review.properties.json |
23 | 45 | - name: Analyze Large Files |
| 46 | +uto-amazonq-review.properties.json |
24 | 47 | id: analyze |
| 48 | +uto-amazonq-review.properties.json |
25 | 49 | run: | |
| 50 | +uto-amazonq-review.properties.json |
26 | 51 | echo "## Large Files Analysis" > /tmp/analysis.md |
| 52 | +uto-amazonq-review.properties.json |
27 | 53 | echo "" >> /tmp/analysis.md |
| 54 | +uto-amazonq-review.properties.json |
28 | 55 | echo "Files larger than 500 lines that may benefit from splitting:" >> /tmp/analysis.md |
| 56 | +uto-amazonq-review.properties.json |
29 | 57 | echo "" >> /tmp/analysis.md |
| 58 | +uto-amazonq-review.properties.json |
30 | 59 |
|
| 60 | +uto-amazonq-review.properties.json |
31 | 61 | # Find files larger than 500 lines (excluding common large files) |
| 62 | +uto-amazonq-review.properties.json |
32 | 63 | find . -type f \( -name "*.py" -o -name "*.js" -o -name "*.ts" -o -name "*.java" -o -name "*.go" -o -name "*.cs" -o -name "*.rb" \) \ |
| 64 | +uto-amazonq-review.properties.json |
33 | 65 | ! -path "*/node_modules/*" \ |
| 66 | +uto-amazonq-review.properties.json |
34 | 67 | ! -path "*/dist/*" \ |
| 68 | +uto-amazonq-review.properties.json |
35 | 69 | ! -path "*/build/*" \ |
| 70 | +uto-amazonq-review.properties.json |
36 | 71 | ! -path "*/.venv/*" \ |
| 72 | +uto-amazonq-review.properties.json |
37 | 73 | ! -path "*/vendor/*" \ |
| 74 | +uto-amazonq-review.properties.json |
38 | 75 | -exec wc -l {} \; | \ |
| 76 | +uto-amazonq-review.properties.json |
39 | 77 | awk '$1 > 500 {print $1 " lines: " $2}' | \ |
| 78 | +uto-amazonq-review.properties.json |
40 | 79 | sort -rn >> /tmp/analysis.md || echo "No large files found" >> /tmp/analysis.md |
| 80 | +uto-amazonq-review.properties.json |
41 | 81 |
|
| 82 | +uto-amazonq-review.properties.json |
42 | 83 | echo "" >> /tmp/analysis.md |
| 84 | +uto-amazonq-review.properties.json |
43 | 85 | echo "## Code Complexity Analysis" >> /tmp/analysis.md |
| 86 | +uto-amazonq-review.properties.json |
44 | 87 | echo "" >> /tmp/analysis.md |
| 88 | +uto-amazonq-review.properties.json |
45 | 89 | echo "Files with potential complexity issues:" >> /tmp/analysis.md |
| 90 | +uto-amazonq-review.properties.json |
46 | 91 |
|
| 92 | +uto-amazonq-review.properties.json |
47 | 93 | # Find files with many functions/classes (basic heuristic) |
| 94 | +uto-amazonq-review.properties.json |
48 | 95 | for ext in py js ts java go cs rb; do |
| 96 | +uto-amazonq-review.properties.json |
49 | 97 | if [ "$ext" = "py" ]; then |
| 98 | +uto-amazonq-review.properties.json |
50 | 99 | pattern="^def |^class " |
| 100 | +uto-amazonq-review.properties.json |
51 | 101 | elif [ "$ext" = "js" ] || [ "$ext" = "ts" ]; then |
| 102 | +uto-amazonq-review.properties.json |
52 | 103 | pattern="^function |^class |const.*=.*=>|function.*{$" |
| 104 | +uto-amazonq-review.properties.json |
53 | 105 | else |
| 106 | +uto-amazonq-review.properties.json |
54 | 107 | pattern="^class |^def |^func " |
| 108 | +uto-amazonq-review.properties.json |
55 | 109 | fi |
| 110 | +uto-amazonq-review.properties.json |
56 | 111 |
|
| 112 | +uto-amazonq-review.properties.json |
57 | 113 | find . -type f -name "*.$ext" \ |
| 114 | +uto-amazonq-review.properties.json |
58 | 115 | ! -path "*/node_modules/*" \ |
| 116 | +uto-amazonq-review.properties.json |
59 | 117 | ! -path "*/dist/*" \ |
| 118 | +uto-amazonq-review.properties.json |
60 | 119 | ! -path "*/build/*" \ |
| 120 | +uto-amazonq-review.properties.json |
61 | 121 | ! -path "*/.venv/*" \ |
| 122 | +uto-amazonq-review.properties.json |
62 | 123 | ! -path "*/vendor/*" \ |
| 124 | +uto-amazonq-review.properties.json |
63 | 125 | -exec sh -c 'count=$(grep -c "$1" "$2" 2>/dev/null || echo 0); if [ "$count" -gt 20 ]; then echo "$count definitions in $2"; fi' _ "$pattern" {} \; \ |
| 126 | +uto-amazonq-review.properties.json |
64 | 127 | 2>/dev/null || true |
| 128 | +uto-amazonq-review.properties.json |
65 | 129 | done | sort -rn >> /tmp/analysis.md |
| 130 | +uto-amazonq-review.properties.json |
66 | 131 |
|
| 132 | +uto-amazonq-review.properties.json |
67 | 133 | cat /tmp/analysis.md |
| 134 | +uto-amazonq-review.properties.json |
68 | 135 |
|
| 136 | +uto-amazonq-review.properties.json |
69 | 137 | - name: GitHub Copilot Code Review |
| 138 | +uto-amazonq-review.properties.json |
70 | 139 | uses: github/copilot-cli-action@main |
| 140 | +uto-amazonq-review.properties.json |
71 | 141 | with: |
| 142 | +uto-amazonq-review.properties.json |
72 | 143 | query: | |
| 144 | +uto-amazonq-review.properties.json |
73 | 145 | Review the codebase for code cleanliness issues: |
| 146 | +uto-amazonq-review.properties.json |
74 | 147 | 1. Identify files that are too large (>500 lines) and suggest how to split them into smaller, focused modules |
| 148 | +uto-amazonq-review.properties.json |
75 | 149 | 2. Look for code duplication and suggest refactoring opportunities |
| 150 | +uto-amazonq-review.properties.json |
76 | 151 | 3. Check for consistent code style and formatting |
| 152 | +uto-amazonq-review.properties.json |
77 | 153 | 4. Identify complex functions that could be simplified |
| 154 | +uto-amazonq-review.properties.json |
78 | 155 | 5. Suggest improvements for code organization and structure |
| 156 | +uto-amazonq-review.properties.json |
79 | 157 | 6. Check for proper separation of concerns |
| 158 | +uto-amazonq-review.properties.json |
80 | 159 |
|
| 160 | +uto-amazonq-review.properties.json |
81 | 161 | Provide actionable recommendations with specific file names and line numbers. |
| 162 | +uto-amazonq-review.properties.json |
82 | 163 | env: |
| 164 | +uto-amazonq-review.properties.json |
83 | 165 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 166 | +uto-amazonq-review.properties.json |
84 | 167 | continue-on-error: true |
| 168 | +uto-amazonq-review.properties.json |
85 | 169 |
|
| 170 | +uto-amazonq-review.properties.json |
86 | 171 | - name: Create Issue for Code Cleanliness Review |
| 172 | +uto-amazonq-review.properties.json |
87 | 173 | uses: actions/github-script@main |
| 174 | +uto-amazonq-review.properties.json |
88 | 175 | with: |
| 176 | +uto-amazonq-review.properties.json |
89 | 177 | github-token: ${{ secrets.GITHUB_TOKEN }} |
| 178 | +uto-amazonq-review.properties.json |
90 | 179 | script: | |
| 180 | +uto-amazonq-review.properties.json |
91 | 181 | const fs = require('fs'); |
| 182 | +uto-amazonq-review.properties.json |
92 | 183 | const analysis = fs.readFileSync('/tmp/analysis.md', 'utf8'); |
| 184 | +uto-amazonq-review.properties.json |
93 | 185 |
|
| 186 | +uto-amazonq-review.properties.json |
94 | 187 | const date = new Date().toISOString().split('T')[0]; |
| 188 | +uto-amazonq-review.properties.json |
95 | 189 | const title = `Code Cleanliness Review - ${date}`; |
| 190 | +uto-amazonq-review.properties.json |
96 | 191 |
|
| 192 | +uto-amazonq-review.properties.json |
97 | 193 | const body = `# Periodic Code Cleanliness Review |
| 194 | +uto-amazonq-review.properties.json |
98 | 195 |
|
| 196 | +uto-amazonq-review.properties.json |
99 | 197 | This is an automated review conducted every 12 hours to maintain code quality. |
| 198 | +uto-amazonq-review.properties.json |
100 | 199 |
|
| 200 | +uto-amazonq-review.properties.json |
101 | 201 | ${analysis} |
| 202 | +uto-amazonq-review.properties.json |
102 | 203 |
|
| 204 | +uto-amazonq-review.properties.json |
103 | 205 | ## Recommendations |
| 206 | +uto-amazonq-review.properties.json |
104 | 207 |
|
| 208 | +uto-amazonq-review.properties.json |
105 | 209 | Please review the analysis above and: |
| 210 | +uto-amazonq-review.properties.json |
106 | 211 | 1. Split large files (>500 lines) into smaller, focused modules |
| 212 | +uto-amazonq-review.properties.json |
107 | 213 | 2. Refactor complex functions into smaller, testable units |
| 214 | +uto-amazonq-review.properties.json |
108 | 215 | 3. Remove code duplication |
| 216 | +uto-amazonq-review.properties.json |
109 | 217 | 4. Ensure consistent code style |
| 218 | +uto-amazonq-review.properties.json |
110 | 219 | 5. Improve code organization and structure |
| 220 | +uto-amazonq-review.properties.json |
111 | 221 |
|
| 222 | +uto-amazonq-review.properties.json |
112 | 223 | ## Next Steps |
| 224 | +uto-amazonq-review.properties.json |
113 | 225 |
|
| 226 | +uto-amazonq-review.properties.json |
114 | 227 | - Assign this issue to relevant team members |
| 228 | +uto-amazonq-review.properties.json |
115 | 229 | - Create follow-up PRs to address findings |
| 230 | +uto-amazonq-review.properties.json |
116 | 231 | - Document any architectural decisions |
| 232 | +uto-amazonq-review.properties.json |
117 | 233 |
|
| 234 | +uto-amazonq-review.properties.json |
118 | 235 | --- |
| 236 | +uto-amazonq-review.properties.json |
119 | 237 | *This issue was automatically generated by the Code Cleanliness Review workflow.* |
| 238 | +uto-amazonq-review.properties.json |
120 | 239 | `; |
| 240 | +uto-amazonq-review.properties.json |
121 | 241 | |
| 242 | +uto-amazonq-review.properties.json |
122 | 243 | // Check if similar issue exists (open, created in last 24 hours) |
| 244 | +uto-amazonq-review.properties.json |
123 | 245 | const issues = await github.rest.issues.listForRepo({ |
| 246 | +uto-amazonq-review.properties.json |
124 | 247 | owner: context.repo.owner, |
| 248 | +uto-amazonq-review.properties.json |
125 | 249 | repo: context.repo.repo, |
| 250 | +uto-amazonq-review.properties.json |
126 | 251 | state: 'open', |
| 252 | +uto-amazonq-review.properties.json |
127 | 253 | labels: ['code-cleanliness', 'automated'], |
| 254 | +uto-amazonq-review.properties.json |
128 | 255 | per_page: 10 |
| 256 | +uto-amazonq-review.properties.json |
129 | 257 | }); |
| 258 | +uto-amazonq-review.properties.json |
130 | 259 | |
| 260 | +uto-amazonq-review.properties.json |
131 | 261 | const recentIssue = issues.data.find(issue => { |
| 262 | +uto-amazonq-review.properties.json |
132 | 263 | const createdAt = new Date(issue.created_at); |
| 264 | +uto-amazonq-review.properties.json |
133 | 265 | const hoursSinceCreation = (Date.now() - createdAt) / (1000 * 60 * 60); |
| 266 | +uto-amazonq-review.properties.json |
134 | 267 | return hoursSinceCreation < 24; |
| 268 | +uto-amazonq-review.properties.json |
135 | 269 | }); |
| 270 | +uto-amazonq-review.properties.json |
136 | 271 | |
| 272 | +uto-amazonq-review.properties.json |
137 | 273 | if (recentIssue) { |
| 274 | +uto-amazonq-review.properties.json |
138 | 275 | console.log(`Recent issue found: #${recentIssue.number}, skipping creation`); |
| 276 | +uto-amazonq-review.properties.json |
139 | 277 | // Update existing issue with new analysis |
| 278 | +uto-amazonq-review.properties.json |
140 | 279 | await github.rest.issues.createComment({ |
| 280 | +uto-amazonq-review.properties.json |
141 | 281 | owner: context.repo.owner, |
| 282 | +uto-amazonq-review.properties.json |
142 | 283 | repo: context.repo.repo, |
| 284 | +uto-amazonq-review.properties.json |
143 | 285 | issue_number: recentIssue.number, |
| 286 | +uto-amazonq-review.properties.json |
144 | 287 | body: `## Updated Analysis (${date})\n\n${analysis}` |
| 288 | +uto-amazonq-review.properties.json |
145 | 289 | }); |
| 290 | +uto-amazonq-review.properties.json |
146 | 291 | } else { |
| 292 | +uto-amazonq-review.properties.json |
147 | 293 | // Create new issue |
| 294 | +uto-amazonq-review.properties.json |
148 | 295 | await github.rest.issues.create({ |
| 296 | +uto-amazonq-review.properties.json |
149 | 297 | owner: context.repo.owner, |
| 298 | +uto-amazonq-review.properties.json |
150 | 299 | repo: context.repo.repo, |
| 300 | +uto-amazonq-review.properties.json |
151 | 301 | title: title, |
| 302 | +uto-amazonq-review.properties.json |
152 | 303 | body: body, |
| 304 | +uto-amazonq-review.properties.json |
153 | 305 | labels: ['code-cleanliness', 'automated', 'needs-review'] |
| 306 | +uto-amazonq-review.properties.json |
154 | 307 | }); |
| 308 | +uto-amazonq-review.properties.json |
155 | 309 | } |
| 310 | +uto-amazonq-review.properties.json |
0 commit comments