Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b4HkWoC7hLzk61vZa8
27 lines
1.4 KiB
Bash
Executable File
27 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Starts a throwaway Gitea 1.27.3 for the live tests and writes scripts/.gitea.env. Never point the tests at a real server.
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")"
|
|
IMAGE=${GITEA_IMAGE:-gitea/gitea:1.27.3}
|
|
docker rm -f pr-reviewer-gitea >/dev/null 2>&1 || true
|
|
docker run -d --name pr-reviewer-gitea -p 127.0.0.1:3118:3000 \
|
|
-e GITEA__security__INSTALL_LOCK=true \
|
|
-e GITEA__security__ALLOWED_HOST_LIST=private \
|
|
-e GITEA__database__DB_TYPE=sqlite3 \
|
|
-e GITEA__server__ROOT_URL=http://localhost:3118/ "$IMAGE" >/dev/null
|
|
until curl -sf --noproxy '*' http://127.0.0.1:3118/api/v1/version >/dev/null; do sleep 2; done
|
|
PASS="Local-$(head -c 12 /dev/urandom | od -An -tx1 | tr -d ' \n')"
|
|
for user in dev reviewbot; do
|
|
extra=""; [ "$user" = dev ] && extra="--admin"
|
|
docker exec -u git pr-reviewer-gitea gitea admin user create --username "$user" --password "$PASS" \
|
|
--email "$user@example.com" --must-change-password=false $extra >/dev/null
|
|
done
|
|
token() { docker exec -u git pr-reviewer-gitea gitea admin user generate-access-token --username "$1" --scopes all --token-name t --raw; }
|
|
{
|
|
echo "GITEA_DEV_TOKEN=$(token dev)"
|
|
echo "GITEA_BOT_TOKEN=$(token reviewbot)"
|
|
# the address under which the container reaches the machine running the tests
|
|
echo "WEBHOOK_HOST=$(docker network inspect bridge -f '{{(index .IPAM.Config 0).Gateway}}')"
|
|
} > .gitea.env
|
|
echo "Gitea is up on http://127.0.0.1:3118"
|