Skip to content

Commit 7f44e3d

Browse files
committed
Supports uploading screenshot test results to github pages
1 parent b7ddc9d commit 7f44e3d

1 file changed

Lines changed: 66 additions & 24 deletions

File tree

.github/workflows/compare_webview_screenshots.yml

Lines changed: 66 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@ name: Compare WebView Screenshots
22

33
on:
44
workflow_dispatch:
5+
schedule:
6+
- cron: "0 0 * * 0"
7+
workflow_run:
8+
workflows: [ "Generate WebView Screenshots" ]
9+
types:
10+
- completed
11+
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
516

617
jobs:
718
compare-screenshots:
@@ -74,35 +85,66 @@ jobs:
7485
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
7586
disable-animations: false
7687
script: |
77-
./gradlew executeScreenshotTests
78-
79-
- name: Verify screenshots
80-
uses: reactivecircus/android-emulator-runner@v2
81-
with:
82-
api-level: 35
83-
arch: x86_64
84-
target: google_apis
85-
force-avd-creation: false
86-
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
87-
disable-animations: false
88-
script: |
89-
./gradlew verifyScreenshots || echo "Screenshot verification completed"
88+
./gradlew executeScreenshotTests || true
9089
91-
- name: Find verification report
90+
- name: Prepare report for GitHub Pages
9291
run: |
93-
echo "Searching for verification/index.html files:"
94-
find . -name "index.html" -path "*/verification/*" -type f | while read file; do
95-
echo "Found verification report: $file"
96-
done
92+
mkdir -p public
93+
if [ -d "app/build/reports/shot/debug/verification" ]; then
94+
cp -r app/build/reports/shot/debug/verification/* public/
95+
else
96+
echo "<h1>No screenshot report found</h1>" > public/index.html
97+
fi
98+
- name: Upload artifact for Pages
99+
uses: actions/upload-pages-artifact@v3
100+
with:
101+
path: ./public
97102

98-
- name: Upload comparison results
103+
- name: Upload comparison results as artifact
99104
uses: actions/upload-artifact@v4
100105
if: always()
101106
with:
102107
name: screenshot-comparison-${{ github.run_id }}
103108
path: |
104-
app/screenshots/
105-
**/screenshots/
106-
app/build/reports/shot/
107-
**/build/reports/shot/
108-
retention-days: 30
109+
app/build/reports/shot/debug/verification/
110+
public/
111+
retention-days: 30
112+
113+
deploy:
114+
needs: compare-screenshots
115+
runs-on: ubuntu-latest
116+
environment:
117+
name: github-pages
118+
url: ${{ steps.deployment.outputs.page_url }}
119+
120+
permissions:
121+
pages: write
122+
id-token: write
123+
124+
steps:
125+
- name: Deploy to GitHub Pages
126+
id: deployment
127+
uses: actions/deploy-pages@v4
128+
129+
check-result:
130+
needs: [ compare-screenshots, deploy ]
131+
runs-on: ubuntu-latest
132+
steps:
133+
- name: Download comparison artifact
134+
uses: actions/download-artifact@v4
135+
with:
136+
name: screenshot-comparison-${{ github.run_id }}
137+
138+
- name: Fail job if diff found
139+
run: |
140+
REPORT=$(find . -type f -name "TEST-Shot.xml" | head -n 1)
141+
if [ -z "$REPORT" ]; then
142+
echo "❌ TEST-Shot.xml not found"
143+
exit 1
144+
fi
145+
if grep -q "<failure" "$REPORT"; then
146+
echo "❌ Screenshot diff detected"
147+
exit 1
148+
else
149+
echo "✅ No screenshot diff detected"
150+
fi

0 commit comments

Comments
 (0)