This repository was archived by the owner on Jan 28, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.yml
More file actions
833 lines (735 loc) · 31.1 KB
/
action.yml
File metadata and controls
833 lines (735 loc) · 31.1 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
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
# ───────────────────────────────────────────────────────────────
# GUI-BASED TESTING CODE REVIEW — ENHANCED COMPOSITE ACTION
# ───────────────────────────────────────────────────────────────
name: 'GUI-Based Testing Code Review'
description: 'Playwright GUI tests · ESLint/Prettier · visual dashboard with 3D visualization, visual regression & quick actions'
author: 'Digital Product Innovation and Development – TUM'
branding:
icon: 'eye'
color: 'purple'
# ───────────────────────────────────────────────────────────────
# ▸▸ Inputs
# ───────────────────────────────────────────────────────────────
inputs:
github-token:
description: 'GitHub token (or PAT) for API calls'
required: true
default: ${{ github.token }}
mode:
description: |
full – run lint, tests, dashboard (default)
lint-only – only ESLint/Prettier
test-only – only Playwright
dashboard-only – build dashboard from existing artifacts
required: false
default: 'full'
enable-playwright:
description: 'Run Playwright (overrides mode)'
required: false
default: 'true'
enable-lint:
description: 'Run ESLint / Prettier (overrides mode)'
required: false
default: 'true'
enable-dashboard:
description: 'Generate dashboard / checklist (overrides mode)'
required: false
default: 'true'
enable-pr-comments:
description: 'Post summary comment on pull-requests'
required: false
default: 'true'
enable-visual-comparison:
description: 'Also run Playwright on the main branch and compare'
required: false
default: 'false'
test-files:
description: 'Folder or glob passed to "npx playwright test"'
required: false
default: 'tests'
node-version:
description: 'Node version'
required: false
default: '18'
playwright-config:
description: 'Path to Playwright config'
required: false
default: 'playwright.config.js'
reviewdog-reporter:
description: 'Reviewdog reporter'
required: false
default: 'github-pr-review'
main-branch:
description: 'Main branch for comparison'
required: false
default: 'main'
key-test-file:
description: 'File used to verify checkout'
required: false
default: 'tests/demo-todo-app.spec.ts'
enable-github-pages:
description: 'Deploy dashboard to GitHub Pages'
required: false
default: 'true'
web-report-url:
description: 'Base URL override for dashboard link'
required: false
default: ''
artifacts-retention-days:
description: 'Days to retain artifacts'
required: false
default: '30'
fail-on-test-failure:
description: 'Fail job if Playwright tests fail'
required: false
default: 'false'
extra-npm-dependencies:
description: 'Extra npm packages (space-separated)'
required: false
default: ''
custom-artifacts-path:
description: |
Dashboard-only: folder already containing artifacts.
Must include:
• playwright-summary*.json
• playwright-report/ (HTML & screenshots)
required: false
default: ''
max-test-retries:
description: 'Maximum number of retries for flaky tests'
required: false
default: '2'
enable-3d-visualization:
description: 'Enable 3D Test City visualization'
required: false
default: 'true'
enable-visual-regression:
description: 'Enable visual regression testing for screenshots'
required: false
default: 'true'
enable-test-history:
description: 'Track test history for flakiness detection'
required: false
default: 'true'
# ───────────────────────────────────────────────────────────────
# ▸▸ Outputs (Enhanced with new outputs)
# ───────────────────────────────────────────────────────────────
outputs:
test-results:
description: 'JSON summary of Playwright results'
value: ${{ steps.test-summary.outputs.results }}
visual-artifacts-path:
description: 'Path to generated artifacts'
value: ${{ steps.setup.outputs.artifacts-path }}
dashboard-url:
description: 'Deployed dashboard URL'
value: ${{ steps.deploy-report.outputs.page_url }}
test-pass-rate:
description: 'Playwright pass-rate'
value: ${{ steps.test-summary.outputs.pass-rate }}
total-gui-tests:
description: 'Total Playwright tests executed'
value: ${{ steps.test-summary.outputs.total-tests }}
code-quality-score:
description: 'Overall quality score (lint)'
value: ${{ steps.lint-summary.outputs.quality-score }}
pr-test-results:
description: 'PR-branch Playwright summary'
value: ${{ steps.test-summary.outputs.pr-results }}
main-test-results:
description: 'Main-branch Playwright summary'
value: ${{ steps.test-summary.outputs.main-results }}
visual-comparison:
description: 'Comparison PR vs main'
value: ${{ steps.test-summary.outputs.visual-comparison }}
gui-regression-detected:
description: 'True if regression detected'
value: ${{ steps.test-summary.outputs.regression-detected }}
review-checklist-status:
description: 'Checklist completion status'
value: ${{ steps.checklist.outputs.status }}
has-failures:
description: 'Boolean indicating if any tests failed'
value: ${{ steps.test-summary.outputs.has-failures }}
failure-details:
description: 'JSON array of failed test names'
value: ${{ steps.test-summary.outputs.failure-details }}
execution-time:
description: 'Total execution time in seconds'
value: ${{ steps.timing.outputs.duration }}
performance-metrics:
description: 'JSON object with performance data'
value: ${{ steps.performance.outputs.metrics }}
flaky-tests:
description: 'JSON array of flaky test names'
value: ${{ steps.history.outputs.flaky-tests }}
visual-regression-summary:
description: 'Visual regression test results'
value: ${{ steps.visual-regression.outputs.summary }}
test-city-url:
description: 'URL to 3D Test City visualization'
value: ${{ steps.test-city.outputs.url }}
# ───────────────────────────────────────────────────────────────
# ▸▸ Composite run
# ───────────────────────────────────────────────────────────────
runs:
using: composite
steps:
# 0a - Start timing
- id: timing
name: Start execution timer
shell: bash
run: |
echo "start-time=$(date +%s)" >> $GITHUB_OUTPUT
echo "🏁 Starting Enhanced GUI Test Review at $(date)"
# 0b - derive feature flags
- id: modes
name: Derive feature flags
shell: bash
run: |
play='${{ inputs.enable-playwright }}'
lint='${{ inputs.enable-lint }}'
dash='${{ inputs.enable-dashboard }}'
compare='${{ inputs.enable-visual-comparison }}'
case '${{ inputs.mode }}' in
lint-only) play=false ; dash=false ; compare=false ;;
test-only) lint=false ; dash=false ;;
dashboard-only) play=false ; lint=false ;
esac
echo "playwright=$play" >> $GITHUB_OUTPUT
echo "lint=$lint" >> $GITHUB_OUTPUT
echo "dashboard=$dash" >> $GITHUB_OUTPUT
echo "compare=$compare" >> $GITHUB_OUTPUT
# 1 workspace
- id: setup
name: Prepare workspace
shell: bash
run: |
echo "📁 Creating workspace directories..."
mkdir -p artifacts
echo "artifacts-path=artifacts" >> $GITHUB_OUTPUT
# 1b - Validate inputs early
- name: Validate configuration
shell: bash
run: |
echo "🔍 Validating configuration..."
# Check if tests directory/files exist
if [ ! -d "${{ inputs.test-files }}" ] && ! ls ${{ inputs.test-files }} 2>/dev/null; then
echo "⚠️ Warning: No test files found matching '${{ inputs.test-files }}'"
echo "⚠️ This may cause Playwright tests to fail if mode includes testing"
else
echo "✅ Test files/directory found: ${{ inputs.test-files }}"
fi
# Warn if no package.json
if [ ! -f package.json ]; then
echo "⚠️ Warning: No package.json found. Using defaults for all configurations."
echo "⚠️ Some features may not work as expected without proper dependencies."
else
echo "✅ package.json found"
fi
# Check playwright config
if [ "${{ steps.modes.outputs.playwright }}" == "true" ]; then
if [ ! -f "${{ inputs.playwright-config }}" ]; then
echo "⚠️ Warning: Playwright config not found at '${{ inputs.playwright-config }}'"
echo "⚠️ Will use default configuration"
else
echo "✅ Playwright config found: ${{ inputs.playwright-config }}"
fi
fi
- name: Setup default configs
shell: bash
run: |
# Get action's directory path
ACTION_PATH="${{ github.action_path }}"
# Check and copy Playwright config if missing
if [ ! -f "playwright.config.js" ] && [ ! -f "playwright.config.ts" ]; then
echo "📋 No Playwright config found, using enhanced default..."
cat > playwright.config.js << 'EOF'
const { defineConfig } = require('@playwright/test');
module.exports = defineConfig({
testDir: './tests',
use: {
headless: true,
screenshot: 'only-on-failure', // Important for visual regression
trace: 'on-first-retry',
video: 'off', // Set to 'retain-on-failure' if you want videos
ignoreHTTPSErrors: true,
},
reporter: [
['list'],
['json', { outputFile: 'playwright-metrics.json' }],
['html', { outputFolder: 'playwright-report', open: 'never' }],
],
retries: process.env.CI ? 2 : 0,
});
EOF
fi
# Check and copy ESLint config if missing
if [ ! -f ".eslintrc.json" ] && [ ! -f ".eslintrc.js" ] && [ ! -f "eslint.config.js" ] && [ ! -f "eslint.config.mjs" ]; then
echo "📋 No ESLint config found, using default..."
cp "$ACTION_PATH/.eslintrc.json" ./.eslintrc.json 2>/dev/null || true
fi
# Check and copy Prettier config if missing
if [ ! -f ".prettierrc" ] && [ ! -f ".prettierrc.json" ] && [ ! -f "prettier.config.js" ]; then
echo "📋 No Prettier config found, using default..."
cp "$ACTION_PATH/.prettierrc.json" ./.prettierrc.json 2>/dev/null || true
fi
- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
# 1c - Cache action dependencies
- name: Cache action dependencies
uses: actions/cache@v3
with:
path: |
~/.npm
node_modules
key: ${{ runner.os }}-action-deps-${{ hashFiles('**/package-lock.json', '**/package.json') }}
restore-keys: |
${{ runner.os }}-action-deps-
- name: Install npm dependencies
shell: bash
run: |
echo "📦 Installing dependencies..."
# Install user dependencies if package.json exists
if [ -f package.json ]; then
echo "📦 Installing project dependencies..."
npm ci 2>/dev/null || npm install
fi
# Always install action's required runtime dependencies
echo "📦 Installing action dependencies..."
npm install --no-save marked@15.0.12 @octokit/core@^5.0.0 @mermaid-js/mermaid-cli@10.6.1
# Install any extra user-specified dependencies
if [ -n "${{ inputs.extra-npm-dependencies }}" ]; then
echo "📦 Installing extra dependencies: ${{ inputs.extra-npm-dependencies }}"
npm install --no-save ${{ inputs.extra-npm-dependencies }}
fi
# Create puppeteer config for mermaid-cli
echo '{ "args": ["--no-sandbox", "--disable-setuid-sandbox"] }' > puppeteer.json
# 2 lint
- uses: reviewdog/action-setup@v1
if: steps.modes.outputs.lint == 'true' && github.event_name == 'pull_request'
with:
reviewdog_version: latest
- name: ESLint / Prettier
if: steps.modes.outputs.lint == 'true'
shell: bash
env:
NODE_PATH: ${{ github.workspace }}/node_modules
GITHUB_TOKEN: ${{ inputs.github-token }}
run: |
echo "🎨 Running code quality checks..."
ACTION_PATH="${{ github.action_path }}"
if [ -f "$ACTION_PATH/scripts/lint.js" ]; then
node "$ACTION_PATH/scripts/lint.js"
elif npx --no-install eslint -v &>/dev/null; then
npx eslint .
else
echo 'ℹ️ no lint script'
fi
continue-on-error: true
# 3 ── Playwright on PR branch (with retry logic)
- name: Install Playwright browsers
if: steps.modes.outputs.playwright == 'true'
shell: bash
run: |
echo "🎭 Installing Playwright browsers..."
npx playwright install --with-deps
- name: Run Playwright (PR) with retry
if: steps.modes.outputs.playwright == 'true'
shell: bash
env:
PLAYWRIGHT_CONFIG: ${{ inputs.playwright-config }}
run: |
echo "🧪 Running Playwright tests on PR branch..."
echo "📁 Test files: ${{ inputs.test-files }}"
echo "⏱️ This may take a few minutes..."
MAX_RETRIES=${{ inputs.max-test-retries }}
RETRY_COUNT=0
until npx playwright test "${{ inputs.test-files }}" || [ $RETRY_COUNT -eq $MAX_RETRIES ]; do
RETRY_COUNT=$((RETRY_COUNT+1))
echo "⚠️ Tests failed, retry $RETRY_COUNT of $MAX_RETRIES..."
sleep 5
done
if [ $RETRY_COUNT -eq $MAX_RETRIES ] && [ ! -f playwright-metrics.json ]; then
echo "❌ Tests failed after $MAX_RETRIES retries"
else
echo "✅ PR tests completed!"
fi
continue-on-error: true
- name: Archive Playwright artifacts (PR)
if: steps.modes.outputs.playwright == 'true'
shell: bash
run: |
[ -f playwright-summary.json ] && mv playwright-summary.json artifacts/playwright-summary-pr.json
[ -f playwright-metrics.json ] && mv playwright-metrics.json artifacts/
if [ -d playwright-report ]; then
mkdir -p artifacts/pr-report
mv playwright-report/* artifacts/pr-report/
fi
if [ ! -f artifacts/playwright-summary-pr.json ] && [ -f artifacts/playwright-metrics.json ]; then
jq '
# count helper — walks the whole tree
def count($f): [ .. | objects | select($f) ] | length ;
# derive numbers with portable `as` bindings
( .stats.passed // .stats.passes // .stats.expected
// count(.outcome=="expected" or .status=="passed") ) as $passed
| ( .stats.failed // .stats.failures // .stats.unexpected
// count(.outcome=="unexpected" or .status=="failed") ) as $failed
| ( .stats.skipped // count(.outcome=="skipped" or .status=="skipped") ) as $skipped
| ($passed + $failed + $skipped) as $total
| {
total: $total,
passed: $passed,
failed: $failed,
skipped: $skipped,
duration: (.stats.duration // 0),
pass_rate: ( if $total==0 then 0
else ( ($passed * 100) / $total | floor ) end )
}
' artifacts/playwright-metrics.json > artifacts/playwright-summary-pr.json
fi
# IMPORTANT: Keep a copy of PR metrics before main branch tests
if [ -f artifacts/playwright-metrics.json ]; then
cp artifacts/playwright-metrics.json artifacts/playwright-metrics-pr.json
echo "✅ Preserved PR metrics"
fi
- name: Alias summary for checklist
if: steps.modes.outputs.playwright == 'true'
shell: bash
run: |
cp artifacts/playwright-summary-pr.json artifacts/playwright-summary.json || true
# 3b ── Playwright on main branch with progress indicators
- name: Run Playwright on main
if: steps.modes.outputs.compare == 'true' && steps.modes.outputs.playwright == 'true' && github.event_name == 'pull_request'
shell: bash
env:
PLAYWRIGHT_CONFIG: ${{ inputs.playwright-config }}
run: |
echo "🔄 Fetching main branch for comparison..."
git fetch --quiet origin "${{ inputs.main-branch }}" || true
git checkout origin/${{ inputs.main-branch }} -- tests/ playwright.config.js || true
echo "🧪 Running Playwright tests on main branch..."
echo "⏱️ This helps detect regressions..."
npx playwright test "${{ inputs.test-files }}"
mkdir -p artifacts/main-report
[ -d playwright-report ] && mv playwright-report/* artifacts/main-report/ || true
[ -f playwright-summary.json ] && mv playwright-summary.json artifacts/playwright-summary-main.json || true
[ -f playwright-metrics.json ] && mv playwright-metrics.json artifacts/
if [ ! -f artifacts/playwright-summary-main.json ] && [ -f artifacts/playwright-metrics.json ]; then
jq '
# count helper — walks the whole tree
def count($f): [ .. | objects | select($f) ] | length ;
# derive numbers with portable `as` bindings
( .stats.passed // .stats.passes // .stats.expected
// count(.outcome=="expected" or .status=="passed") ) as $passed
| ( .stats.failed // .stats.failures // .stats.unexpected
// count(.outcome=="unexpected" or .status=="failed") ) as $failed
| ( .stats.skipped // count(.outcome=="skipped" or .status=="skipped") ) as $skipped
| ($passed + $failed + $skipped) as $total
| {
total: $total,
passed: $passed,
failed: $failed,
skipped: $skipped,
duration: (.stats.duration // 0),
pass_rate: ( if $total==0 then 0
else ( ($passed * 100) / $total | floor ) end )
}
' artifacts/playwright-metrics.json > artifacts/playwright-summary-main.json
fi
git checkout HEAD -- tests/ playwright.config.js
echo "✅ Main branch tests completed!"
continue-on-error: true
# 4 external artifacts (dashboard-only)
- name: Import external artifacts
if: inputs.mode == 'dashboard-only'
shell: bash
run: |
SRC='${{ inputs.custom-artifacts-path }}'
if [ "$SRC" != 'artifacts' ] && [ -d "$SRC" ]; then
cp -R "$SRC/." artifacts/
fi
# 5 ensure metrics for flow-chart
- name: Locate metrics JSON
if: steps.modes.outputs.dashboard == 'true'
shell: bash
run: |
M=$(find artifacts -name playwright-metrics.json | head -n1 || true)
[ -n "$M" ] && cp "$M" playwright-metrics.json
# 6 flow-chart
- name: Flow-chart
if: steps.modes.outputs.dashboard == 'true'
shell: bash
env:
NODE_PATH: ${{ github.workspace }}/node_modules
run: |
echo "📊 Generating test flow visualization..."
ACTION_PATH="${{ github.action_path }}"
[ -f "$ACTION_PATH/scripts/generate-flowchart.js" ] && node "$ACTION_PATH/scripts/generate-flowchart.js"
continue-on-error: true
# 7 checklist
- id: checklist
if: steps.modes.outputs.dashboard == 'true'
shell: bash
env:
NODE_PATH: ${{ github.workspace }}/node_modules
run: |
echo "✅ Generating review checklist..."
ACTION_PATH="${{ github.action_path }}"
if [ -f "$ACTION_PATH/scripts/checklist.js" ]; then
node "$ACTION_PATH/scripts/checklist.js"
# Extract checklist status
if [ -f artifacts/checklist.json ]; then
STATUS=$(jq -r '.status // "unknown"' artifacts/checklist.json 2>/dev/null || echo "unknown")
echo "status=$STATUS" >> $GITHUB_OUTPUT
fi
else
echo '{"status":"missing"}' > artifacts/checklist.json
fi
continue-on-error: true
# 7b - Analyze test failures
- name: Analyze test failures
if: steps.modes.outputs.dashboard == 'true'
shell: bash
env:
NODE_PATH: ${{ github.workspace }}/node_modules
run: |
echo "🔍 Analyzing test failure patterns..."
ACTION_PATH="${{ github.action_path }}"
if [ -f "$ACTION_PATH/scripts/analyze-test-failures.js" ]; then
node "$ACTION_PATH/scripts/analyze-test-failures.js"
fi
continue-on-error: true
# ENHANCEMENT: Track test history
- id: history
name: Track Test History
if: inputs.enable-test-history == 'true'
shell: bash
run: |
echo "📈 Tracking test history..."
ACTION_PATH="${{ github.action_path }}"
if [ -f "$ACTION_PATH/scripts/track-test-history.js" ]; then
node "$ACTION_PATH/scripts/track-test-history.js"
# Extract flaky tests
if [ -f artifacts/test-history-insights.json ]; then
FLAKY=$(jq -c '.flakyTests // []' artifacts/test-history-insights.json)
echo "flaky-tests=$FLAKY" >> $GITHUB_OUTPUT
fi
fi
continue-on-error: true
# ENHANCEMENT: Visual regression testing
- id: visual-regression
name: Generate Visual Regression Report
if: steps.modes.outputs.compare == 'true' && steps.modes.outputs.dashboard == 'true' && inputs.enable-visual-regression == 'true'
shell: bash
run: |
echo "🖼️ Analyzing visual differences..."
ACTION_PATH="${{ github.action_path }}"
if [ -f "$ACTION_PATH/scripts/visual-regression.js" ]; then
node "$ACTION_PATH/scripts/visual-regression.js"
# Extract summary
if [ -f artifacts/visual-regression-report.json ]; then
SUMMARY=$(jq -c '{
total: .totalComparisons,
identical: .identical,
changed: (.minor + .major),
new: .new,
removed: .removed
}' artifacts/visual-regression-report.json)
echo "summary=$SUMMARY" >> $GITHUB_OUTPUT
fi
fi
continue-on-error: true
# ENHANCEMENT: Generate Quick Actions Panel
- name: Generate Quick Actions
if: steps.modes.outputs.dashboard == 'true'
shell: bash
env:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_RUN_ID: ${{ github.run-id }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}
GITHUB_EVENT_NAME: ${{ github.event-name }}
run: |
echo "⚡ Generating quick actions panel..."
ACTION_PATH="${{ github.action_path }}"
if [ -f "$ACTION_PATH/scripts/generate-quick-actions.js" ]; then
node "$ACTION_PATH/scripts/generate-quick-actions.js"
fi
continue-on-error: true
# ENHANCEMENT: Generate 3D Test City
- id: test-city
name: Generate 3D Test City Visualization
if: steps.modes.outputs.dashboard == 'true' && inputs.enable-3d-visualization == 'true'
shell: bash
run: |
echo "🏙️ Generating 3D Test City visualization..."
ACTION_PATH="${{ github.action_path }}"
if [ -f "$ACTION_PATH/scripts/generate-test-city-3d.js" ]; then
node "$ACTION_PATH/scripts/generate-test-city-3d.js"
echo "url=test-city-3d.html" >> $GITHUB_OUTPUT
fi
continue-on-error: true
# 8 dashboard HTML with performance metrics
- id: dashboard
name: Build dashboard HTML
if: steps.modes.outputs.dashboard == 'true'
shell: bash
env:
NODE_PATH: ${{ github.workspace }}/node_modules
ACTION_START_TIME: ${{ steps.timing.outputs.start-time }}
run: |
echo "🎨 Building interactive dashboard..."
ACTION_PATH="${{ github.action_path }}"
# Export timing for performance metrics
export DASHBOARD_GEN_START=$(date +%s%N)
[ -f "$ACTION_PATH/scripts/generate-webpage.js" ] && node "$ACTION_PATH/scripts/generate-webpage.js"
# Enhance with new features
if [ -f "$ACTION_PATH/scripts/generate-enhanced-webpage.js" ]; then
node "$ACTION_PATH/scripts/generate-enhanced-webpage.js"
fi
continue-on-error: true
# 8b - Collect performance metrics
- id: performance
name: Collect performance metrics
if: steps.modes.outputs.dashboard == 'true'
shell: bash
run: |
END_TIME=$(date +%s)
START_TIME=${{ steps.timing.outputs.start-time }}
DURATION=$((END_TIME - START_TIME))
# Calculate artifact sizes
TOTAL_SIZE=0
if [ -d artifacts ]; then
TOTAL_SIZE=$(du -sb artifacts | cut -f1 | awk '{print $1/1048576}')
fi
# Create performance metrics JSON
cat > artifacts/performance-metrics.json <<EOF
{
"executionTime": $DURATION,
"artifactSizeMB": $TOTAL_SIZE,
"timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
}
EOF
echo "metrics=$(cat artifacts/performance-metrics.json | jq -c .)" >> $GITHUB_OUTPUT
# 9 upload Pages artifact & deploy
- uses: actions/upload-pages-artifact@v3
if: steps.modes.outputs.dashboard == 'true' && inputs.enable-github-pages == 'true'
with:
name: gui-test-visual-artifacts
path: artifacts/web-report
- id: deploy-report
name: Deploy to GitHub Pages
if: steps.modes.outputs.dashboard == 'true' && inputs.enable-github-pages == 'true'
uses: actions/deploy-pages@v4
with:
artifact_name: gui-test-visual-artifacts
continue-on-error: true
# 10 - Add test summary output to GitHub Actions
- name: Output test summary
if: steps.modes.outputs.playwright == 'true'
shell: bash
run: |
if [ -f artifacts/playwright-summary-pr.json ]; then
echo "## 🧪 Test Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Metric | Value |" >> $GITHUB_STEP_SUMMARY
echo "|--------|-------|" >> $GITHUB_STEP_SUMMARY
# Parse JSON and create summary
jq -r '. | "| Total Tests | \(.total) |\n| ✅ Passed | \(.passed) |\n| ❌ Failed | \(.failed) |\n| ⏭️ Skipped | \(.skipped) |\n| 📊 Pass Rate | \(.pass_rate)% |\n| ⏱️ Duration | \(.duration)ms |"' artifacts/playwright-summary-pr.json >> $GITHUB_STEP_SUMMARY
# Add link to dashboard if available
if [ "${{ steps.deploy-report.outputs.page_url }}" != "" ]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 🔗 Enhanced Features" >> $GITHUB_STEP_SUMMARY
echo "- [📊 Full Dashboard](${{ steps.deploy-report.outputs.page_url }})" >> $GITHUB_STEP_SUMMARY
echo "- [🏙️ 3D Test City](${{ steps.deploy-report.outputs.page_url }}test-city-3d.html)" >> $GITHUB_STEP_SUMMARY
echo "- [🖼️ Visual Regression](${{ steps.deploy-report.outputs.page_url }}#visual-regression)" >> $GITHUB_STEP_SUMMARY
echo "- [⚡ Quick Actions](${{ steps.deploy-report.outputs.page_url }}#quick-actions)" >> $GITHUB_STEP_SUMMARY
fi
fi
# 10b - Calculate test summary outputs
- id: test-summary
name: Calculate test summary outputs
if: steps.modes.outputs.playwright == 'true' || inputs.mode == 'dashboard-only'
shell: bash
run: |
# Read PR summary
if [ -f artifacts/playwright-summary-pr.json ]; then
PR_RESULTS=$(cat artifacts/playwright-summary-pr.json | jq -c .)
TOTAL=$(echo "$PR_RESULTS" | jq -r '.total // 0')
PASSED=$(echo "$PR_RESULTS" | jq -r '.passed // 0')
FAILED=$(echo "$PR_RESULTS" | jq -r '.failed // 0')
PASS_RATE=$(echo "$PR_RESULTS" | jq -r '.pass_rate // 0')
echo "results=$PR_RESULTS" >> $GITHUB_OUTPUT
echo "pr-results=$PR_RESULTS" >> $GITHUB_OUTPUT
echo "total-tests=$TOTAL" >> $GITHUB_OUTPUT
echo "pass-rate=$PASS_RATE" >> $GITHUB_OUTPUT
echo "has-failures=$([[ $FAILED -gt 0 ]] && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
# Extract failed test names if any
if [ -f artifacts/playwright-metrics.json ] && [ $FAILED -gt 0 ]; then
FAILED_TESTS=$(jq -c '[.. | objects | select(.status == "failed" or .outcome == "unexpected") | .title // .name // "Unknown test"] | unique' artifacts/playwright-metrics.json 2>/dev/null || echo '[]')
echo "failure-details=$FAILED_TESTS" >> $GITHUB_OUTPUT
else
echo "failure-details=[]" >> $GITHUB_OUTPUT
fi
fi
# Read main summary if exists
if [ -f artifacts/playwright-summary-main.json ]; then
MAIN_RESULTS=$(cat artifacts/playwright-summary-main.json | jq -c .)
echo "main-results=$MAIN_RESULTS" >> $GITHUB_OUTPUT
# Calculate regression
if [ -f artifacts/playwright-summary-pr.json ]; then
PR_FAILED=$(echo "$PR_RESULTS" | jq -r '.failed // 0')
MAIN_FAILED=$(echo "$MAIN_RESULTS" | jq -r '.failed // 0')
echo "regression-detected=$([[ $PR_FAILED -gt $MAIN_FAILED ]] && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
fi
fi
# 11 PR comment (enhanced)
- name: PR summary comment
if: steps.modes.outputs.dashboard == 'true' &&
inputs.enable-pr-comments == 'true' &&
github.event_name == 'pull_request'
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.github-token }}
WEB_REPORT_URL: ${{ inputs.web-report-url || steps.deploy-report.outputs.page_url }}
NODE_PATH: ${{ github.workspace }}/node_modules
run: |
echo "💬 Posting enhanced summary comment to PR..."
ACTION_PATH="${{ github.action_path }}"
[ -f "$ACTION_PATH/scripts/summary-comment.js" ] && node "$ACTION_PATH/scripts/summary-comment.js"
continue-on-error: true
# 12 - Calculate final timing
- name: Calculate execution time
id: timing-final
shell: bash
run: |
END_TIME=$(date +%s)
START_TIME=${{ steps.timing.outputs.start-time }}
DURATION=$((END_TIME - START_TIME))
echo "duration=$DURATION" >> $GITHUB_OUTPUT
echo "⏱️ Total execution time: ${DURATION}s"
# 13 - Finish with better messaging
- name: Finish
shell: bash
run: |
echo '✅ Enhanced GUI-Based Testing Code Review completed!'
# Provide helpful summary based on results
if [ -f artifacts/playwright-summary-pr.json ]; then
FAILED=$(jq -r '.failed // 0' artifacts/playwright-summary-pr.json)
if [ "$FAILED" -gt "0" ]; then
echo "❌ $FAILED test(s) failed. Check the dashboard for details."
else
echo "✅ All tests passed!"
fi
fi
if [ "${{ steps.deploy-report.outputs.page_url }}" != "" ]; then
echo "📊 Dashboard: ${{ steps.deploy-report.outputs.page_url }}"
echo "🏙️ Test City: ${{ steps.deploy-report.outputs.page_url }}/test-city-3d.html"
fi
echo "✨ New features available:"
echo " - 3D Test City visualization"
echo " - Visual regression testing"
echo " - Quick actions panel"
echo " - Test history tracking"