CI / test (pull_request) Successful in 45s
tests/core/bot_contract.test.js copies the bot's AtlasPolicy.advise (DragonKind src/atlasPolicy.js at ebe134a2) and plays the bot's own recorded screens through it for every colour, sample and goal; checks the Black is routed through both gates and up the tree; checks every assignment of the experiment plan is playable; checks the known answers' shape. Added to npm run test:unit. push-policy now also sends data/public/experiments.json and tree.json, which docs/BOT_INTEGRATION.md says the bot reads (Solver.assign, screenPick) but which were never delivered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
67 lines
3.6 KiB
YAML
67 lines
3.6 KiB
YAML
# When the route model changes on main, send it to the bot: open (or update) a pull request on the bot's repo,
|
|
# DragonKind/DragonKind, that replaces vendor/threshing-atlas/{policy.json,solver.js,graph.js,known_answers.json,
|
|
# experiments.json,tree.json} with this repo's data/public/policy.json, core/solver.js, core/graph.js,
|
|
# data/public/known_answers.json, data/public/experiments.json and data/public/tree.json. They always travel together, so
|
|
# the policy, the experiment plan and the solver that reads them never get out of step (docs/BOT_INTEGRATION.md).
|
|
# tests/core/bot_contract.test.js runs the bot's own call chain against them in CI. Ken reviews and merges it; the running bot reloads the files after a pull.
|
|
#
|
|
# Secrets: ATLAS_BOT_TOKEN (repository: read and write, with write access to DragonKind/DragonKind).
|
|
name: Send the route model to the bot
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- data/public/policy.json
|
|
- core/solver.js
|
|
- core/graph.js
|
|
- data/public/known_answers.json
|
|
- data/public/experiments.json
|
|
- data/public/tree.json
|
|
workflow_dispatch:
|
|
jobs:
|
|
send:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
token: ${{ secrets.ATLAS_BOT_TOKEN }}
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
- run: pip install -r requirements.txt # `python -m collection` loads the whole package
|
|
- name: Open or update the pull request on the bot's repo
|
|
env:
|
|
ATLAS_BOT_TOKEN: ${{ secrets.ATLAS_BOT_TOKEN }}
|
|
run: |
|
|
set -e
|
|
dst="$RUNNER_TEMP/dragonkind"
|
|
export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0="http.https://git.kenschiano.net/.extraheader" \
|
|
GIT_CONFIG_VALUE_0="AUTHORIZATION: token $ATLAS_BOT_TOKEN"
|
|
git clone --quiet --depth 1 https://git.kenschiano.net/DragonKind/DragonKind.git "$dst"
|
|
mkdir -p "$dst/vendor/threshing-atlas"
|
|
cp data/public/policy.json core/solver.js core/graph.js data/public/known_answers.json \
|
|
data/public/experiments.json data/public/tree.json "$dst/vendor/threshing-atlas/"
|
|
id=$(python3 -c "import json; print(json.load(open('data/public/policy.json')).get('id', ''))")
|
|
sha=$(git rev-parse --short HEAD)
|
|
cd "$dst"
|
|
if [ -z "$(git status --porcelain -- vendor/threshing-atlas)" ]; then
|
|
echo "The bot already has route model $id."; exit 0
|
|
fi
|
|
git config user.name "Atlas data bot"
|
|
git config user.email "atlas-bot@noreply.localhost"
|
|
git checkout -q -b atlas/route-model
|
|
git add vendor/threshing-atlas
|
|
git commit -q -m "Threshing Atlas route model $id (atlas $sha)"
|
|
git push -q --force origin atlas/route-model
|
|
cd "$GITHUB_WORKSPACE"
|
|
printf '%s\n' \
|
|
"The Threshing Atlas route model changed (policy \`$id\`, atlas commit \`$sha\`)." \
|
|
"" \
|
|
"This replaces \`vendor/threshing-atlas/\` (policy.json, solver.js, graph.js, known_answers.json, experiments.json, tree.json) together, as \`npm run atlas:sync\` would." \
|
|
"This pull request is updated in place each time the model changes. After merging, pull on the bot's machine:" \
|
|
"the running bot reloads the files on its next decision." \
|
|
"" \
|
|
"Opened automatically by the Atlas's push-policy workflow." > "$RUNNER_TEMP/body.md"
|
|
python -m collection forge open-pr --repo DragonKind/DragonKind --base main --head atlas/route-model \
|
|
--title "Threshing Atlas route model update" --body-file "$RUNNER_TEMP/body.md"
|