A Django web app for running automated SC2 bot matches and tracking the results. It wraps the AI Arena local-play-bootstrap infrastructure in Docker, so your bot plays in the same environment it uses on the AI Arena ladder — but locally, under your control.
What you get:
- Four match types — vs Blizzard AI, vs custom bots (any aiarena-supported type: Python, C++, Java, …), vs past versions of your own bot (git A/B), and replay-continuation tests
- Test suites — bundle matchups into suites (default: the 15 Blizzard AI variants — 3 races × 5 builds) and run them with one click
- Tickets — agent prompts for AI-assisted development, each ticket working in its own git worktree, with tests triggered on commit
- Results, logs & replays — every match records its result, full bot logs, and replay download
- API —
POST /api/trigger-tests/to fire matches or suites from scripts, git hooks, or CI, and a token-authenticatedPOST /api/trigger-gate/+GET /api/gate-status/<run_id>/pair that plays a branch series against a baseline and returns a verdict
Every match, suite run, and test group is keyed to the bot under test, so different bots keep completely separate experiment histories.
See ROADMAP.md for where this is heading: regression verdicts, GitHub-native CI, and continuous deployment for bots.
This is intended to work for all bot types but some types are untested. It's all very WIP so feel free to send a PR — I won't be too picky about merging it.
- Docker (running)
- Python 3.12+
- StarCraft II maps on the host (a directory of
.SC2Mapfiles)
Use this if you've cloned test_lab on its own and want to get it running quickly. The only prerequisites are Docker (running), Python 3.12+, and StarCraft II installed (for map files).
Why not fully Dockerize Django too? The match runner launches SC2 Docker containers from the Django process using
docker composewith host-path volume mounts. Running Django itself inside Docker would require Docker-in-Docker with complex host/container path mapping that is fragile across OSes. Keeping Django on the host avoids this entirely.
Clone, run one command, and the browser opens automatically:
mkdir sc2_test_lab && cd sc2_test_lab
git clone <test_lab_repo_url> test_lab
python test_lab/quickstart/setup.pyThe script handles everything: starts MySQL in Docker, creates a virtual environment, installs dependencies, runs migrations, and launches the development server. It works on Windows, Linux, and macOS.
On Debian/Ubuntu you may need
sudo apt install python3-venvfirst.
Click to expand manual steps
#### 1. Clone into the right directory structureDjango needs test_lab to be an importable Python package, so clone it
inside a wrapper directory:
mkdir sc2_test_lab && cd sc2_test_lab
git clone git@github.com:chadspratt/sc_bot_test_lab.git test_labYour layout should look like:
sc2_test_lab/ # <-- you'll run commands from here
test_lab/ # <-- the cloned repo
quickstart/
aiarena/
models.py
...
docker compose -f test_lab/quickstart/docker-compose.yml up -dThis starts a MySQL 8.0 container on localhost:3306 with database sc_bot
(user root, password testlab). Adjust credentials in the compose file or
via environment variables — see quickstart/settings.py for the full list.
python -m venv venv
# Windows
venv\Scripts\activate
# Linux / macOS
source venv/bin/activate
pip install -r test_lab/requirements.txtpython test_lab/quickstart/manage.py migrate --database default
python test_lab/quickstart/manage.py migrate test_lab --database sc_bot_test_labpython test_lab/quickstart/manage.py runserverOpen http://localhost:8000/test_lab/ in your browser.
# Stop MySQL (data is preserved in a Docker volume)
docker compose -f test_lab/quickstart/docker-compose.yml down
# Stop MySQL and delete all data
docker compose -f test_lab/quickstart/docker-compose.yml down -vDjango's built-in dev server cannot parse chunked transfer-encoding, which
many reverse proxies (e.g. tailscale serve) use for POST requests — form
submissions behind such a proxy will fail with 403 (CSRF token missing).
For remote access, run a real WSGI server instead and opt in to forwarded
headers:
pip install waitress
# Example: expose at https://your-host.ts.net:8443/test_lab/ via `tailscale serve`
TEST_LAB_CSRF_TRUSTED_ORIGINS="https://your-host.ts.net:8443" \
TEST_LAB_USE_FORWARDED=1 \
python -m waitress --listen=0.0.0.0:8000 test_lab.quickstart.wsgi:applicationTEST_LAB_CSRF_TRUSTED_ORIGINS— comma-separated list of proxy origins trusted for CSRF (scheme + host + port must match exactly).TEST_LAB_USE_FORWARDED=1— honorX-Forwarded-Host/X-Forwarded-Proto.
Both default to unset, so local runserver setups are unaffected.
If you're adding test_lab to an existing Django project instead of using the quickstart, follow these steps.
test_lab uses its own MySQL database (the router in quickstart/db_router.py
sends all test_lab models to the sc_bot_test_lab alias — define it in your
project's settings). Run migrations with:
python manage.py migrate test_lab --database sc_bot_test_labIn the app, go to Config > System and enter the path for the directory containing the maps.
Also enter the path to SC2Switcher.exe to enable launching replays from the app.
Go to Config > Custom Bots and follow the instructions for adding a bot.
A bot marked as a test subject can act as Player 1 in matches. Source Path defaults to the aiarena package but you can change this to point to your live development code
Symlinks/junctions in the source directory are auto-detected and stored so Docker volume mounts resolve correctly.
On Run Match > Vs Blizzard AI you can trigger a test run of the bot vs the Blizzard AI. The first run may take a while to build docker images
There are 4 kinds of matches that can be run. the Run Match page allows running an individual match
- Blizzard AI - custom bot vs in-game bot
- Custom Bot - custom bot vs custom bot The form shows the git state of the selected test bot's source checkout (branch, short commit, clean/dirty). The optional Source branch dropdown mounts the bot from a worktree of that branch instead of its working tree.
- Past Version - custom bot vs itself. can be use a past version or the current version for a true mirror match
- Replay - custom bot vs in-game bot, but you start from a game state that is pulled from a replay. Will require some edits for a custom bot to make good use of this, since the misleading clock and lack of game state will probably trip up all but the simplest bots.
Config > Test Suites allows you to bundle different matchups in to a suite that can be run. There is a default Blizzard AI suite for running vs 15 variants of the Blizzard AI (3 races * 5 builds). Test Suites can be attached to Tickets to be run automatically
Tickets is a system for generating agent prompts that can be run in the editor of your choice.
The prompt instructs the agent to work in a git worktree so that multiple tickets can be worked on concurrently.
After finishing the work, the agent is instructed to commit and trigger the ticket tests, which will run against the code in the worktree
Config > Prompt Templates Allows for creating custom templates for working on specific bots. There are forms for creating and editing them but they are stored in actual files so it's probably easier to edit manage them with a normal text editor. In the app you can register them to specific bots. When creating a ticket you can choose from registered templates for the bot or, if there are none, the default prompt.
Any two test groups can be compared side by side on the Results → Compare tab — every stat derives from the groups' own match data, so it works for any experiment:
- Run your two conditions. Each condition is just a test group:
use a description that names the condition (e.g. "MyBot vs
Clicadinha — rush build" vs "MyBot vs Clicadinha — macro build").
Matches land in their own group automatically when triggered as a
suite, or set
descriptionper match via the API. - Open Results → Compare and pick the two groups from the
dropdowns (or link directly:
/test_lab/?tab=compare&a=3&b=4).
You get win rate, W/L record, average + median game duration split by outcome, fast-loss %, cumulative win-rate trend, and the per-game duration scatter — the same dashboard for any pairing, not just the rush-defense experiment the lab was originally built around.
To automatically trigger a test suite on every commit, add a post-commit
hook to the bot's git repo:
#!/bin/sh
# Post-commit hook: trigger test_lab test suite via the Django API
# Replace TEST_BOT_ID with the bot's numeric ID from the Custom Bots page.
BRANCH=$(git rev-parse --abbrev-ref HEAD)
SHORT_SHA=$(git rev-parse --short HEAD)
COMMIT_MSG=$(git log -1 --format=%s)
DESCRIPTION="$BRANCH $SHORT_SHA: $COMMIT_MSG"
curl -s -X POST http://localhost:8000/test_lab/api/trigger-tests/ \
-H "Content-Type: application/json" \
-d "{\"description\": \"$DESCRIPTION\", \"difficulty\": \"CheatInsane\", \"test_bot_id\": TEST_BOT_ID}" \
> /dev/null 2>&1 &
echo "Test suite triggered for commit $SHORT_SHA"Save this as .git/hooks/post-commit and make it executable (chmod +x).
JSON body:
| Field | Type | Default | Description |
|---|---|---|---|
test_bot_id |
int | required | Custom bot ID for Player 1 (the test subject) |
difficulty |
string | "CheatInsane" |
AI difficulty level |
description |
string | "" |
Test group description |
custom_bot_id |
int | null | When set, runs a single match vs this bot instead of the full test suite |
test_suite_id |
int | null | Run a specific test suite (falls back to the bot's default suite, then "Blizzard AI") |
branch |
string | "" |
Git branch name — creates a worktree so the bot source is mounted from that branch |
Runs a gate series: the same roster series is played on the branch under
test and on a baseline ref, and the two are compared with a noise band.
Requires the shared bridge token in the X-Lab-Bridge-Token header (or
Authorization: Bearer <token>); the token comes from the
LAB_BRIDGE_TOKEN environment variable — an unset token disables the
endpoint instead of serving it unauthenticated.
JSON body:
| Field | Type | Default | Description |
|---|---|---|---|
repo_url |
string | required | Repo whose branch is under test — must match the registered test bot's source repository |
branch |
string | required | Branch to test (worktree created/reused by the regular branch machinery, with its submodules checked out) |
test_bot_id |
int | required | Custom bot ID for Player 1 (the test subject) |
opponent_bot_ids |
list[int] | required | Roster opponents for the series |
games_per_opponent |
int | 3 |
Games per opponent, per series |
baseline |
string | "master" |
Ref the baseline series is played on |
Returns {"run_id": <test_group_id>} immediately — the games are played in
the background. One gate run runs lab-wide at a time: a second request
gets 409 {"status": "busy", "run_id": <active_run_id>}.
The worktree of the branch and of the baseline is prepared with
git submodule update --init --recursive: git worktree add does not check
out submodules, so a bot that imports a pinned submodule would crash on
import. A submodule checkout that fails aborts the trigger with a clear
error instead of starting a series that can only crash.
A repo may also provide a prepare script — scripts/prepare_worktree.sh or
scripts/vendor_lab_deps.sh (first match wins) — for repos that vendor
dependencies git ignores (an in-tree engine library, a map analyzer, compiled
extensions): git restores none of those files in a worktree, so the lab runs
the repo's own script in the worktree instead of guessing which files
matter. A prepare script that fails aborts the trigger with the script name
and its stderr; repos without ignored dependencies need no script.
Same token header. Returns the run status (pending / running /
complete), the noise_band rule the verdict was computed with, the
verdict (pass / fail / invalid) once the run is complete, and the
raw per-opponent results of both the branch series and the baseline series
(wins, losses, crash counts, durations, game list) so a caller can apply
its own judging.
invalid means the run could not be judged: a series crashed in more than
half of its games, so the comparison says nothing about the branch (a
baseline that crashed every game would otherwise look like a baseline the
branch merely failed to beat, and the run would be judged pass). The
crash counts of both sides are in the payload (branch.crashes /
baseline.crashes).
python quickstart/manage.py test test_lab --settings=test_lab.quickstart.test_settingsThe test settings use SQLite, so the unit tests need neither MySQL nor Docker.