-
Notifications
You must be signed in to change notification settings - Fork 2
248 lines (214 loc) · 8.39 KB
/
workflow-native.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
name: Workflow - Tests on native
on:
workflow_call:
inputs:
repository:
required: true
type: string
default: 'bevyengine/bevy'
gitref:
required: true
type: string
pixeleagle_project:
required: true
type: string
branch:
required: true
type: string
default: 'main'
per_page:
required: true
type: string
platforms:
required: false
type: string
default: '["ubuntu-22.04", "macos-14"]'
jobs:
split-pages:
name: Prepare pages
runs-on: ubuntu-latest
outputs:
pages: ${{ steps.env.outputs.pages }}
steps:
- name: Checkout Bevy
uses: actions/checkout@v4
with:
repository: ${{ inputs.repository}}
ref: ${{ inputs.gitref }}
- name: Prepare Pages
id: env
run: |
example_count=`cat Cargo.toml | grep '\[\[example\]\]' | wc -l`
page_count=$((example_count / ${{ inputs.per_page }} + 1))
echo "pages=`python -c \"import json; print(json.dumps([i for i in range($page_count)]))\"`" >> $GITHUB_OUTPUT
take-screenshots:
name: Take Screenshots
needs: [split-pages]
runs-on: ${{ matrix.os }}
env:
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
strategy:
matrix:
os: ${{ fromJSON(inputs.platforms) }}
page: ${{ fromJSON(needs.split-pages.outputs.pages) }}
steps:
- name: Checkout Bevy
uses: actions/checkout@v4
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.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 Sentry Reporting
# shell: pwsh
# run: |
# cargo add vleue_sentry --git https://github.com/vleue/vleue_sentry -p bevy_internal --features subcrates --no-default-features
# git apply --ignore-whitespace runner-patches/add_sentry.patch
- 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 || FAILED=true
# retry as it sometimes timeout
if [ $FAILED ]; then
sleep 5
sudo add-apt-repository ppa:kisak/turtle -y || FAILED=true
if [ $FAILED ]; then
sleep 5
sudo add-apt-repository ppa:kisak/turtle -y
fi
fi
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 ${{ inputs.per_page }} run --screenshot-frame 400 --fixed-frame-time 0.0125 --stop-frame 450 --in-ci --ignore-stress-tests --report-details --show-logs
- 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 ${{ inputs.per_page }} run --screenshot-frame 400 --fixed-frame-time 0.0125 --stop-frame 450 --in-ci --ignore-stress-tests --report-details --show-logs
- name: Log errors
shell: pwsh
run: |
if (Get-Content example-showcase-reports/no_screenshots) {
perl -p -e 's/(.*) - [.0-9]*\n/\1, /g' example-showcase-reports/no_screenshots > cleaned
$no_screenshots = Get-Content .\cleaned -Raw
echo "::warning title=No Screenshots ${{ runner.os }}/${{ matrix.page }}::$no_screenshots"
}
if (Get-Content example-showcase-reports/failures) {
perl -p -e 's/(.*) - [.0-9]*\n/\1, /g' example-showcase-reports/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 example-showcase-reports/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: |
example-showcase-reports
send-to-pixel-eagle:
name: Send screenshots to Pixel Eagle
runs-on: macos-14
needs: [take-screenshots]
strategy:
fail-fast: false
matrix:
include:
- os: Linux
- os: macOS
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: |
project="B25A040A-A980-4602-B90C-D480AB84076D"
run=`curl https://pixel-eagle.com/$project/runs --json '{"os":"${{ matrix.os }}", "gitref": "${{ inputs.gitref }}", "branch": "${{ inputs.branch }}"}' | jq '.id'`
SAVEIFS=$IFS
cd screenshots-${{ matrix.os }}
IFS=$'\n'
# Build a json array of screenshots and their hashes
hashes='[';
for screenshot in $(find . -type f -name "*.png");
do
name=${screenshot:2}
echo $name
hash=`shasum -a 256 $screenshot | awk '{print $1}'`
hashes="$hashes [\"$name\",\"$hash\"],"
done
hashes=`echo $hashes | rev | cut -c 2- | rev`
hashes="$hashes]"
IFS=$SAVEIFS
# Upload screenshots with unknown hashes
curl https://pixel-eagle.com/$project/runs/$run/hashes --json "$hashes" | jq '.[]|[.name] | @tsv' |
while IFS=$'\t' read -r name; do
name=`echo $name | tr -d '"'`
echo "Uploading $name"
curl https://pixel-eagle.com/$project/runs/$run/screenshots -F "data=@./$name" -F "screenshot=$name" -H "Authorization: Bearer ${{ secrets.PIXELEAGLE }}"
echo
done
IFS=$SAVEIFS
cd ..
curl https://pixel-eagle.com/$project/runs/$run/compare/auto --json '{"os":"<equal>", "branch": "main"}' | jq '{project_id: .project_id, from: .from, to: .to}' > pixeleagle-${{ matrix.os }}.json
cat pixeleagle-${{ matrix.os }}.json
echo "created run $run"
- name: Upload Pixel Eagle status
uses: actions/upload-artifact@v4
with:
name: pixeleagle-${{ matrix.os }}
path: pixeleagle-${{ matrix.os }}.json