-
-
Notifications
You must be signed in to change notification settings - Fork 14
353 lines (314 loc) · 12 KB
/
Copy pathlint.yml
File metadata and controls
353 lines (314 loc) · 12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
name: 🧼 Lint
on:
workflow_dispatch:
inputs:
frameworks:
description: 'Frameworks to lint (comma-separated, see frameworks.json for available options)'
required: false
default: 'all'
type: string
pull_request:
branches: [ main, master, dev ]
paths:
- 'apps/**'
- 'eslint.config.mjs'
- 'package.json'
- '.github/workflows/lint.yml'
types: [ opened, synchronize, reopened ]
push:
branches: [ main ]
paths:
- 'apps/**'
- 'eslint.config.mjs'
- 'package.json'
- '.github/workflows/lint.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
actions: read
jobs:
setup:
name: Setup for Linting
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
frameworks: ${{ steps.matrix.outputs.frameworks }}
steps:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: '22'
cache: 'npm'
- name: Setup Python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: '3.9'
cache: 'pip'
cache-dependency-path: scripts/requirements.txt
- name: Install Python dependencies
run: pip install -r scripts/requirements.txt
- name: Install dependencies
run: npm ci
- name: Filter changed paths
if: github.event_name == 'pull_request'
uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4
id: changed
with:
list-files: shell
filters: |
shared:
- 'package.json'
- 'package-lock.json'
- 'eslint.config.mjs'
- '.github/workflows/lint.yml'
apps:
- 'apps/**'
- name: Determine frameworks to lint
id: matrix
env:
FRAMEWORKS_INPUT: ${{ github.event.inputs.frameworks }}
EVENT_NAME: ${{ github.event_name }}
SHARED: ${{ steps.changed.outputs.shared }}
APPS_FILES: ${{ steps.changed.outputs.apps_files }}
run: |
if [ "$EVENT_NAME" = "workflow_dispatch" ] && [ "$FRAMEWORKS_INPUT" != "all" ]; then
frameworks="$FRAMEWORKS_INPUT"
elif [ "$EVENT_NAME" = "pull_request" ] && [ "$SHARED" != "true" ]; then
# PR touching only specific apps: lint just those frameworks
frameworks=$(echo "$APPS_FILES" | tr ' ' '\n' | sed -nE 's#^apps/([^/]+)/.*#\1#p' | sort -u | paste -sd, -)
else
# Get framework list from Python config
frameworks=$(python scripts/get_frameworks.py)
fi
echo "frameworks=$(echo "[$frameworks]" | sed 's/,/", "/g' | sed 's/\[/[\"/ ; s/\]/\"]/')" >> "$GITHUB_OUTPUT"
echo "Linting frameworks: $frameworks"
lint:
name: Lint ${{ matrix.framework }}
needs: setup
if: fromJSON(needs.setup.outputs.frameworks)[0] != ''
runs-on: ubuntu-latest
timeout-minutes: 10
continue-on-error: true
strategy:
fail-fast: false
matrix:
framework: ${{ fromJSON(needs.setup.outputs.frameworks) }}
steps:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run ESLint for ${{ matrix.framework }}
env:
FRAMEWORK: ${{ matrix.framework }}
run: npm run "lint:$FRAMEWORK"
- name: Generate lint report for ${{ matrix.framework }}
if: always()
env:
FRAMEWORK: ${{ matrix.framework }}
run: |
mkdir -p lint-reports
npm run "lint:$FRAMEWORK" -- --format=json --output-file="lint-reports/${FRAMEWORK}-lint-report.json" || true
- name: Upload lint report
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: lint-report-${{ matrix.framework }}
path: lint-reports/${{ matrix.framework }}-lint-report.json
retention-days: 30
- name: Generate lint badge
if: always()
env:
FRAMEWORK: ${{ matrix.framework }}
run: |
# Determine badge status and color
report_file="lint-reports/${FRAMEWORK}-lint-report.json"
if [ -f "$report_file" ]; then
error_count=$(jq '[.[].errorCount] | add // 0' "$report_file" 2>/dev/null || echo "0")
warning_count=$(jq '[.[].warningCount] | add // 0' "$report_file" 2>/dev/null || echo "0")
if [ "$error_count" = "0" ] && [ "$warning_count" = "0" ]; then
status="Clean"
color="3cd96b"
label_color="33b348"
elif [ "$error_count" = "0" ]; then
status="${warning_count}_warnings"
color="fb974e"
label_color="d58144"
else
status="${error_count}_errors"
color="ff5666"
label_color="d5334a"
fi
else
status="unknown"
color="c4c4c4"
label_color="939393"
fi
# Generate badge
badge_url="https://img.shields.io/badge/Lint-${status}-${color}?logo=eslint&logoColor=fff&labelColor=${label_color}"
curl -o "lint-${FRAMEWORK}.svg" "$badge_url"
- name: Upload badge
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: badge-lint-${{ matrix.framework }}
path: lint-${{ matrix.framework }}.svg
retention-days: 1
summary:
name: Lint Summary
needs: [setup, lint]
if: always()
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Download all lint reports
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
path: lint-reports
merge-multiple: true
- name: Generate lint summary
env:
FRAMEWORKS_JSON: ${{ needs.setup.outputs.frameworks }}
run: |
# Get the frameworks that were actually tested
frameworks=$(echo "$FRAMEWORKS_JSON" | jq -r '.[]' | tr '\n' ' ')
total_apps=0
passed_apps=0
total_errors=0
total_warnings=0
table_rows=""
for framework in $frameworks; do
total_apps=$((total_apps + 1))
report_file="lint-reports/${framework}-lint-report.json"
if [ -f "$report_file" ]; then
# Count actual errors and warnings from the JSON
error_count=$(jq '[.[].errorCount] | add // 0' "$report_file" 2>/dev/null || echo "0")
warning_count=$(jq '[.[].warningCount] | add // 0' "$report_file" 2>/dev/null || echo "0")
total_errors=$((total_errors + error_count))
total_warnings=$((total_warnings + warning_count))
if [ "$error_count" = "0" ] && [ "$warning_count" = "0" ]; then
table_rows="$table_rows| **$framework** | ✅ **Clean** | No issues |\n"
passed_apps=$((passed_apps + 1))
else
issues=""
if [ "$error_count" -gt "0" ]; then
issues="$error_count errors"
fi
if [ "$warning_count" -gt "0" ]; then
if [ -n "$issues" ]; then
issues="$issues, $warning_count warnings"
else
issues="$warning_count warnings"
fi
fi
table_rows="$table_rows| **$framework** | ❌ **Issues** | $issues |\n"
fi
else
table_rows="$table_rows| **$framework** | ❓ **Missing** | No report found |\n"
fi
done
# Generate summary
{
echo "# 🧼 Lint Results Summary"
echo ""
if [ "$total_errors" -eq "0" ] && [ "$total_warnings" -eq "0" ]; then
echo "> 🎉 **Perfect!** All $total_apps apps passed lint checks with no issues."
else
issues_text=""
if [ "$total_errors" -gt "0" ]; then
issues_text="$total_errors errors"
fi
if [ "$total_warnings" -gt "0" ]; then
if [ -n "$issues_text" ]; then
issues_text="$issues_text and $total_warnings warnings"
else
issues_text="$total_warnings warnings"
fi
fi
echo "> ⚠️ **$passed_apps/$total_apps** apps passed lint checks, $issues_text need addressing (see below for details)."
fi
# Only show table if there are results
if [ -n "$table_rows" ]; then
echo ""
echo "| Framework | Status | Issues |"
echo "|-----------|--------|--------|"
echo -e "$table_rows"
fi
} >> "$GITHUB_STEP_SUMMARY"
- name: Check overall status
run: |
if [[ "${{ needs.lint.result }}" != "success" ]]; then
echo "❌ Some linting failed"
exit 1
else
echo "✅ All linting passed successfully!"
fi
badges:
name: Update Lint Badges
needs: [setup, lint]
if: ${{ always() && github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
continue-on-error: true
permissions:
contents: write
steps:
- name: Checkout with bot token
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
token: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }}
fetch-depth: 0
persist-credentials: false
- name: Download all badges
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
pattern: badge-lint-*
path: badges
merge-multiple: true
- name: Commit badges
env:
TOKEN: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
run: |
git config user.name 'liss-bot'
git config user.email 'alicia-gh-bot@mail.as93.net'
git remote set-url origin "https://x-access-token:${TOKEN}@github.com/${REPO}.git"
# Switch to badges branch
git fetch origin badges:badges 2>/dev/null || git checkout --orphan badges
git checkout badges 2>/dev/null || true
git pull origin badges 2>/dev/null || true
# Copy badges and commit
cp badges/*.svg . 2>/dev/null || echo "⚠️ No badge files found"
if git add ./*.svg && git diff --staged --quiet; then
echo "ℹ️ No badge changes to commit"
else
git commit -m "Update lint badges"
if git push origin badges; then
echo "✅ Successfully updated lint badges"
else
echo "⚠️ Failed to push badge updates"
exit 1
fi
fi