53 lines
2.5 KiB
Bash
53 lines
2.5 KiB
Bash
#!/usr/bin/env bash
|
|
# Run on ces-control after deployment; never starts a preview web server.
|
|
set -Eeuo pipefail
|
|
# Wiki and Studio deploy independently; wait for Wiki's canonical route proxy.
|
|
canonical_ready=false
|
|
for attempt in {1..120}; do
|
|
if curl -fsS http://8.211.154.134:18131/ | grep -q '想法不该停在对话里'; then canonical_ready=true; break; fi
|
|
sleep 5
|
|
done
|
|
$canonical_ready || { echo 'Wiki landing and canonical route release is not ready'; exit 1; }
|
|
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" "$@"
|
|
}
|
|
# Result files are uploaded by the workflow and removed after successful upload.
|
|
printf '{"temporaryOutputManagedByCI":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"
|
|
docker run --rm \
|
|
--mount "type=bind,src=$REPO_ROOT,dst=/delivery,readonly" \
|
|
--mount "type=bind,src=$RESULT_DIR,dst=/tmp/studio-library" \
|
|
-e NODE_PATH=/app/node_modules -e CHROMIUM_PATH=/usr/bin/chromium \
|
|
-e SCREENSHOT_DIR=/tmp/studio-library/visual \
|
|
--entrypoint node "$TEST_IMAGE" /delivery/apps/studio/scripts/infinite-canvas-smoke.cjs
|