This repository is currently being migrated. It's locked while the migration is in progress.
-
Notifications
You must be signed in to change notification settings - Fork 87
492 lines (420 loc) · 20.7 KB
/
metrics-dashboard.yml
File metadata and controls
492 lines (420 loc) · 20.7 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
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
name: Update Metrics Dashboard Data
on:
schedule:
# Run weekly on Fridays at 6 PM UTC (2 PM ET / 1 PM EDT) - after component-library PR is merged
- cron: '0 18 * * 5'
# NOTE: pull_request trigger intentionally removed — it caused infinite loops
# when the workflow committed updated metrics data back to the PR branch.
# Use workflow_dispatch to test changes manually.
workflow_dispatch:
# Allow manual triggering for testing and on-demand updates
jobs:
update-metrics:
runs-on: ubuntu-latest
# Skip if the last commit was made by GitHub Action (prevents infinite loops)
if: |
github.event.head_commit.author.email != 'action@github.com' &&
!contains(github.event.head_commit.message, '📊 Update metrics dashboard data') &&
!contains(github.event.head_commit.message, '🤖 Automated update via GitHub Actions')
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.VADS_WORKFLOWS }}
ref: ${{ github.head_ref || github.ref_name }}
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Skip dependency installation for metrics scripts
run: |
echo "📝 Metrics scripts only use built-in Node.js modules"
echo "🚀 Skipping yarn install to avoid React dependency conflicts"
echo "✅ Node.js $(node --version) is ready for script execution"
- name: Setup GitHub CLI
run: |
# GitHub CLI is pre-installed on ubuntu-latest runners
echo "Using pre-installed GitHub CLI"
gh --version
env:
GITHUB_TOKEN: ${{ secrets.VADS_WORKFLOWS }}
- name: Verify GitHub CLI authentication
run: |
gh auth status
gh api user --jq '.login'
env:
GITHUB_TOKEN: ${{ secrets.VADS_WORKFLOWS }}
- name: Create data directories
run: |
mkdir -p src/assets/data/metrics
mkdir -p src/assets/img/metrics
mkdir -p src/_data/metrics
- name: Checkout component-library for CLI tools
uses: actions/checkout@v4
with:
repository: department-of-veterans-affairs/component-library
path: component-library
token: ${{ secrets.VADS_WORKFLOWS }}
fetch-depth: 1
- name: Checkout vets-website for analysis
uses: actions/checkout@v4
with:
repository: department-of-veterans-affairs/vets-website
path: vets-website
token: ${{ secrets.VADS_WORKFLOWS }}
fetch-depth: 1
- name: Checkout content-build for analysis
uses: actions/checkout@v4
with:
repository: department-of-veterans-affairs/content-build
path: content-build
token: ${{ secrets.VADS_WORKFLOWS }}
fetch-depth: 1
- name: Install CLI dependencies
working-directory: component-library/packages/design-system-dashboard-cli
run: yarn install
- name: Set consistent date for all operations
run: |
CURRENT_DATE=$(date +%Y-%m-%d)
echo "CURRENT_DATE=$CURRENT_DATE" >> $GITHUB_ENV
echo "📅 Using consistent date: $CURRENT_DATE"
- name: Create CLI .env.json for GitHub Actions
working-directory: component-library/packages/design-system-dashboard-cli
run: |
echo '{
"repos": {
"vets-website": "../../../vets-website/",
"content-build": "../../../content-build/"
}
}' > .env.json
- name: Generate forms report
working-directory: component-library/packages/design-system-dashboard-cli
run: |
mkdir -p output
yarn forms --csv --output "output/form-apps-${CURRENT_DATE}.csv"
echo "✅ Forms report generated: form-apps-${CURRENT_DATE}.csv"
- name: Generate design system components report
working-directory: component-library/packages/design-system-dashboard-cli
run: |
yarn report:csv --output "output/ds-components-${CURRENT_DATE}.csv"
echo "✅ DS components report generated: ds-components-${CURRENT_DATE}.csv"
- name: Generate forms library usage report
working-directory: component-library/packages/design-system-dashboard-cli
run: |
yarn forms-library-usage --list > "output/forms-library-usage-${CURRENT_DATE}.txt"
echo "✅ Forms library usage report generated: forms-library-usage-${CURRENT_DATE}.txt"
- name: Copy reports to metrics directories
run: |
CLI_OUTPUT="component-library/packages/design-system-dashboard-cli/output"
# Verify all required files exist before copying
FORM_APPS_FILE="${CLI_OUTPUT}/form-apps-${CURRENT_DATE}.csv"
DS_COMPONENTS_FILE="${CLI_OUTPUT}/ds-components-${CURRENT_DATE}.csv"
FORMS_USAGE_FILE="${CLI_OUTPUT}/forms-library-usage-${CURRENT_DATE}.txt"
if [ ! -f "$FORM_APPS_FILE" ]; then
echo "❌ Error: Forms report not found at $FORM_APPS_FILE"
exit 1
fi
if [ ! -f "$DS_COMPONENTS_FILE" ]; then
echo "❌ Error: DS components report not found at $DS_COMPONENTS_FILE"
exit 1
fi
if [ ! -f "$FORMS_USAGE_FILE" ]; then
echo "❌ Error: Forms library usage report not found at $FORMS_USAGE_FILE"
exit 1
fi
echo "✅ All required files verified, copying reports..."
# Copy all three reports with timestamped names
cp "$FORM_APPS_FILE" "src/_data/metrics/form-apps-${CURRENT_DATE}.csv"
cp "$DS_COMPONENTS_FILE" "src/_data/metrics/ds-components-${CURRENT_DATE}.csv"
cp "$FORMS_USAGE_FILE" "src/_data/metrics/forms-library-usage-${CURRENT_DATE}.txt"
# Also create "latest" copies for easier processing
cp "$FORM_APPS_FILE" "src/_data/metrics/form-apps-latest.csv"
cp "$DS_COMPONENTS_FILE" "src/_data/metrics/ds-components-latest.csv"
cp "$FORMS_USAGE_FILE" "src/_data/metrics/forms-library-usage-latest.txt"
echo "✅ All reports copied to src/_data/metrics/"
echo "Files created:"
ls -lh src/_data/metrics/*-${CURRENT_DATE}.*
ls -lh src/_data/metrics/*-latest.*
- name: Process ds-components data
run: |
echo "Processing ds-components CSV data..."
if node scripts/process-ds-components.js; then
echo "✅ ds-components processing completed successfully"
else
echo "⚠️ ds-components processing failed, but continuing with fallback data"
# Don't fail the workflow - fallback data should be available
fi
- name: Collect issue metrics
run: |
echo "Starting issue metrics collection..."
node scripts/collect-issue-metrics.js
echo "Issue metrics collection completed"
env:
GITHUB_TOKEN: ${{ secrets.VADS_WORKFLOWS }}
- name: Collect experimental design metrics
run: |
echo "Starting experimental design metrics collection..."
node scripts/collect-experimental-metrics.js
echo "Experimental design metrics collection completed"
env:
GITHUB_TOKEN: ${{ secrets.VADS_WORKFLOWS }}
- name: Collect governance metrics
run: |
echo "Starting governance metrics collection..."
node scripts/collect-governance-metrics.js
echo "Governance metrics collection completed"
env:
GITHUB_TOKEN: ${{ secrets.VADS_WORKFLOWS }}
- name: Collect imposter metrics
# Allow workflow to continue if imposter metrics collection fails
# This is a newer feature and shouldn't block other metrics
continue-on-error: true
run: |
echo "Starting imposter component metrics collection..."
node scripts/collect-imposter-metrics.js
echo "Imposter metrics collection completed"
env:
GITHUB_TOKEN: ${{ secrets.VADS_WORKFLOWS }}
- name: Verify generated data files
run: |
echo "Checking for generated files..."
ls -la src/assets/data/metrics/
ls -la src/_data/metrics/
# Check issue metrics in both locations
if [ -f "src/assets/data/metrics/issue-metrics.json" ]; then
echo "✅ issue-metrics.json generated successfully in assets"
echo "File size: $(du -h src/assets/data/metrics/issue-metrics.json)"
# Show first few lines for verification
echo "Sample data:"
head -20 src/assets/data/metrics/issue-metrics.json
else
echo "❌ issue-metrics.json not found in assets"
exit 1
fi
if [ -f "src/_data/metrics/issue-metrics.json" ]; then
echo "✅ issue-metrics.json also generated for Jekyll"
echo "File size: $(du -h src/_data/metrics/issue-metrics.json)"
else
echo "❌ issue-metrics.json not found for Jekyll"
exit 1
fi
# Check component usage data in both locations
if [ -f "src/assets/data/metrics/component-usage.json" ]; then
echo "✅ component-usage.json generated successfully in assets"
echo "File size: $(du -h src/assets/data/metrics/component-usage.json)"
else
echo "❌ component-usage.json not found in assets"
exit 1
fi
if [ -f "src/_data/metrics/component-usage.json" ]; then
echo "✅ component-usage.json also generated for Jekyll"
echo "File size: $(du -h src/_data/metrics/component-usage.json)"
else
echo "❌ component-usage.json not found for Jekyll"
exit 1
fi
# Check experimental metrics in both locations
if [ -f "src/assets/data/metrics/experimental-metrics.json" ]; then
echo "✅ experimental-metrics.json generated successfully in assets"
echo "File size: $(du -h src/assets/data/metrics/experimental-metrics.json)"
else
echo "❌ experimental-metrics.json not found in assets"
exit 1
fi
if [ -f "src/_data/metrics/experimental-metrics.json" ]; then
echo "✅ experimental-metrics.json also generated for Jekyll"
echo "File size: $(du -h src/_data/metrics/experimental-metrics.json)"
else
echo "❌ experimental-metrics.json not found for Jekyll"
exit 1
fi
# Check ds-components data
if [ -f "src/_data/metrics/ds-components-latest.csv" ]; then
echo "✅ ds-components-latest.csv available"
echo "File size: $(du -h src/_data/metrics/ds-components-latest.csv)"
echo "Component data preview:"
head -5 src/_data/metrics/ds-components-latest.csv
else
echo "❌ ds-components-latest.csv not found"
exit 1
fi
# Check governance metrics data
if [ -f "src/_data/metrics/governance-index.json" ]; then
echo "✅ governance-index.json generated successfully"
echo "File size: $(du -h src/_data/metrics/governance-index.json)"
else
echo "❌ governance-index.json not found"
exit 1
fi
# Check if governance metrics CSV was generated
if [ -f "src/_data/metrics/governance-metrics.csv" ]; then
echo "✅ governance-metrics.csv generated successfully"
echo "File size: $(du -h src/_data/metrics/governance-metrics.csv)"
else
echo "ℹ️ governance-metrics.csv not found (may not be generated in current run)"
fi
# Check imposter metrics in both locations (non-blocking since collection has continue-on-error)
if [ -f "src/assets/data/metrics/imposter-metrics.json" ]; then
echo "✅ imposter-metrics.json generated successfully in assets"
echo "File size: $(du -h src/assets/data/metrics/imposter-metrics.json)"
else
echo "ℹ️ imposter-metrics.json not found in assets (imposter metrics collection may have been skipped)"
fi
if [ -f "src/_data/metrics/imposter-metrics.json" ]; then
echo "✅ imposter-metrics.json also generated for Jekyll"
echo "File size: $(du -h src/_data/metrics/imposter-metrics.json)"
else
echo "ℹ️ imposter-metrics.json not found for Jekyll (imposter metrics collection may have been skipped)"
fi
- name: Check for changes
id: git-check
run: |
# Only add the specific metric files that were generated, not all files in the directories
# List expected files and add them if they exist
# Add specific JSON files
for file in \
src/assets/data/metrics/issue-metrics.json \
src/assets/data/metrics/experimental-metrics.json \
src/assets/data/metrics/component-usage.json \
src/assets/data/metrics/governance-index.json \
src/assets/data/metrics/imposter-metrics.json \
src/_data/metrics/issue-metrics.json \
src/_data/metrics/experimental-metrics.json \
src/_data/metrics/component-usage.json \
src/_data/metrics/governance-index.json \
src/_data/metrics/imposter-metrics.json; do
if [ -f "$file" ]; then
git add "$file"
fi
done
# Add quarterly governance metrics files (governance-metrics-YYYYQN.json pattern)
# These are generated dynamically, one file per quarter (e.g., governance-metrics-2025Q3.json)
# The wildcard intentionally captures all quarterly files matching this naming convention
git add src/assets/data/metrics/governance-metrics-*.json 2>/dev/null || true
git add src/_data/metrics/governance-metrics-*.json 2>/dev/null || true
# Add CSV files if they exist
# Note: Only CSV files in src/assets/data/metrics/ are added
# CSV files in src/_data/metrics/ (if generated) are intentionally excluded
# to avoid duplication since they're copied from src/assets/data/metrics/
for file in \
src/assets/data/metrics/ds-components-latest.csv \
src/assets/data/metrics/governance-metrics.csv; do
if [ -f "$file" ]; then
git add "$file"
fi
done
if git diff --staged --quiet; then
echo "changes=false" >> $GITHUB_OUTPUT
echo "No changes detected in metrics data"
else
echo "changes=true" >> $GITHUB_OUTPUT
echo "Changes detected in metrics data"
git diff --staged --stat
fi
- name: Create branch and commit changes
if: steps.git-check.outputs.changes == 'true'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
# Use consistent date for branch name and commit message
BRANCH_NAME="metrics-update-${CURRENT_DATE}"
# Create and switch to new branch
git checkout -b "$BRANCH_NAME"
# Count total issues processed
TOTAL_ISSUES=$(jq -r '.summary.total_issues_processed // "unknown"' src/assets/data/metrics/issue-metrics.json)
# Create descriptive commit message
git commit -m "📊 Update metrics dashboard data - ${CURRENT_DATE}
- Updated issue tracking metrics
- Processed ${TOTAL_ISSUES} total issues
- Updated quarterly and monthly aggregations
- Updated experimental design issue tracking
- Updated governance metrics and collaboration cycle data
- Updated imposter component tracking metrics
- Fetched latest ds-components usage data from component-library
🤖 Automated update via GitHub Actions"
# Push the new branch
git push origin "$BRANCH_NAME"
# Store branch name for PR creation
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
- name: Create Pull Request
if: steps.git-check.outputs.changes == 'true'
run: |
# Use consistent date for PR description
CURRENT_TIMESTAMP=$(date -u '+%Y-%m-%d %H:%M UTC')
# Create PR body as a variable
PR_BODY="## Summary
Automated weekly update of metrics dashboard data collected from GitHub issues and component usage.
### Files Updated
- Issue tracking metrics (JSON files)
- Component usage data from component-library
- Experimental design metrics
- Governance metrics and collaboration cycle data
- Imposter component tracking metrics
- Design system component usage CSV data
### Test Plan
- [ ] Verify JSON files are valid
- [ ] Check dashboard displays updated data correctly
- [ ] Confirm no regressions in metric calculations
🤖 Generated with automated workflow - ${CURRENT_TIMESTAMP}"
# Create PR using GitHub CLI
gh pr create \
--title "📊 Update metrics dashboard data - ${CURRENT_DATE}" \
--body "$PR_BODY" \
--head "$BRANCH_NAME" \
--base main
# Store PR URL for summary
PR_URL=$(gh pr view "$BRANCH_NAME" --json url --jq '.url')
echo "PR_URL=$PR_URL" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.VADS_WORKFLOWS }}
- name: Create summary
if: always()
run: |
echo "## 📊 Metrics Update Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ -f "src/assets/data/metrics/issue-metrics.json" ]; then
TOTAL_ISSUES=$(jq -r '.summary.total_issues_processed // "unknown"' src/assets/data/metrics/issue-metrics.json)
OPEN_ISSUES=$(jq -r '.summary.open_issues // "unknown"' src/assets/data/metrics/issue-metrics.json)
CLOSED_MONTH=$(jq -r '.summary.closed_this_month // "unknown"' src/assets/data/metrics/issue-metrics.json)
AVG_RESOLUTION=$(jq -r '.summary.avg_resolution_days // "unknown"' src/assets/data/metrics/issue-metrics.json)
QUARTERS=$(jq -r '.quarterly | length' src/assets/data/metrics/issue-metrics.json)
EXPERIMENTAL_QUARTERS=$(jq -r '.experimental_quarterly | length' src/assets/data/metrics/issue-metrics.json)
echo "### ✅ Issue Metrics Updated Successfully" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Total Issues Processed:** ${TOTAL_ISSUES}" >> $GITHUB_STEP_SUMMARY
echo "- **Currently Open:** ${OPEN_ISSUES}" >> $GITHUB_STEP_SUMMARY
echo "- **Closed This Month:** ${CLOSED_MONTH}" >> $GITHUB_STEP_SUMMARY
echo "- **Average Resolution Time:** ${AVG_RESOLUTION} days" >> $GITHUB_STEP_SUMMARY
echo "- **Quarterly Periods:** ${QUARTERS}" >> $GITHUB_STEP_SUMMARY
echo "- **Experimental Design Quarters:** ${EXPERIMENTAL_QUARTERS}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ steps.git-check.outputs.changes }}" == "true" ]; then
echo "### 🚀 Pull Request Created" >> $GITHUB_STEP_SUMMARY
echo "Updated metrics data has been committed to a new branch and a pull request has been created." >> $GITHUB_STEP_SUMMARY
if [ -n "${PR_URL:-}" ]; then
echo "**PR URL:** $PR_URL" >> $GITHUB_STEP_SUMMARY
fi
else
echo "### ℹ️ No Changes" >> $GITHUB_STEP_SUMMARY
echo "No changes detected - metrics data is up to date." >> $GITHUB_STEP_SUMMARY
fi
else
echo "### ❌ Issue Metrics Update Failed" >> $GITHUB_STEP_SUMMARY
echo "The issue-metrics.json file was not generated successfully." >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 📅 Next Update" >> $GITHUB_STEP_SUMMARY
echo "The next automatic update is scheduled for next Friday at 6 PM UTC (2 PM ET)." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 🔗 Dashboard" >> $GITHUB_STEP_SUMMARY
echo "View the updated metrics at: [design.va.gov/about/metrics/](https://design.va.gov/about/metrics/)" >> $GITHUB_STEP_SUMMARY
- name: Notify on failure
if: failure()
run: |
echo "❌ Metrics update workflow failed"
echo "Check the workflow logs for details"
echo "The dashboard may show stale data until this is resolved"