Files
probably-rendering-one-more…/scripts/verify-studio-production.sh
T
codex-bot 5beddf1d85
studio CI and deployment / verify-and-deploy (pull_request) Successful in 8m10s
Run server acceptance through CI artifacts and clean task temporaries
2026-10-28 16:25:29 +08:00

51 lines
2.5 KiB
Bash

#!/usr/bin/env bash
# Run on ces-control after deployment; never starts a preview web server.
set -Eeuo pipefail
REPO_ROOT=$(git rev-parse --show-toplevel)
RESULT_DIR="$REPO_ROOT/artifacts/studio-acceptance"
MODE=${1:-verify}
[[ "$MODE" == verify || "$MODE" == --diagnose ]] || exit 2
WIKI_IMAGE=$(docker inspect --format '{{.Config.Image}}' prompt-waterfall-wiki-1)
[[ "$WIKI_IMAGE" =~ ^waterfall-wiki:[0-9a-f]{40}$ ]] || { echo 'Unexpected Wiki image'; exit 1; }
TEST_IMAGE="waterfall-wiki-tests:${WIKI_IMAGE#waterfall-wiki:}"
docker image inspect "$TEST_IMAGE" >/dev/null
mkdir -p "$RESULT_DIR"
chown 1000:1000 "$RESULT_DIR"
run_api(){
local result_root=$1 script=$2; shift 2
docker run --rm --volumes-from prompt-waterfall-wiki-1:ro \
--mount "type=bind,src=$REPO_ROOT,dst=/delivery,readonly" \
--mount "type=bind,src=$result_root,dst=/tmp/studio-library" \
-e AUTH_CONFIG_FILE=/auth/config.json -e AUTH_CHECK_BASE_URL=http://8.211.154.134:18131 \
--entrypoint node "$TEST_IMAGE" dist/auth-cli.cjs run "/delivery/scripts/$script" "$@"
}
# Clean only this task's explicitly named legacy temporary directories. Preserve test data via archive.
if [[ -f /tmp/studio-library/verification.json ]]; then
run_api /tmp/studio-library verify-studio-library.mjs --finalize
fi
if [[ -d /tmp/studio-library-source ]]; then
test -z "$(git -C /tmp/studio-library-source status --porcelain)" || { echo 'Temporary source has unexpected edits; preserved'; exit 1; }
git --git-dir=/tmp/studio-library-delivery.git worktree remove /tmp/studio-library-source
fi
rm -rf /tmp/studio-library-delivery.git /tmp/studio-library-evidence /tmp/studio-library
for old_path in /tmp/studio-library-source /tmp/studio-library-delivery.git /tmp/studio-library-evidence /tmp/studio-library; do
test ! -e "$old_path" || exit 1
done
printf '{"legacyTemporaryDirectoriesRemoved":true}\n' > "$RESULT_DIR/cleanup.json"
# Always archive only the UUIDs created by this run, including when visual checks fail.
finish(){
local status=$?
trap - EXIT
if [[ -f "$RESULT_DIR/verification.json" ]]; then
if ! run_api "$RESULT_DIR" verify-studio-library.mjs --finalize; then status=1; fi
fi
exit "$status"
}
trap finish EXIT
run_api "$RESULT_DIR" verify-studio-library.mjs
docker run --rm --volumes-from prompt-waterfall-wiki-1:ro \
--mount "type=bind,src=$REPO_ROOT,dst=/delivery,readonly" \
--mount "type=bind,src=$RESULT_DIR,dst=/tmp/studio-library" \
-e AUTH_CONFIG_FILE=/auth/config.json -e NODE_PATH=/app/node_modules \
--entrypoint node "$TEST_IMAGE" /delivery/scripts/verify-studio-visual.cjs "$MODE"