Files
homarr/apps/workshop/test-image.sh
T
Thomas 229bd4b3ed chore: use Bun package management and Turbo remote caching (#6978)
* feat: migrate tooling and runtimes to bun

* fix: serialize act installs and adapt backup checks

* fix: finish bun scripts and rootless act setup

* fix: support bun images in runtime benchmarks

* fix: keep a single bun toolchain configuration

* fix: include docs mascot sources in workshop build

* docs: use bun in remaining tool commands

* fix: complete bun sqlite development tooling

* docs: explain sqlite development adapter

* fix: align remaining commands and local ci validation

* fix: use renovate regex fallback with bun

* fix: finalize bun sqlite connections during cleanup

* fix: preserve sqlite foreign key enforcement

* fix: align docker build frontends

* fix: prepare release versions with bun

* Add Bun benchmarks and preserve SQLite connection defaults

* Benchmark Bun installs, conflicts and production workloads

* Force Bun workspace tools and HTTP/1.1 upstream streaming

* Exclude benchmark evidence from Docker contexts

* Expose branch benchmarks through CI

* Verify hydrated widget data in production benchmarks

* Measure image archives and document benchmark protocol

* Audit dependency sharing across every workspace

* Pin pnpm for nested baseline benchmark scripts

* Preserve nested manager pinning on benchmark resume

* Include application and runtime image footprints

* Fail benchmark gates on candidate command errors

* Report complete build overhead and sampled memory bounds

* Validate migration comparisons across pinned revisions

* Record configurable runtime memory budgets

* Retain out-of-memory kills in runtime budget probes

* Reject OOM events consistently across runtime metrics

* Record complete Bun migration benchmarks

* Record memory diagnosis and correct Turbo caching

* Use Bun package management while preserving Node runtimes

* Keep native build fallbacks and exclude development artifacts

* Fix Node ESM metadata and isolate local CI configuration

* Measure development performance and isolate act environment

* Support isolated environment files in rootless act

* Validate the full migration range with act

* Preserve native SQLite binding for bundled migrations

* Use documented dev defaults and report benchmark scope

* Validate dev defaults and isolate restart measurements

* Record package-manager and development benchmarks

* Keep benchmark measurements and link full command artifacts

* Clean up temporary act environment files

* Validate Node runtimes in package-manager comparisons

* Validate every workspace in manual CI runs

* Retain patched nested brace expansion versions

* Complete package-manager and Node performance report

* Normalize archived benchmark logs

* Record final hosted validation

* Cache both Next builds with platform isolation

* Prime cache with write-only mode

* Split Next artifacts below Cloudflare upload limit

* Assemble coherent standalone cache outputs

* Preserve traced middleware entrypoints

* Assemble traced directory links before files

* Separate cached dependencies from assembled output

* Record signed Turbo cache benchmarks

* Remove archived benchmark captures

Full benchmark evidence is preserved at 8f7d3bcd14109bfb13fa664d31710b88d820ad66.

* Remove migration benchmark harness

* fix: correct migration launch and local Act prerequisites

* Consolidate Turbo caches and production artifacts

* Exclude generated files from Docker cache inputs

* fix: address Bun migration review findings

* fix: check restored compiler bundle manifests
2026-10-07 16:38:14 +02:00

177 lines
7.9 KiB
Bash

#!/bin/sh
set -eu
WORKSHOP_IMAGE_TEST_PORT=${WORKSHOP_IMAGE_TEST_PORT:-18091}
WORKSHOP_IMAGE_TEST_NAME="homarr-workshop-image-test-$$"
WORKSHOP_IMAGE_TEST_RESTORED_NAME="homarr-workshop-image-restored-$$"
WORKSHOP_IMAGE_TEST_TAG=${WORKSHOP_IMAGE_TEST_IMAGE:-homarr-workshop:test-$$}
WORKSHOP_IMAGE_TEST_VOLUME="homarr-workshop-image-test-$$"
WORKSHOP_IMAGE_TEST_RESTORE_VOLUME="homarr-workshop-image-restore-$$"
WORKSHOP_IMAGE_TEST_BACKUP_DIR=$(mktemp -d)
WORKSHOP_IMAGE_TEST_BACKUP="$WORKSHOP_IMAGE_TEST_BACKUP_DIR/pb-data.tar"
TEST_WEBSITE_URL=https://docs.example.invalid
TEST_API_URL=https://api.example.invalid
TEST_WORKSHOP_URL=https://workshop.example.invalid
cleanup() {
docker rm --force "$WORKSHOP_IMAGE_TEST_NAME" "$WORKSHOP_IMAGE_TEST_RESTORED_NAME" >/dev/null 2>&1 || true
docker volume rm "$WORKSHOP_IMAGE_TEST_VOLUME" "$WORKSHOP_IMAGE_TEST_RESTORE_VOLUME" >/dev/null 2>&1 || true
rm -rf "$WORKSHOP_IMAGE_TEST_BACKUP_DIR"
}
trap cleanup EXIT
verify_persisted_data() {
WORKSHOP_TEST_URL="$1" node --input-type=module -e '
import assert from "node:assert/strict";
const baseUrl = process.env.WORKSHOP_TEST_URL;
const response = await fetch(`${baseUrl}/api/collections/_superusers/auth-with-password`, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ identity: "workshop-image@example.invalid", password: "WorkshopImageTest123!" }),
});
assert.equal(response.status, 200, "superuser must survive restart or restore");
const { token } = await response.json();
const headers = { authorization: `Bearer ${token}` };
const usersResponse = await fetch(`${baseUrl}/api/collections/users/records?perPage=200`, { headers });
assert.equal(usersResponse.status, 200);
const users = await usersResponse.json();
const author = users.items.find((user) => user.email === "social-author@example.invalid");
assert.ok(author, "user must survive restart or restore");
const submissionsResponse = await fetch(`${baseUrl}/api/collections/submissions/records?perPage=200`, { headers });
assert.equal(submissionsResponse.status, 200);
const submissions = await submissionsResponse.json();
const submission = submissions.items.find((item) => item.title === "Ocean <Glow>");
assert.ok(submission, "submission must survive restart or restore");
assert.equal(submission.author, author.id, "submission author must survive restart or restore");
assert.equal(submission.content, "body { color: white; }", "submission content must survive restart or restore");
assert.equal(submission.screenshots.length, 1, "screenshot reference must survive restart or restore");
const screenshot = encodeURIComponent(submission.screenshots[0]);
const screenshotResponse = await fetch(`${baseUrl}/api/files/submissions/${submission.id}/${screenshot}`, { headers });
assert.equal(screenshotResponse.status, 200, "screenshot file must survive restart or restore");
const expectedScreenshot = Buffer.from(
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=",
"base64",
);
assert.deepEqual(Buffer.from(await screenshotResponse.arrayBuffer()), expectedScreenshot, "screenshot bytes must survive restart or restore");
'
}
docker volume create "$WORKSHOP_IMAGE_TEST_VOLUME" >/dev/null
docker volume create "$WORKSHOP_IMAGE_TEST_RESTORE_VOLUME" >/dev/null
if [ -z "${WORKSHOP_IMAGE_TEST_IMAGE:-}" ]; then
bash tooling/github/docker-build.sh --target production -f apps/workshop/Dockerfile -t "$WORKSHOP_IMAGE_TEST_TAG" .
fi
docker run --detach --name "$WORKSHOP_IMAGE_TEST_NAME" \
--publish "127.0.0.1:$WORKSHOP_IMAGE_TEST_PORT:8090" \
--mount "type=volume,source=$WORKSHOP_IMAGE_TEST_VOLUME,target=/pb_data" \
--env HOMARR_WEBSITE_URL="$TEST_WEBSITE_URL" \
--env WORKSHOP_API_URL="$TEST_API_URL" \
--env WORKSHOP_WEB_URL="$TEST_WORKSHOP_URL" \
--env WORKSHOP_PUBLIC_ORIGIN="$TEST_API_URL" \
--env PB_ALLOWED_ORIGINS='*' \
"$WORKSHOP_IMAGE_TEST_TAG" >/dev/null
for attempt in $(seq 1 60); do
if curl --fail --silent "http://127.0.0.1:$WORKSHOP_IMAGE_TEST_PORT/api/health" >/dev/null; then
break
fi
if [ "$attempt" -eq 60 ]; then
docker logs "$WORKSHOP_IMAGE_TEST_NAME"
exit 1
fi
sleep 1
done
WORKSHOP_TEST_URL="http://127.0.0.1:$WORKSHOP_IMAGE_TEST_PORT" \
EXPECTED_HOMARR_WEBSITE_URL="$TEST_WEBSITE_URL" \
EXPECTED_WORKSHOP_API_URL="$TEST_API_URL" \
EXPECTED_WORKSHOP_WEB_URL="$TEST_WORKSHOP_URL" \
node apps/workshop/tests/runtime-config.integration.mjs
WORKSHOP_TEST_URL="http://127.0.0.1:$WORKSHOP_IMAGE_TEST_PORT" \
node apps/workshop/tests/static-export.integration.mjs
docker exec "$WORKSHOP_IMAGE_TEST_NAME" pocketbase superuser create \
workshop-image@example.invalid 'WorkshopImageTest123!' --dir=/pb_data
WORKSHOP_TEST_URL="http://127.0.0.1:$WORKSHOP_IMAGE_TEST_PORT" \
EXPECTED_HOMARR_WEBSITE_URL="$TEST_WEBSITE_URL" \
EXPECTED_WORKSHOP_API_URL="$TEST_API_URL" \
EXPECTED_WORKSHOP_WEB_URL="$TEST_WORKSHOP_URL" \
node apps/workshop/tests/workshop-social-metadata.integration.mjs
curl --fail --location --silent "http://127.0.0.1:$WORKSHOP_IMAGE_TEST_PORT/workshop" >/dev/null
curl --fail --silent \
"http://127.0.0.1:$WORKSHOP_IMAGE_TEST_PORT/api/collections/workshop_listings/records?perPage=1" >/dev/null
curl --fail --silent --dump-header - --output /dev/null \
--header 'Origin: https://homarr.example' \
"http://127.0.0.1:$WORKSHOP_IMAGE_TEST_PORT/api/collections/workshop_listings/records?perPage=1" \
| tr -d '\r' \
| grep -qi '^Access-Control-Allow-Origin: \*$'
docker stop "$WORKSHOP_IMAGE_TEST_NAME" >/dev/null
mkdir -p "$WORKSHOP_IMAGE_TEST_BACKUP_DIR/data"
docker cp "$WORKSHOP_IMAGE_TEST_NAME:/pb_data/." "$WORKSHOP_IMAGE_TEST_BACKUP_DIR/data"
test -s "$WORKSHOP_IMAGE_TEST_BACKUP_DIR/data/data.db"
tar -C "$WORKSHOP_IMAGE_TEST_BACKUP_DIR/data" -cf "$WORKSHOP_IMAGE_TEST_BACKUP" .
docker rm "$WORKSHOP_IMAGE_TEST_NAME" >/dev/null
docker run --detach --name "$WORKSHOP_IMAGE_TEST_NAME" \
--publish "127.0.0.1:$WORKSHOP_IMAGE_TEST_PORT:8090" \
--mount "type=volume,source=$WORKSHOP_IMAGE_TEST_VOLUME,target=/pb_data" \
--env HOMARR_WEBSITE_URL="$TEST_WEBSITE_URL" \
--env WORKSHOP_API_URL="$TEST_API_URL" \
--env WORKSHOP_WEB_URL="$TEST_WORKSHOP_URL" \
--env WORKSHOP_PUBLIC_ORIGIN="$TEST_API_URL" \
--env PB_ALLOWED_ORIGINS='*' \
"$WORKSHOP_IMAGE_TEST_TAG" >/dev/null
for attempt in $(seq 1 60); do
if curl --fail --silent "http://127.0.0.1:$WORKSHOP_IMAGE_TEST_PORT/api/health" >/dev/null; then
break
fi
if [ "$attempt" -eq 60 ]; then
docker logs "$WORKSHOP_IMAGE_TEST_NAME"
exit 1
fi
sleep 1
done
verify_persisted_data "http://127.0.0.1:$WORKSHOP_IMAGE_TEST_PORT"
echo "Workshop named-volume persistence passed"
docker stop "$WORKSHOP_IMAGE_TEST_NAME" >/dev/null
docker rm "$WORKSHOP_IMAGE_TEST_NAME" >/dev/null
docker run --rm \
--mount "type=volume,source=$WORKSHOP_IMAGE_TEST_RESTORE_VOLUME,target=/pb_data" \
--mount "type=bind,source=$WORKSHOP_IMAGE_TEST_BACKUP,target=/tmp/pb-data.tar,readonly" \
--entrypoint sh \
"$WORKSHOP_IMAGE_TEST_TAG" \
-c 'tar -C /pb_data -xf /tmp/pb-data.tar'
docker run --detach --name "$WORKSHOP_IMAGE_TEST_RESTORED_NAME" \
--publish "127.0.0.1:$WORKSHOP_IMAGE_TEST_PORT:8090" \
--mount "type=volume,source=$WORKSHOP_IMAGE_TEST_RESTORE_VOLUME,target=/pb_data" \
--env HOMARR_WEBSITE_URL="$TEST_WEBSITE_URL" \
--env WORKSHOP_API_URL="$TEST_API_URL" \
--env WORKSHOP_WEB_URL="$TEST_WORKSHOP_URL" \
--env WORKSHOP_PUBLIC_ORIGIN="$TEST_API_URL" \
--env PB_ALLOWED_ORIGINS='*' \
"$WORKSHOP_IMAGE_TEST_TAG" >/dev/null
for attempt in $(seq 1 60); do
if curl --fail --silent "http://127.0.0.1:$WORKSHOP_IMAGE_TEST_PORT/api/health" >/dev/null; then
break
fi
if [ "$attempt" -eq 60 ]; then
docker logs "$WORKSHOP_IMAGE_TEST_RESTORED_NAME"
exit 1
fi
sleep 1
done
verify_persisted_data "http://127.0.0.1:$WORKSHOP_IMAGE_TEST_PORT"
echo "Workshop backup restore passed"
echo "Workshop production image passed"