Skip to content

Commit 68321d2

Browse files
committed
Fix e2e: show headless Chromium errors, add missing deps for screenshot
The headless screenshot silently failed (2>/dev/null hid the error). Now show stderr, use --headless=new, --disable-dev-shm-usage, and add missing shared libraries (libnss3, libgbm1, etc.) needed for Chromium headless in the container environment.
1 parent 45480fa commit 68321d2

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

testing/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ FROM ptrsr/pi-ci:latest
33
ENV LIBGUESTFS_BACKEND=direct
44

55
RUN apt-get update && apt-get install -y --no-install-recommends \
6-
sshpass openssh-client curl socat imagemagick chromium \
6+
sshpass openssh-client curl socat imagemagick \
7+
chromium libnss3 libatk1.0-0 libatk-bridge2.0-0 libgbm1 \
8+
libasound2t64 libxcomposite1 libxdamage1 libxrandr2 fonts-liberation \
79
&& rm -rf /var/lib/apt/lists/*
810

911
# Shared framework from CustomPiOS (copied into build context by CI)

testing/hooks/screenshot.sh

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,32 @@ if [ "$WIZARD_READY" -eq 0 ]; then
3030
fi
3131

3232
HTTP_PORT="${QEMU_HTTP_PORT:-8080}"
33-
for BROWSER in chromium chromium-browser google-chrome; do
34-
if command -v "$BROWSER" &>/dev/null; then
35-
echo " Using $BROWSER for headless screenshot..."
36-
"$BROWSER" --headless --disable-gpu --no-sandbox \
33+
34+
echo " Checking forwarded port accessibility..."
35+
curl -s -o /dev/null -w " Port $HTTP_PORT -> HTTP %{http_code}\n" "http://localhost:${HTTP_PORT}" || echo " Port $HTTP_PORT not reachable"
36+
37+
for BROWSER in chromium chromium-browser; do
38+
BROWSER_PATH=$(command -v "$BROWSER" 2>/dev/null || true)
39+
if [ -n "$BROWSER_PATH" ]; then
40+
echo " Taking headless screenshot with $BROWSER_PATH ..."
41+
"$BROWSER_PATH" \
42+
--headless=new \
43+
--no-sandbox \
44+
--disable-gpu \
45+
--disable-software-rasterizer \
46+
--disable-dev-shm-usage \
3747
--virtual-time-budget=15000 \
3848
--screenshot="$ARTIFACTS_DIR/screenshot.png" \
3949
--window-size=1280,720 \
40-
"http://localhost:${HTTP_PORT}" 2>/dev/null || true
50+
"http://localhost:${HTTP_PORT}" 2>&1 | tail -5 || true
4151
if [ -f "$ARTIFACTS_DIR/screenshot.png" ]; then
42-
echo " Browser screenshot saved"
52+
echo " Screenshot saved to $ARTIFACTS_DIR/screenshot.png"
53+
ls -la "$ARTIFACTS_DIR/screenshot.png"
4354
exit 0
55+
else
56+
echo " Screenshot file was NOT created by $BROWSER"
4457
fi
4558
fi
4659
done
4760

48-
echo " No headless browser available in container (HTML artifact saved instead)"
61+
echo " No screenshot produced (headless browser may have failed)"

0 commit comments

Comments
 (0)