Skip to content

Commit 7c4abc1

Browse files
committed
fix: ensure lfs screenshots are always pulled
chore: debug risk level try to debug lfs issues fix: ensure screenshots in lfs are always downloaded chore: remove debugging artifacts
1 parent 7d2433b commit 7c4abc1

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

.github/workflows/android-regression.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,40 @@ jobs:
110110
with:
111111
lfs: true
112112

113+
# This is necessary because the macOS runner was not always pulling the lfs files despite checkout with lfs: true
114+
# Check if LFS files were actually pulled
115+
- name: Verify LFS files
116+
run: |
117+
echo "Ensuring all LFS screenshot files are downloaded..."
118+
git lfs pull --include="run/screenshots/**/*.png"
119+
120+
echo "=== Verifying screenshot files ==="
121+
corrupted_files=0
122+
total_files=0
123+
124+
for file in run/screenshots/**/*.png; do
125+
if [[ -f "$file" ]]; then # Make sure file exists (in case glob doesn't match anything)
126+
((total_files++))
127+
if file "$file" | grep -q "PNG image"; then
128+
echo "✅ $file"
129+
else
130+
echo "⚠️ WARNING: $file is not a PNG image - related tests may fail"
131+
# Show what it actually is for debugging
132+
echo " File type: $(file "$file")"
133+
((corrupted_files++))
134+
fi
135+
fi
136+
done
137+
138+
echo "📊 Screenshot verification: $((total_files - corrupted_files))/$total_files files valid"
139+
140+
if [ $corrupted_files -gt 0 ]; then
141+
echo "⚠️ Found $corrupted_files corrupted screenshot files"
142+
echo "📝 Tests using these files will be skipped or may fail"
143+
else
144+
echo "✅ All screenshot files are valid PNG images"
145+
fi
146+
113147
- name: Fetch result history from gh-pages
114148
uses: ./github/actions/fetch-allure-history
115149
if: ${{ env.ALLURE_ENABLED == 'true' }}

run/test/specs/utils/verify_screenshots.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,32 @@ export async function verifyElementScreenshot<
6060
const elementScreenshotBase64: string = await device.getElementScreenshot(
6161
elementToScreenshot.ELEMENT
6262
);
63+
6364
// Convert the base64 string to a Buffer and save it to disk as a png
6465
const elementScreenshotPath = path.join(diffsDir, `${uuid}_screenshot.png`);
6566
const screenshotBuffer = Buffer.from(elementScreenshotBase64, 'base64');
67+
6668
fs.writeFileSync(elementScreenshotPath, screenshotBuffer);
69+
6770
// Check if baseline screenshot exists
6871
const baselineScreenshotPath = element.screenshotFileName(...args);
6972
if (!fs.existsSync(baselineScreenshotPath)) {
7073
throw new Error(
7174
`No baseline image found at: ${baselineScreenshotPath}. A new screenshot has been saved at: ${elementScreenshotPath}`
7275
);
7376
}
77+
78+
// Fail loudly if LFS pointer has not been resolved correctly
79+
const baselineBuffer = fs.readFileSync(baselineScreenshotPath);
80+
if (baselineBuffer.toString('utf8', 0, 50).includes('version https://git-lfs')) {
81+
throw new Error(`Baseline is corrupted LFS pointer: ${baselineScreenshotPath}. Skipping visual test.`);
82+
}
83+
7484
// Use looks-same to verify the element screenshot against the baseline
7585
const { equal, diffImage } = await looksSame(elementScreenshotPath, baselineScreenshotPath, {
7686
createDiffImage: true,
7787
});
88+
7889
if (!equal) {
7990
const diffImagePath = path.join(diffsDir, `${uuid}_diffImage.png`);
8091
await diffImage.save(diffImagePath);

0 commit comments

Comments
 (0)