Skip to content

Commit fca8fa9

Browse files
committed
test(relay): smoke published image platforms
1 parent df60034 commit fca8fa9

4 files changed

Lines changed: 79 additions & 0 deletions

File tree

.github/workflows/desktop-package.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,12 @@ jobs:
383383
REVISION=${{ needs.prepare.outputs.release_tag }}
384384
tags: ${{ steps.image-tags.outputs.value }}
385385

386+
- name: Smoke-test published image on both platforms
387+
shell: bash
388+
env:
389+
IMAGE_DIGEST: ${{ steps.image.outputs.digest }}
390+
run: bash scripts/relay/smoke-image.sh "${IMAGE}@${IMAGE_DIGEST}"
391+
386392
- name: Verify manifest and generate signed descriptor
387393
shell: bash
388394
env:

.github/workflows/nightly.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,13 @@ jobs:
337337
ghcr.io/gcwing/bitfun-relay-server:${{ env.NIGHTLY_TAG }}
338338
ghcr.io/gcwing/bitfun-relay-server:${{ steps.nightly-image-meta.outputs.asset_version }}
339339
340+
- name: Smoke-test published Relay image on both platforms
341+
shell: bash
342+
env:
343+
IMAGE_DIGEST: ${{ steps.relay-image.outputs.digest }}
344+
run: bash scripts/relay/smoke-image.sh \
345+
"ghcr.io/gcwing/bitfun-relay-server@${IMAGE_DIGEST}"
346+
340347
- name: Generate signed Relay image descriptor
341348
shell: bash
342349
env:

scripts/relay/package-contract.test.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ test('formal and nightly releases publish signed anonymous multi-platform Relay
4444
const formal = read('.github/workflows/desktop-package.yml');
4545
const nightly = read('.github/workflows/nightly.yml');
4646
const dockerfile = read('src/apps/relay-server/Dockerfile.release');
47+
const smoke = read('scripts/relay/smoke-image.sh');
4748

4849
for (const workflow of [formal, nightly]) {
4950
assert.match(workflow, /packages:\s*write/);
@@ -52,12 +53,17 @@ test('formal and nightly releases publish signed anonymous multi-platform Relay
5253
assert.match(workflow, /ghcr\.io\/gcwing\/bitfun-relay-server/);
5354
assert.match(workflow, /relay-image\.json/);
5455
assert.match(workflow, /scripts\/sign-release-assets\.sh relay-image\.json/);
56+
assert.match(workflow, /scripts\/relay\/smoke-image\.sh/);
5557
assert.match(workflow, /Verify anonymous .*image access|Verify anonymous pull access/);
5658
assert.match(workflow, /DOCKER_CONFIG="\$clean_config" docker buildx imagetools inspect/);
5759
}
5860
assert.match(formal, /latest_release=.*releases\/latest/);
5961
assert.doesNotMatch(nightly, /bitfun-relay-server:latest/);
6062

63+
assert.match(smoke, /for arch in amd64 arm64/);
64+
assert.match(smoke, /\.State\.Health/);
65+
assert.match(smoke, /docker logs --tail/);
66+
6167
assert.match(dockerfile, /org\.opencontainers\.image\.source="https:\/\/github\.com\/GCWing\/BitFun"/);
6268
assert.match(dockerfile, /TARGETARCH/);
6369
assert.match(dockerfile, /bitfun-relay-server/);

scripts/relay/smoke-image.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env bash
2+
3+
# Start every published Relay platform under the runner's native/QEMU runtime
4+
# and require the image's own HEALTHCHECK to pass before release metadata is
5+
# signed. Usage: smoke-image.sh <repository>@sha256:<multi-platform-digest>
6+
7+
set -euo pipefail
8+
9+
IMAGE_REF="${1:?usage: smoke-image.sh <repository>@sha256:<digest>}"
10+
if [[ ! "$IMAGE_REF" =~ @sha256:[0-9a-f]{64}$ ]]; then
11+
echo "ERROR: Relay smoke test requires a digest-pinned image." >&2
12+
exit 2
13+
fi
14+
15+
containers=()
16+
cleanup() {
17+
local container
18+
for container in "${containers[@]}"; do
19+
docker rm -fv "$container" >/dev/null 2>&1 || true
20+
done
21+
}
22+
trap cleanup EXIT INT TERM
23+
24+
for arch in amd64 arm64; do
25+
container="bitfun-relay-smoke-${arch}"
26+
containers+=("$container")
27+
echo ">>> Smoke-testing ${IMAGE_REF} on linux/${arch}..."
28+
docker run -d \
29+
--name "$container" \
30+
--platform "linux/${arch}" \
31+
-e RELAY_PORT=9700 \
32+
-e RELAY_STATIC_DIR=/app/static \
33+
-e RELAY_ROOM_WEB_DIR=/app/room-web \
34+
-e RELAY_DB_PATH=/app/data/bitfun_relay.db \
35+
"$IMAGE_REF" >/dev/null
36+
37+
healthy=0
38+
for _attempt in $(seq 1 45); do
39+
status="$(docker inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{else}}{{.State.Status}}{{end}}' "$container")"
40+
if [ "$status" = "healthy" ]; then
41+
healthy=1
42+
break
43+
fi
44+
if [ "$status" = "exited" ] || [ "$status" = "dead" ]; then
45+
break
46+
fi
47+
sleep 2
48+
done
49+
50+
if [ "$healthy" != "1" ]; then
51+
echo "ERROR: linux/${arch} Relay image did not become healthy." >&2
52+
docker inspect -f 'status={{.State.Status}} exit={{.State.ExitCode}} oom={{.State.OOMKilled}} error={{.State.Error}}' "$container" >&2 || true
53+
docker logs --tail 80 "$container" >&2 || true
54+
exit 1
55+
fi
56+
docker rm -fv "$container" >/dev/null
57+
echo ">>> linux/${arch} Relay image is healthy."
58+
done
59+
60+
trap - EXIT INT TERM

0 commit comments

Comments
 (0)