-
Notifications
You must be signed in to change notification settings - Fork 2
162 lines (139 loc) · 5.26 KB
/
Copy pathheaded-smoke.yml
File metadata and controls
162 lines (139 loc) · 5.26 KB
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
name: Headed and Desktop Docker Smoke Test
permissions:
contents: read
on:
pull_request:
paths:
- "Dockerfile"
- "docker-compose.yml"
- ".dockerignore"
- "docker/**"
- "config.json"
- "pyproject.toml"
- "uv.lock"
- "akari_bot_webrender/**"
- ".github/workflows/headed-smoke.yml"
push:
branches:
- master
- main
paths:
- "Dockerfile"
- "docker-compose.yml"
- ".dockerignore"
- "docker/**"
- "config.json"
- "pyproject.toml"
- "uv.lock"
- "akari_bot_webrender/**"
- ".github/workflows/headed-smoke.yml"
workflow_dispatch:
jobs:
headed-smoke:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Validate Docker Compose example
run: |
docker compose --profile headless config --quiet
docker compose --profile headed config --quiet
docker compose --profile desktop config --quiet
- name: Build headed image
run: docker build --target headed --tag akari-bot-webrender:headed-smoke .
- name: Start headed container and render a page
shell: bash
run: |
set -Eeuo pipefail
container_name="webrender-headed-smoke"
response_file="${RUNNER_TEMP}/webrender-page-response.json"
screenshot_file="${RUNNER_TEMP}/webrender-page.png"
cleanup() {
exit_status=$?
trap - EXIT
if (( exit_status != 0 )); then
docker logs "${container_name}" || true
fi
docker rm --force "${container_name}" >/dev/null 2>&1 || true
exit "${exit_status}"
}
trap cleanup EXIT
docker run --detach \
--name "${container_name}" \
--shm-size=1g \
--env WEBRENDER_HOST=0.0.0.0 \
--publish 127.0.0.1:15551:15551 \
akari-bot-webrender:headed-smoke
ready=0
for attempt in $(seq 1 60); do
if status_json=$(curl --fail --silent --show-error http://127.0.0.1:15551/status/ 2>/dev/null) \
&& jq --exit-status \
'.browser_initialized == true and .headless == false and .browser_mode == "headed"' \
<<<"${status_json}" >/dev/null; then
ready=1
break
fi
sleep 2
done
if (( ready != 1 )); then
echo "WebRender did not become ready within 120 seconds" >&2
exit 1
fi
curl --fail-with-body --silent --show-error \
--header 'Content-Type: application/json' \
--data-binary '{"content":"<!doctype html><html><body><h1>Headed smoke test</h1><p>Chromium rendered this local content.</p></body></html>","output_type":"png","width":480,"height":320,"counttime":false}' \
http://127.0.0.1:15551/page/ \
> "${response_file}"
jq --exit-status \
'type == "array" and length > 0 and all(.[]; type == "string" and length > 0)' \
"${response_file}" >/dev/null
jq --raw-output '.[0]' "${response_file}" | base64 --decode > "${screenshot_file}"
test -s "${screenshot_file}"
png_signature=$(od -An -tx1 -N8 "${screenshot_file}" | tr -d '[:space:]')
test "${png_signature}" = "89504e470d0a1a0a"
- name: Build and smoke test desktop image
shell: bash
run: |
set -Eeuo pipefail
image_name="akari-bot-webrender:desktop-smoke"
container_name="webrender-desktop-smoke"
cleanup() {
exit_status=$?
trap - EXIT
if (( exit_status != 0 )); then
docker logs "${container_name}" || true
fi
docker rm --force "${container_name}" >/dev/null 2>&1 || true
exit "${exit_status}"
}
trap cleanup EXIT
docker build --target desktop --tag "${image_name}" .
docker run --detach \
--name "${container_name}" \
--shm-size=1g \
--env ENABLE_NOVNC=1 \
--env NOVNC_LISTEN=0.0.0.0 \
--env NOVNC_PASSWORD=ci-only-password \
--publish 127.0.0.1:15551:15551 \
--publish 127.0.0.1:6080:6080 \
"${image_name}"
ready=0
for attempt in $(seq 1 60); do
if status_json=$(curl --fail --silent --show-error http://127.0.0.1:15551/status/ 2>/dev/null) \
&& jq --exit-status \
'.browser_initialized == true and .headless == false and .browser_mode == "headed"' \
<<<"${status_json}" >/dev/null \
&& curl --fail --silent --show-error http://127.0.0.1:6080/vnc.html >/dev/null; then
ready=1
break
fi
sleep 2
done
if (( ready != 1 )); then
echo "Desktop WebRender did not become ready within 120 seconds" >&2
exit 1
fi
docker exec "${container_name}" pgrep --exact xfce4-session >/dev/null
docker exec "${container_name}" pgrep --exact x11vnc >/dev/null
docker exec "${container_name}" pgrep --full websockify >/dev/null