Skip to content

Commit 31766bd

Browse files
authored
rely on Pixel Eagle for mobile (#139)
* format * linter * common project for Pixel Eagle * fix reference to run id * check for screenshots in correct folder * prettier name * quote name * keep mobile common pixel eagle result * remove individual pixel eagle uploads * pixel eagle for mobile in report * format
1 parent f778753 commit 31766bd

File tree

4 files changed

+130
-79
lines changed

4 files changed

+130
-79
lines changed

.github/workflows/report-main.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Example report - main
33
on:
44
workflow_dispatch:
55
schedule:
6-
- cron: '0 */3 * * *'
6+
- cron: "0 */3 * * *"
77

88
concurrency:
99
group: ${{ github.repository }}-example-report
@@ -26,8 +26,8 @@ jobs:
2626
- name: Checkout Bevy main branch
2727
uses: actions/checkout@v4
2828
with:
29-
repository: 'bevyengine/bevy'
30-
ref: 'main'
29+
repository: "bevyengine/bevy"
30+
ref: "main"
3131
- name: Get Environment
3232
id: env
3333
run: |
@@ -37,8 +37,8 @@ jobs:
3737
echo "mobile_percy_project=dede4209/Bevy-Mobile-Example" >> $GITHUB_OUTPUT
3838
- uses: actions/checkout@v4
3939
with:
40-
ref: 'results'
41-
path: 'results'
40+
ref: "results"
41+
path: "results"
4242
- name: Check if current Bevy version already ran
4343
id: version-check
4444
run: |
@@ -58,7 +58,7 @@ jobs:
5858
repository: "bevyengine/bevy"
5959
per_page: "${{ needs.get-environment.outputs.per_page }}"
6060
secrets: inherit
61-
61+
6262
mobile-run:
6363
name: Mobile
6464
needs: [get-environment]
@@ -92,11 +92,10 @@ jobs:
9292
permissions:
9393
contents: write
9494
steps:
95-
9695
- uses: actions/checkout@v4
9796
with:
98-
ref: 'results'
99-
path: 'results'
97+
ref: "results"
98+
path: "results"
10099

101100
- name: Download all status artifacts
102101
uses: actions/download-artifact@v4
@@ -156,6 +155,7 @@ jobs:
156155
mv pixeleagle-Linux/pixeleagle-Linux.json results/${{ needs.get-environment.outputs.date }}-${{ needs.get-environment.outputs.gitref }}/Linux-pixeleagle
157156
mv pixeleagle-macOS/pixeleagle-macOS.json results/${{ needs.get-environment.outputs.date }}-${{ needs.get-environment.outputs.gitref }}/macOS-pixeleagle
158157
mv pixeleagle-Windows/pixeleagle-Windows.json results/${{ needs.get-environment.outputs.date }}-${{ needs.get-environment.outputs.gitref }}/Windows-pixeleagle
158+
mv pixeleagle-mobile/pixeleagle-mobile.json results/${{ needs.get-environment.outputs.date }}-${{ needs.get-environment.outputs.gitref }}/mobile-pixeleagle
159159
160160
- name: Store results in git
161161
run: |

.github/workflows/workflow-mobile.yml

Lines changed: 61 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ on:
66
repository:
77
required: true
88
type: string
9-
default: 'bevyengine/bevy'
9+
default: "bevyengine/bevy"
1010
gitref:
1111
required: true
1212
type: string
13-
default: 'main'
13+
default: "main"
1414
mobile_percy_project:
1515
required: false
1616
type: string
@@ -25,23 +25,39 @@ on:
2525
repository:
2626
required: true
2727
type: string
28-
default: 'bevyengine/bevy'
28+
default: "bevyengine/bevy"
29+
description: "Bevy repository to use"
2930
gitref:
3031
required: true
3132
type: string
32-
default: 'main'
33+
default: "main"
34+
description: "Commit or branch name to run on"
3335
mobile_percy_project:
3436
required: false
3537
type: string
38+
description: "Percy project to send results to"
3639
pixeleagle_project:
3740
required: true
3841
type: string
39-
default: 'B25A040A-A980-4602-B90C-D480AB84076D'
42+
default: "B25A040A-A980-4602-B90C-D480AB84076D"
43+
description: "Pixel Eagle project to send results to"
4044
branch:
4145
required: true
4246
type: string
47+
description: "Branch name to use as a tag in Pixel Eagle"
4348

4449
jobs:
50+
create-pixel-eagle-run:
51+
runs-on: ubuntu-latest
52+
outputs:
53+
pixeleagle_run: ${{ steps.run.outputs.pixeleagle_run }}
54+
steps:
55+
- name: Create Run
56+
id: run
57+
run: |
58+
run=`curl https://pixel-eagle.com/${{ inputs.pixeleagle_project }}/runs -H 'Content-Type: application/json' -d '{"os":"mobile", "gitref": "${{ inputs.gitref }}", "branch": "${{ inputs.branch }}"}' --oauth2-bearer ${{ secrets.PIXELEAGLE }} | jq '.id'`
59+
echo "pixeleagle_run=$run" >> $GITHUB_OUTPUT
60+
4561
build-for-iOS:
4662
runs-on: macos-latest
4763
timeout-minutes: 30
@@ -54,17 +70,17 @@ jobs:
5470
- name: Checkout patches
5571
uses: actions/checkout@v4
5672
with:
57-
path: 'runner-patches'
58-
73+
path: "runner-patches"
74+
5975
- name: Apply patches
6076
shell: pwsh
6177
run: |
62-
Get-ChildItem "runner-patches/patches" -Filter *.patch |
78+
Get-ChildItem "runner-patches/patches" -Filter *.patch |
6379
Foreach-Object {
6480
Write-Output "Processing $($_.FullName)"
6581
git apply --ignore-whitespace $($_.FullName)
6682
}
67-
83+
6884
- uses: dtolnay/rust-toolchain@stable
6985

7086
- name: Add iOS targets
@@ -104,12 +120,12 @@ jobs:
104120
- name: Checkout patches
105121
uses: actions/checkout@v4
106122
with:
107-
path: 'runner-patches'
108-
123+
path: "runner-patches"
124+
109125
- name: Apply patches
110126
shell: pwsh
111127
run: |
112-
Get-ChildItem "runner-patches/patches" -Filter *.patch |
128+
Get-ChildItem "runner-patches/patches" -Filter *.patch |
113129
Foreach-Object {
114130
Write-Output "Processing $($_.FullName)"
115131
git apply --ignore-whitespace $($_.FullName)
@@ -122,8 +138,8 @@ jobs:
122138
- name: Set up JDK 17
123139
uses: actions/setup-java@v4
124140
with:
125-
java-version: '17'
126-
distribution: 'temurin'
141+
java-version: "17"
142+
distribution: "temurin"
127143

128144
- name: Install Cargo NDK
129145
run: cargo install --force cargo-ndk
@@ -150,7 +166,7 @@ jobs:
150166
take-screenshots:
151167
runs-on: ubuntu-latest
152168
timeout-minutes: 30
153-
needs: [build-for-iOS, build-for-Android]
169+
needs: [build-for-iOS, build-for-Android, create-pixel-eagle-run]
154170
strategy:
155171
fail-fast: false
156172
max-parallel: 7
@@ -217,17 +233,17 @@ jobs:
217233
- name: Checkout patches
218234
uses: actions/checkout@v4
219235
with:
220-
path: 'runner-patches'
221-
236+
path: "runner-patches"
237+
222238
- name: Apply patches
223239
shell: pwsh
224240
run: |
225-
Get-ChildItem "runner-patches/patches" -Filter *.patch |
241+
Get-ChildItem "runner-patches/patches" -Filter *.patch |
226242
Foreach-Object {
227243
Write-Output "Processing $($_.FullName)"
228244
git apply --ignore-whitespace $($_.FullName)
229245
}
230-
246+
231247
- name: Set Percy Token if needed
232248
if: "${{ inputs.mobile_percy_project != '' }}"
233249
run: echo "PERCY_TOKEN=${{ secrets.PERCY_TOKEN_MOBILE }}" >> $GITHUB_ENV
@@ -247,51 +263,25 @@ jobs:
247263
PERCY_COMMIT: ${{ inputs.gitref }}
248264
PERCY_PARALLEL_NONCE: ${{ github.run_id }}
249265
PERCY_PARALLEL_TOTAL: ${{ strategy.job-total }}
250-
266+
251267
- name: Save screenshots
252268
if: ${{ always() }}
253269
uses: actions/upload-artifact@v4
254270
with:
255271
name: screenshots-${{ matrix.device }}-${{ matrix.os_version }}
256272
path: .github/start-mobile-example/*.png
257-
273+
258274
- name: Send to Pixel Eagle
259275
run: |
260-
run=`curl https://pixel-eagle.com/${{ inputs.pixeleagle_project }}/runs -H 'Content-Type: application/json' -d '{"device":"${{ matrix.device }}", "os":"${{ matrix.os }}-${{ matrix.os_version }}", "adapter": "${{ matrix.adapter }}", "gitref": "${{ inputs.gitref }}", "branch": "${{ inputs.branch }}"}' --oauth2-bearer ${{ secrets.PIXELEAGLE }} | jq '.id'`
261-
262-
SAVEIFS=$IFS
263-
264-
IFS=$'\n'
265-
266276
cd .github/start-mobile-example
267-
268-
# Build a json array of screenshots and their hashes
269-
hashes='[';
270277
for screenshot in $(find . -type f -maxdepth 1 -name "*.png");
271278
do
272-
name=${screenshot:2}
279+
file=${screenshot:2}
280+
name="${{ matrix.os }}-${{ matrix.device }}-${{ matrix.os_version }}-$file"
273281
echo $name
274-
hash=`shasum -a 256 $screenshot | awk '{print $1}'`
275-
hashes="$hashes [\"$name\",\"$hash\"],"
282+
curl https://pixel-eagle.com/${{ inputs.pixeleagle_project }}/runs/${{ needs.create-pixel-eagle-run.outputs.pixeleagle_run }}/screenshots -F "data=@./$file" -F "screenshot=$name" --oauth2-bearer ${{ secrets.PIXELEAGLE }}
276283
done
277-
hashes=`echo $hashes | rev | cut -c 2- | rev`
278-
hashes="$hashes]"
279-
280-
IFS=$SAVEIFS
281-
282-
# Upload screenshots with unknown hashes
283-
curl https://pixel-eagle.com/${{ inputs.pixeleagle_project }}/runs/$run/hashes -H 'Content-Type: application/json' -d "$hashes" --oauth2-bearer ${{ secrets.PIXELEAGLE }} | jq '.[]|[.name] | @tsv' |
284-
while IFS=$'\t' read -r name; do
285-
name=`echo $name | tr -d '"'`
286-
echo "Uploading $name"
287-
curl https://pixel-eagle.com/${{ inputs.pixeleagle_project }}/runs/$run/screenshots -F "data=@./$name" -F "screenshot=$name" --oauth2-bearer ${{ secrets.PIXELEAGLE }}
288-
echo
289-
done
290-
291-
IFS=$SAVEIFS
292284
293-
curl https://pixel-eagle.com/${{ inputs.pixeleagle_project }}/runs/$run/compare/auto -H 'Content-Type: application/json' -d '{"os":"<equal>", "device":"<equal>", "branch": "main"}' --oauth2-bearer ${{ secrets.PIXELEAGLE }}
294-
295285
mobile-check-result:
296286
runs-on: ubuntu-latest
297287
timeout-minutes: 30
@@ -308,3 +298,24 @@ jobs:
308298
sleep 30
309299
env:
310300
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN_MOBILE }}
301+
302+
mobile-check-result-pixel-eagle:
303+
runs-on: ubuntu-latest
304+
timeout-minutes: 30
305+
needs: [take-screenshots]
306+
if: always()
307+
steps:
308+
- name: Trigger screenshots comparison
309+
run: |
310+
curl https://pixel-eagle.com/${{ inputs.pixeleagle_project }}/runs/${{ needs.create-pixel-eagle-run.outputs.pixeleagle_run }}/compare/auto -H 'Content-Type: application/json' -d '{"os":"<equal>", "branch": "main"}' --oauth2-bearer ${{ secrets.PIXELEAGLE }} | jq '{project_id: .project_id, from: .from, to: .to}' > pixeleagle-mobile.json
311+
cat pixeleagle-mobile.json
312+
313+
- name: Upload Pixel Eagle status
314+
uses: actions/upload-artifact@v4
315+
with:
316+
name: pixeleagle-mobile
317+
path: pixeleagle-mobile.json
318+
319+
- name: Wait a bit
320+
run: |
321+
sleep 30

src/main.rs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ impl Hash for Example {
3737
struct Run {
3838
date: String,
3939
commit: String,
40-
results: HashMap<String, HashMap<String, Kind>>,
41-
screenshots: HashMap<String, HashMap<String, (ImageUrl, ScreenshotState, SnapshotViewerUrl)>>,
40+
results: HashMap<String, HashMap<Platform, Kind>>,
41+
screenshots: HashMap<String, HashMap<Platform, (ImageUrl, ScreenshotState, SnapshotViewerUrl)>>,
4242
logs: HashMap<String, HashMap<String, String>>,
4343
}
4444

@@ -184,29 +184,34 @@ fn main() {
184184
run.results
185185
.entry(example.name)
186186
.or_insert_with(HashMap::new)
187-
.insert(platform.to_string().clone(), kind.clone());
187+
.insert(platform.clone(), kind.clone());
188188
});
189189
}
190190
if [Kind::Percy, Kind::PixelEagle].contains(&kind) {
191191
println!(" - {:?} / {:?}", kind, platform);
192192
let content = fs::read_to_string(&path).unwrap();
193193
let screenshots = match kind {
194-
Kind::Percy => percy::read_results(content),
194+
Kind::Percy => continue, //percy::read_results(content),
195195
Kind::PixelEagle => pixeleagle::read_results(content),
196196
_ => unreachable!(),
197197
};
198198
for ScreenshotData {
199-
example,
199+
mut example,
200200
screenshot,
201201
mut changed,
202-
tag,
202+
mut tag,
203203
diff_ratio,
204204
snapshot_url,
205205
} in screenshots.into_iter()
206206
{
207207
let (category, name) = if platform == Platform::Mobile {
208208
if let Some(tag) = tag.as_ref() {
209209
all_mobile_platforms.insert(tag.clone());
210+
} else {
211+
let parts = example.split('-').collect::<Vec<_>>();
212+
tag = Some(format!("{} {} / {}", parts[0], parts[2], parts[1]));
213+
all_mobile_platforms.insert(tag.clone().unwrap());
214+
example = "Bevy Mobile Example".to_string();
210215
}
211216
(ExampleCategory("Mobile".to_string()), example)
212217
} else {
@@ -227,6 +232,9 @@ fn main() {
227232
flaky: true,
228233
..previous
229234
});
235+
} else {
236+
let previous = all_examples.take(&example).unwrap_or(example.clone());
237+
all_examples.insert(previous);
230238
}
231239
if diff_ratio == 0.0 && changed == ScreenshotState::Changed {
232240
println!(
@@ -238,23 +246,13 @@ fn main() {
238246
let platform = tag
239247
.clone()
240248
.map(|tag| Platform::Tag(tag.clone()))
241-
.unwrap_or_else(|| platform.clone())
242-
.to_string();
249+
.unwrap_or_else(|| platform.clone());
243250
// If there is a screenshot but no results, mark as success
244251
run.results
245252
.entry(example.name.clone())
246253
.or_insert_with(HashMap::new)
247254
.entry(platform.clone())
248255
.or_insert_with(|| Kind::Successes);
249-
// Keeping Percy results over PixelEagle for now
250-
// TODO: remove
251-
if let Some(existing_screenshots) = run.screenshots.get(&example.name) {
252-
if existing_screenshots.contains_key(&platform) {
253-
if kind == Kind::PixelEagle {
254-
continue;
255-
}
256-
}
257-
}
258256
run.screenshots
259257
.entry(example.name)
260258
.or_insert_with(HashMap::new)
@@ -285,7 +283,7 @@ fn main() {
285283
run.results
286284
.entry(example.name)
287285
.or_insert_with(HashMap::new)
288-
.insert(rerun_platform.to_string(), Kind::NoScreenshots);
286+
.insert(rerun_platform.clone(), Kind::NoScreenshots);
289287
});
290288
}
291289
if kind.ends_with(".log") {

0 commit comments

Comments
 (0)