Files
sol/dev/bootstrap-gitea.sh
Sienna Meridian Satterwhite 4528739a5f feat: deterministic Gitea integration tests + mutation lifecycle
Bootstrap:
- Creates test issue + comment on studio/sol for deterministic test data
- Mirrors 6 real repos from src.sunbeam.pt

Devtools tests (13, all deterministic):
- Read: list_repos, get_repo, get_file, list_branches, list_issues,
  list_pulls, list_comments, list_notifications, list_org_repos,
  get_org, unknown_tool
- Mutation lifecycle: create_repo → create_issue → create_comment →
  create_branch → create_pull → get_pull → edit_issue →
  delete_branch → cleanup (all arg names verified against tool impls)

Additional tests:
- Script sandbox: basic math, string manipulation, JSON output
- Archive search: arg parsing, OpenSearch query
- Persistence: agent CRUD, service user CRUD
- gRPC bridge: event filtering, tool mapping
2026-03-24 12:45:01 +00:00

103 lines
3.4 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
## Bootstrap Gitea for local dev/testing.
## Creates admin user, org, and mirrors public repos from src.sunbeam.pt.
## Run after: docker compose -f docker-compose.dev.yaml up -d gitea
set -euo pipefail
GITEA="http://localhost:3000"
ADMIN_USER="sol"
ADMIN_PASS="solpass123"
ADMIN_EMAIL="sol@sunbeam.local"
SOURCE="https://src.sunbeam.pt"
echo "Waiting for Gitea..."
until curl -sf "$GITEA/api/v1/version" >/dev/null 2>&1; do
sleep 2
done
echo "Gitea is ready."
# Create admin user via container CLI (can't use API without existing admin)
echo "Creating admin user..."
docker compose -f docker-compose.dev.yaml exec -T --user git gitea \
gitea admin user create \
--username "$ADMIN_USER" --password "$ADMIN_PASS" \
--email "$ADMIN_EMAIL" --admin --must-change-password=false 2>/dev/null || true
echo "Admin user ready."
# Create studio org
echo "Creating studio org..."
curl -sf -X POST "$GITEA/api/v1/orgs" \
-H 'Content-Type: application/json' \
-u "$ADMIN_USER:$ADMIN_PASS" \
-d '{"username":"studio","full_name":"Sunbeam Studios","visibility":"public"}' \
> /dev/null 2>&1 || true
# Mirror repos from src.sunbeam.pt (public, no auth needed)
REPOS=(
"sol"
"cli"
"proxy"
"storybook"
"admin-ui"
"mistralai-client-rs"
)
for repo in "${REPOS[@]}"; do
echo "Migrating studio/$repo from src.sunbeam.pt..."
curl -sf -X POST "$GITEA/api/v1/repos/migrate" \
-H 'Content-Type: application/json' \
-u "$ADMIN_USER:$ADMIN_PASS" \
-d "{
\"clone_addr\": \"$SOURCE/studio/$repo.git\",
\"repo_name\": \"$repo\",
\"repo_owner\": \"studio\",
\"service\": \"gitea\",
\"mirror\": false
}" > /dev/null 2>&1 && echo "$repo" || echo " $repo (already exists or failed)"
done
# Create a PAT for the admin user (for SDK testing without Vault)
echo "Creating admin PAT..."
PAT=$(curl -sf -X POST "$GITEA/api/v1/users/$ADMIN_USER/tokens" \
-H 'Content-Type: application/json' \
-u "$ADMIN_USER:$ADMIN_PASS" \
-d '{"name":"sol-dev-pat","scopes":["read:repository","write:repository","read:user","read:organization","read:issue","write:issue","read:notification"]}' \
2>/dev/null | python3 -c "import sys,json; print(json.load(sys.stdin).get('sha1',json.load(sys.stdin).get('token','')))" 2>/dev/null || echo "")
if [ -z "$PAT" ]; then
# Token might already exist — try to get it
PAT="already-provisioned"
echo " PAT already exists (or creation failed)"
else
echo " PAT: ${PAT:0:8}..."
fi
# Create a deterministic test issue on sol repo
echo "Creating test issue on studio/sol..."
curl -sf -X POST "$GITEA/api/v1/repos/studio/sol/issues" \
-H 'Content-Type: application/json' \
-u "$ADMIN_USER:$ADMIN_PASS" \
-d '{"title":"Bootstrap test issue","body":"Created by bootstrap-gitea.sh for integration testing."}' \
> /dev/null 2>&1 || true
# Create a comment on issue #1
echo "Creating test comment on issue #1..."
curl -sf -X POST "$GITEA/api/v1/repos/studio/sol/issues/1/comments" \
-H 'Content-Type: application/json' \
-u "$ADMIN_USER:$ADMIN_PASS" \
-d '{"body":"Bootstrap test comment for integration testing."}' \
> /dev/null 2>&1 || true
echo ""
echo "Gitea bootstrap complete."
echo " Admin: $ADMIN_USER / $ADMIN_PASS"
echo " Org: studio"
echo " Repos: ${REPOS[*]}"
echo " URL: $GITEA"
if [ "$PAT" != "already-provisioned" ] && [ -n "$PAT" ]; then
echo ""
echo "Add to .env:"
echo " GITEA_PAT=$PAT"
fi