-
Notifications
You must be signed in to change notification settings - Fork 2
565 lines (488 loc) · 22.2 KB
/
example-report.yml
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
name: Example report - Status and Screenshots
on:
workflow_dispatch:
schedule:
- cron: '0 6,18 * * *'
concurrency:
group: ${{ github.repository }}-example-report
env:
PER_PAGE: 20
jobs:
get-environment:
name: Get Environment
runs-on: ubuntu-latest
outputs:
pages: ${{ steps.env.outputs.pages }}
gitref: ${{ steps.env.outputs.gitref }}
date: ${{ steps.env.outputs.date }}
linux_percy_project: ${{ steps.env.outputs.linux_percy_project }}
windows_percy_project: ${{ steps.env.outputs.windows_percy_project }}
macos_percy_project: ${{ steps.env.outputs.macos_percy_project }}
mobile_percy_project: ${{ steps.env.outputs.mobile_percy_project }}
mobile_nonce: ${{ steps.env.outputs.mobile_nonce }}
updated: ${{ steps.version-check.outputs.updated }}
steps:
- name: Checkout Bevy main branch
uses: actions/checkout@v4
with:
repository: 'bevyengine/bevy'
ref: 'main'
- name: Get Environment
id: env
run: |
example_count=`cat Cargo.toml | grep '\[\[example\]\]' | wc -l`
page_count=$((example_count / ${{ env.PER_PAGE }} + 1))
echo "gitref=`git rev-parse HEAD`" >> $GITHUB_OUTPUT
echo "date=`date +%Y%m%d%H%M`" >> $GITHUB_OUTPUT
echo "linux_percy_project=dede4209/Screenshots-Linux-Vulkan" >> $GITHUB_OUTPUT
echo "windows_percy_project=dede4209/Screenshots-Windows-DX12" >> $GITHUB_OUTPUT
echo "macos_percy_project=dede4209/Screenshots-macOS-Metal" >> $GITHUB_OUTPUT
echo "mobile_percy_project=dede4209/Bevy-Mobile-Example" >> $GITHUB_OUTPUT
echo "pages=`python -c \"import json; print(json.dumps([i for i in range($page_count)]))\"`" >> $GITHUB_OUTPUT
echo "mobile_nonce=${{ github.run_id }}-$(date +%s)" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
ref: 'results'
path: 'results'
- name: Check if current Bevy version already ran
id: version-check
run: |
gitref=`git rev-parse HEAD`
updated=`if ls results/*-$gitref 1> /dev/null 2>&1; then echo "false"; else echo "true"; fi`
echo "updated=$updated" >> $GITHUB_OUTPUT
take-screenshots:
name: Take Screenshots
needs: get-environment
if: needs.get-environment.outputs.updated == 'true' || github.event_name == 'workflow_dispatch'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-14]
page: ${{ fromJSON(needs.get-environment.outputs.pages) }}
steps:
- name: Checkout Bevy main branch
uses: actions/checkout@v4
with:
repository: 'bevyengine/bevy'
ref: ${{ needs.get-environment.outputs.gitref }}
- name: Checkout patches
uses: actions/checkout@v4
with:
path: 'runner-patches'
- name: Apply patches
shell: pwsh
run: |
Get-ChildItem "runner-patches/patches" -Filter *.patch |
Foreach-Object {
Write-Output "Processing $($_.FullName)"
git apply --ignore-whitespace $($_.FullName)
}
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Install Bevy dependencies
if: runner.os == 'linux'
run: |
sudo apt-get update;
DEBIAN_FRONTEND=noninteractive sudo apt-get install --no-install-recommends -yq \
libasound2-dev libudev-dev libxkbcommon-x11-0;
- name: install xvfb, llvmpipe and lavapipe
if: runner.os == 'linux'
run: |
sudo apt-get update -y -qq
sudo add-apt-repository ppa:kisak/turtle -y
sudo apt-get update
sudo apt install -y xvfb libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
- uses: actions/cache/restore@v4
id: restore-cache
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Take Screenshots (Linux)
id: screenshots-linux
if: runner.os == 'linux'
continue-on-error: true
run: xvfb-run -s "-screen 0 1280x1024x24" cargo run -p example-showcase -- --page ${{ matrix.page }} --per-page ${{ env.PER_PAGE }} run --screenshot-at 250 --frame-duration 0.02 --stop-at 350 --in-ci --ignore-stress-tests --report-details
- name: Take Screenshots (Windows)
id: screenshots-windows
if: runner.os == 'windows'
continue-on-error: true
shell: pwsh
run: |
Add-Type -AssemblyName System.Windows.Forms
$screen = [System.Windows.Forms.SystemInformation]::VirtualScreen
[Windows.Forms.Cursor]::Position = "$($screen.Width / 2),$($screen.Height / 2)"
cargo run -p example-showcase -- --page ${{ matrix.page }} --per-page ${{ env.PER_PAGE }} run --screenshot-at 250 --frame-duration 0.02 --stop-at 350 --in-ci --ignore-stress-tests --report-details
- name: Take Screenshots (macOS)
id: screenshots-macos
if: runner.os == 'macos'
continue-on-error: true
run: cargo run -p example-showcase -- --page ${{ matrix.page }} --per-page ${{ env.PER_PAGE }} run --screenshot-at 250 --frame-duration 0.02 --stop-at 350 --in-ci --ignore-stress-tests --report-details
- name: Log errors
shell: pwsh
run: |
if (Get-Content no_screenshots) {
perl -p -e 's/(.*) - [.0-9]*\n/\1, /g' no_screenshots > cleaned
$no_screenshots = Get-Content .\cleaned -Raw
echo "::warning title=No Screenshots ${{ runner.os }}/${{ matrix.page }}::$no_screenshots"
}
if (Get-Content failures) {
perl -p -e 's/(.*) - [.0-9]*\n/\1, /g' failures > cleaned
$failures = Get-Content .\cleaned -Raw
echo "::error title=Failed To Run ${{ runner.os }}/${{ matrix.page }}::$failures"
}
- name: Outputs run results
id: run-results
shell: pwsh
run: |
echo "has_success=$(![String]::IsNullOrWhiteSpace((Get-content successes)))" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
- name: Upload Screenshots
uses: actions/upload-artifact@v4
with:
name: screenshots-${{ runner.os }}-${{ matrix.page }}
path: screenshots
- name: Upload Status
uses: actions/upload-artifact@v4
with:
name: status-${{ runner.os }}-${{ matrix.page }}
path: |
successes
failures
no_screenshots
send-to-percy:
name: Send screenshots to Percy
runs-on: ubuntu-latest
needs: [take-screenshots, get-environment]
strategy:
fail-fast: false
matrix:
include:
- os: Linux
percy_key: PERCY_TOKEN_LINUX_VULKAN
percy_project: ${{ needs.get-environment.outputs.linux_percy_project }}
- os: Windows
percy_key: PERCY_TOKEN_WINDOWS_DX12
percy_project: ${{ needs.get-environment.outputs.windows_percy_project }}
- os: macOS
percy_key: PERCY_TOKEN_MACOS_METAL
percy_project: ${{ needs.get-environment.outputs.macos_percy_project }}
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: screenshots-${{ matrix.os }}-*
- name: Move examples to the correct folder
id: gather-examples
continue-on-error: true
run: |
mkdir screenshots-${{ matrix.os }}
for screenshotfolder in screenshots-${{ matrix.os }}-*
do
echo $screenshotfolder
rsync --verbose --archive $screenshotfolder/* screenshots-${{ matrix.os }}/
rm -rf $screenshotfolder
done
- name: Remove images that are all black
if: steps.gather-examples.outcome == 'success'
run: |
set +e
sudo apt install -y imagemagick
for image in screenshots-${{ matrix.os }}/*/*.png
do
mean=`convert "$image" -format "%[mean]" info:`
if [[ "$?" = "1" ]]; then
echo "Error reading $image"
rm "$image"
fi
if [ "$mean" = 0 ]; then
echo "$image is all black"
rm "$image"
fi
done
- name: Remove example known to be random
if: steps.gather-examples.outcome == 'success'
run: |
rm "screenshots-${{ matrix.os }}/Animation/animated_fox.png" || true
rm "screenshots-${{ matrix.os }}/Animation/morph_targets.png" || true
rm "screenshots-${{ matrix.os }}/Async Tasks/async_compute.png" || true
rm "screenshots-${{ matrix.os }}/Async Tasks/external_source_external_thread.png" || true
rm "screenshots-${{ matrix.os }}/Games/alien_cake_addict.png" || true
rm "screenshots-${{ matrix.os }}/Games/contributors.png" || true
rm "screenshots-${{ matrix.os }}/UI (User Interface)/font_atlas_debug.png" || true
rm "screenshots-${{ matrix.os }}/Shaders/compute_shader_game_of_life.png" || true
- name: Send to Percy
if: steps.gather-examples.outcome == 'success'
run: |
npm install -g @percy/cli@latest
npx percy upload screenshots-${{ matrix.os }}
env:
PERCY_TOKEN: ${{ secrets[matrix.percy_key] }}
PERCY_COMMIT: ${{ needs.get-environment.outputs.gitref }}
- name: Wait for result
if: steps.gather-examples.outcome == 'success'
run: |
npx percy build:wait --project ${{ matrix.percy_project }} --commit ${{ needs.get-environment.outputs.gitref }}
env:
PERCY_TOKEN: ${{ secrets[matrix.percy_key] }}
update-results:
name: Update Results
runs-on: ubuntu-latest
needs: [send-to-percy, get-environment, mobile-run]
if: always() && (needs.get-environment.outputs.updated == 'true' || github.event_name == 'workflow_dispatch')
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: 'results'
path: 'results'
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: status-*
- name: Concatenate status
run: |
set -x
mkdir results/${{ needs.get-environment.outputs.date }}-${{ needs.get-environment.outputs.gitref }}
for report in status-Linux-*
do
(cat $report/successes; echo) >> Linux-successes-concat
(cat $report/failures; echo) >> Linux-failures-concat
(cat $report/no_screenshots; echo) >> Linux-no_screenshots-concat
done
# remove empty lines
grep . Linux-successes-concat > results/${{ needs.get-environment.outputs.date }}-${{ needs.get-environment.outputs.gitref }}/Linux-successes || true
grep . Linux-failures-concat > results/${{ needs.get-environment.outputs.date }}-${{ needs.get-environment.outputs.gitref }}/Linux-failures || true
grep . Linux-no_screenshots-concat > results/${{ needs.get-environment.outputs.date }}-${{ needs.get-environment.outputs.gitref }}/Linux-no_screenshots || true
for report in status-Windows-*
do
(cat $report/successes; echo) >> Windows-successes-concat
(cat $report/failures; echo) >> Windows-failures-concat
(cat $report/no_screenshots; echo) >> Windows-no_screenshots-concat
done
# remove empty lines
grep . Windows-successes-concat > results/${{ needs.get-environment.outputs.date }}-${{ needs.get-environment.outputs.gitref }}/Windows-successes || true
grep . Windows-failures-concat > results/${{ needs.get-environment.outputs.date }}-${{ needs.get-environment.outputs.gitref }}/Windows-failures || true
grep . Windows-no_screenshots-concat > results/${{ needs.get-environment.outputs.date }}-${{ needs.get-environment.outputs.gitref }}/Windows-no_screenshots || true
for report in status-macOS-*
do
(cat $report/successes; echo) >> macOS-successes-concat
(cat $report/failures; echo) >> macOS-failures-concat
(cat $report/no_screenshots; echo) >> macOS-no_screenshots-concat
done
# remove empty lines
grep . macOS-successes-concat > results/${{ needs.get-environment.outputs.date }}-${{ needs.get-environment.outputs.gitref }}/macOS-successes || true
grep . macOS-failures-concat > results/${{ needs.get-environment.outputs.date }}-${{ needs.get-environment.outputs.gitref }}/macOS-failures || true
grep . macOS-no_screenshots-concat > results/${{ needs.get-environment.outputs.date }}-${{ needs.get-environment.outputs.gitref }}/macOS-no_screenshots || true
- name: Save Percy results
run: |
curl 'https://percy.io/api/v1/projects/${{ needs.get-environment.outputs.windows_percy_project }}/builds?filter\[sha\]=${{ needs.get-environment.outputs.gitref }}' | jq '.data[0].attributes' > results/${{ needs.get-environment.outputs.date }}-${{ needs.get-environment.outputs.gitref }}/Windows-percy
curl 'https://percy.io/api/v1/projects/${{ needs.get-environment.outputs.linux_percy_project }}/builds?filter\[sha\]=${{ needs.get-environment.outputs.gitref }}' | jq '.data[0].attributes' > results/${{ needs.get-environment.outputs.date }}-${{ needs.get-environment.outputs.gitref }}/Linux-percy
curl 'https://percy.io/api/v1/projects/${{ needs.get-environment.outputs.macos_percy_project }}/builds?filter\[sha\]=${{ needs.get-environment.outputs.gitref }}' | jq '.data[0].attributes' > results/${{ needs.get-environment.outputs.date }}-${{ needs.get-environment.outputs.gitref }}/macOS-percy
curl 'https://percy.io/api/v1/projects/${{ needs.get-environment.outputs.mobile_percy_project }}/builds?filter\[sha\]=${{ needs.get-environment.outputs.gitref }}' | jq '.data[0].attributes' > results/${{ needs.get-environment.outputs.date }}-${{ needs.get-environment.outputs.gitref }}/mobile-percy
- name: Store results in git
run: |
cd results
git config user.name 'Workflow'
git config user.email '<>'
git add .
git commit -m "Update Results"
git push
- name: Upload Aggregated Status
uses: actions/upload-artifact@v4
with:
name: aggregated-status
path: |
results/${{ needs.get-environment.outputs.date }}-${{ needs.get-environment.outputs.gitref }}
rerun-failed-examples:
name: Rerun Failed Examples (without screenshot)
needs: [get-environment, update-results]
if: always() && (needs.get-environment.outputs.updated == 'true' || github.event_name == 'workflow_dispatch')
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-14]
steps:
- name: Checkout Bevy main branch
uses: actions/checkout@v4
with:
repository: 'bevyengine/bevy'
ref: ${{ needs.get-environment.outputs.gitref }}
- name: Checkout patches
uses: actions/checkout@v4
with:
path: 'runner-patches'
- name: Apply patches
shell: pwsh
run: |
Get-ChildItem "runner-patches/patches" -Filter *.patch |
Foreach-Object {
Write-Output "Processing $($_.FullName)"
git apply --ignore-whitespace $($_.FullName)
}
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Download Aggregated Status
uses: actions/download-artifact@v4
with:
name: aggregated-status
path: aggregated-status
- name: Clean Up failures list
run: |
sed 's/.*\/\(.*\) - [.0-9]*/\1/g' aggregated-status/${{ runner.os }}-failures > failure-list
- name: Install Bevy dependencies
if: runner.os == 'linux'
run: |
sudo apt-get update;
DEBIAN_FRONTEND=noninteractive sudo apt-get install --no-install-recommends -yq \
libasound2-dev libudev-dev;
- name: install xvfb, llvmpipe and lavapipe
if: runner.os == 'linux'
run: |
sudo apt-get update -y -qq
sudo add-apt-repository ppa:kisak/turtle -y
sudo apt-get update
sudo apt install -y xvfb libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
- uses: actions/cache/restore@v4
id: restore-cache
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Take Screenshots (Linux)
if: runner.os == 'linux'
continue-on-error: true
run: xvfb-run -s "-screen 0 1280x1024x24" cargo run -p example-showcase -- run --screenshot-at 0 --frame-duration 0.02 --stop-at 200 --in-ci --ignore-stress-tests --report-details --example-list failure-list
- name: Take Screenshots (Windows)
if: runner.os == 'windows'
continue-on-error: true
run: cargo run -p example-showcase -- run --screenshot-at 0 --frame-duration 0.02 --stop-at 200 --in-ci --ignore-stress-tests --report-details --example-list failure-list
- name: Take Screenshots (macOS)
if: runner.os == 'macos'
continue-on-error: true
run: cargo run -p example-showcase -- run --screenshot-at 0 --frame-duration 0.02 --stop-at 200 --in-ci --ignore-stress-tests --report-details --example-list failure-list
- name: Upload Rerun Status
uses: actions/upload-artifact@v4
with:
name: status-rerun-${{ runner.os }}
path: |
successes
failures
no_screenshots
*.log
update-results-with-rerun:
name: Update Results with Rerun
needs: [rerun-failed-examples, get-environment]
if: always() && (needs.get-environment.outputs.updated == 'true' || github.event_name == 'workflow_dispatch')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: 'results'
path: 'results'
- name: Download Rerun Status on Linux
uses: actions/download-artifact@v4
with:
name: status-rerun-Linux
path: status-rerun-Linux
- name: Download Rerun Status on Windows
uses: actions/download-artifact@v4
with:
name: status-rerun-Windows
path: status-rerun-Windows
- name: Download Rerun Status on macOS
uses: actions/download-artifact@v4
with:
name: status-rerun-macOS
path: status-rerun-macOS
- name: Store results in git
run: |
mv status-rerun-Windows results/${{ needs.get-environment.outputs.date }}-${{ needs.get-environment.outputs.gitref }}/
mv status-rerun-Linux results/${{ needs.get-environment.outputs.date }}-${{ needs.get-environment.outputs.gitref }}/
mv status-rerun-macOS results/${{ needs.get-environment.outputs.date }}-${{ needs.get-environment.outputs.gitref }}/
cd results
git config user.name 'Workflow'
git config user.email '<>'
git add .
git commit -m "Update Results"
git push
update-website:
name: Update Website
needs: [update-results-with-rerun, get-environment]
if: always() && (needs.get-environment.outputs.updated == 'true' || github.event_name == 'workflow_dispatch')
uses: ./.github/workflows/rebuild-website.yml
permissions:
contents: read
pages: write
id-token: write
mobile-run:
needs: [get-environment]
if: needs.get-environment.outputs.updated == 'true' || github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/workflow-mobile.yml
with:
gitref: ${{ needs.get-environment.outputs.gitref }}
nonce: ${{ needs.get-environment.outputs.mobile_nonce }}
mobile_percy_project: ${{ needs.get-environment.outputs.mobile_percy_project }}
secrets: inherit
send-to-pixel-eagle:
name: Send screenshots to Pixel Eagle
runs-on: macos-14
needs: [take-screenshots, get-environment]
strategy:
fail-fast: false
matrix:
include:
- os: Linux
- os: macOS
- os: Windows
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: screenshots-${{ matrix.os }}-*
- name: Move examples to the correct folder
id: gather-examples
continue-on-error: true
run: |
mkdir screenshots-${{ matrix.os }}
for screenshotfolder in screenshots-${{ matrix.os }}-*
do
echo $screenshotfolder
rsync --verbose --archive $screenshotfolder/* screenshots-${{ matrix.os }}/
rm -rf $screenshotfolder
done
- name: Send to Pixel Eagle
if: steps.gather-examples.outcome == 'success'
run: |
uuid="B25A040A-A980-4602-B90C-D480AB84076D"
id=`curl https://pixel-eagle.vleue.com/$uuid/runs --json '{"os":"${{ matrix.os }}", "gitref": "${{ needs.get-environment.outputs.gitref }}"}' | jq '.id'`
SAVEIFS=$IFS
IFS=$'\n'
cd screenshots-${{ matrix.os }}
for screenshot in $(find . -type f -name "*.png");
do
name=${screenshot:2}
echo $name
sha=`shasum -a 256 $screenshot | awk '{print $1}'`
to_upload=`curl https://pixel-eagle.vleue.com/$uuid/runs/$id/hashes --json "[ [\"$name\", \"$sha\"] ]" | jq '. | length'`
if [ $to_upload -eq 1 ]; then
echo " uploading $screenshot"
curl https://pixel-eagle.vleue.com/$uuid/runs/$id/screenshots -F "data=@$screenshot" -F "screenshot=$name"
else
echo " skipping $screenshot"
fi
done
echo "created run $id"
IFS=$SAVEIFS