Compare commits

...

3 Commits

Author SHA1 Message Date
Claude
b42d24c477 README: час збірок після кешу й паралельних тестів
All checks were successful
build / build (push) Successful in 37s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017HrHZxjRNfPF6rNJTvBXnq
2026-11-25 16:00:17 +00:00
Gitea Actions
90d7440756 template.sha256: rebuilt template-4.7.2 2026-11-25 15:58:49 +00:00
Claude
25bf505bab CI швидше: тести й сіди бота паралельно (тег пропускає тести, якщо коміт уже пройшов на main); шаблон і образ збираються BuildKit з кешем (тулчейн, вихідні коди, об'єкти scons)
All checks were successful
build / build (push) Successful in 35s
ci-image / image (push) Successful in 3m15s
template / template (push) Successful in 14m27s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017HrHZxjRNfPF6rNJTvBXnq
2026-11-25 15:40:30 +00:00
8 changed files with 77 additions and 35 deletions

View File

@@ -25,19 +25,37 @@ jobs:
working-directory: source_godot
run: godot --version && godot --headless --path . --import
- name: Tests
run: GODOT=godot sh source_godot/run_tests.sh
- name: Balance bot (several seeds, every difficulty, both endings, endless)
- name: Tests and balance bot (in parallel; a tag skips them if this commit already passed on main)
working-directory: source_godot
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# seed:difficulty (0 novice, 1 normal, 2 paranoid):choices in the Act IV and Act V finals
fail=0
case "$GITHUB_REF" in refs/tags/*)
if curl -sf -H "Authorization: token $TOKEN" "http://gitea:3000/api/v1/repos/$GITHUB_REPOSITORY/actions/tasks?limit=50" | python3 -c '
import json, os, sys
ok = any(t["name"] == "build" and t["head_branch"] == "main" and t["head_sha"] == os.environ["GITHUB_SHA"]
and t["status"] == "success" for t in json.load(sys.stdin)["workflow_runs"])
sys.exit(0 if ok else 1)'; then
echo "commit $GITHUB_SHA already passed the tests on main: skipped"; exit 0
fi;;
esac
# every Godot process gets its own user:// (XDG_DATA_HOME), because the tests reuse save file names
L=/tmp/ci; mkdir -p $L
run() { n=$1; shift; (env XDG_DATA_HOME=$L/u_$n "$@" > $L/$n.log 2>&1; echo $? > $L/$n.rc) & }
run tests env GODOT=godot sh run_tests.sh
# balance bot: seed:difficulty (0 novice, 1 normal, 2 paranoid):choices in the Act IV and Act V finals
for c in 1:1:22 2:1:11 3:1:22 4:0:11 5:2:22 7:2:11; do
s=$(echo $c | cut -d: -f1); d=$(echo $c | cut -d: -f2); ch=$(echo $c | cut -d: -f3)
r=$(BAL_DIFF=$d BAL_CHOICE=$ch BAL_ENDLESS=1 godot --headless --path . -s tests/balance.gd -- $s 2>&1) || fail=1
echo "seed $s diff $d choice $ch: $(echo "$r" | grep -E '^(НЕСКІНЧЕННА|КІНЕЦЬ|OK|FAIL)' | tr '\n' ' ')"
run "bal_$s" env BAL_DIFF=$d BAL_CHOICE=$ch BAL_ENDLESS=1 godot --headless --path . -s tests/balance.gd -- $s
done
wait
cat $L/tests.log
fail=0
for c in 1:1:22 2:1:11 3:1:22 4:0:11 5:2:22 7:2:11; do
s=${c%%:*}
echo "seed $c: $(grep -E '^(НЕСКІНЧЕННА|КІНЕЦЬ|OK|FAIL)' $L/bal_$s.log | tr '\n' ' ')"
done
for r in $L/*.rc; do [ "$(cat $r)" = 0 ] || { fail=1; echo "FAILED: $(basename $r .rc)"; cat ${r%.rc}.log | tail -30; }; done
exit $fail
- name: Export Windows exe

View File

@@ -1,6 +1,7 @@
# Rebuilds the small Windows export template (tools/template_custom.py) from Godot sources on the server,
# replaces TinMerezhi-template.exe in the prerelease template-<ver>, commits the new tools/template.sha256
# and rebuilds the CI image. ~20-40 min on 8 cores, up to ~8 GB RAM (lto=full), ~6 GB disk while it runs.
# and rebuilds the CI image. First build ~15 min on 8 cores, a profile change rebuilds only what it touches,
# an unchanged profile ~1 min (Docker cache). Up to ~8 GB RAM (lto=full), ~6 GB disk in the Docker build cache.
name: template
on:
push:
@@ -17,26 +18,18 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Toolchain (scons, mingw-w64 with posix threads)
- name: Build template (Docker, cached toolchain and objects)
run: |
apt-get update -qq
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends scons mingw-w64 >/dev/null
update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix
update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix
x86_64-w64-mingw32-gcc --version | head -1; scons --version | tail -1
- name: Build template
working-directory: /tmp
run: |
time sh "$GITHUB_WORKSPACE/source_godot/tools/build_template.sh"
ls -l godot-$GODOT_VER-stable/bin/godot.windows.template_release.x86_64.exe
. ci/docker_cli.sh
time docker buildx build --build-arg GODOT_VER=$GODOT_VER -f ci/template.Dockerfile --output type=local,dest=/tmp/tpl source_godot/tools
ls -l /tmp/tpl/template.exe
- name: Upload to the prerelease, commit the checksum
env:
TOKEN: ${{ secrets.RELEASE_TOKEN || secrets.GITHUB_TOKEN }}
API: http://gitea:3000/api/v1/repos/${{ github.repository }}
run: |
EXE=/tmp/godot-$GODOT_VER-stable/bin/godot.windows.template_release.x86_64.exe
EXE=/tmp/tpl/template.exe
TAG=template-$GODOT_VER
H="Authorization: token $TOKEN"
getid() { python3 -c 'import json,sys; print(json.load(sys.stdin)["id"])'; }

View File

@@ -4,13 +4,10 @@
set -e
VER="${GODOT_VER:-4.7.2}"
REPO="${GITHUB_REPOSITORY:-junior/TinMerezhi}"
if ! command -v docker >/dev/null; then
curl -sSL --fail -o /tmp/docker.tgz https://download.docker.com/linux/static/stable/x86_64/docker-27.5.1.tgz
tar xzf /tmp/docker.tgz -C /tmp && install /tmp/docker/docker /usr/local/bin/docker
fi
. ci/docker_cli.sh
curl -sSL --fail -o ci/template.exe "http://gitea:3000/$REPO/releases/download/template-$VER/TinMerezhi-template.exe"
echo "$(cat source_godot/tools/template.sha256) ci/template.exe" | sha256sum -c -
docker build --pull=false --build-arg GODOT_VER="$VER" -t "tinmerezhi-ci:$VER" ci
docker buildx build --build-arg GODOT_VER="$VER" -t "tinmerezhi-ci:$VER" ci
rm -f ci/template.exe
docker image prune -f >/dev/null # drop the previous untagged image
docker image prune -f >/dev/null # drop the previous untagged image; build cache stays for the next run
docker images tinmerezhi-ci

12
ci/docker_cli.sh Normal file
View File

@@ -0,0 +1,12 @@
#!/bin/sh
# Docker CLI + buildx (BuildKit: layer cache and cache mounts) for jobs; the daemon is the host one via /var/run/docker.sock.
set -e
command -v docker >/dev/null || {
curl -sSL --fail -o /tmp/docker.tgz https://download.docker.com/linux/static/stable/x86_64/docker-27.5.1.tgz
tar xzf /tmp/docker.tgz -C /tmp && install /tmp/docker/docker /usr/local/bin/docker
}
docker buildx version >/dev/null 2>&1 || {
mkdir -p ~/.docker/cli-plugins
curl -sSL --fail -o ~/.docker/cli-plugins/docker-buildx https://github.com/docker/buildx/releases/download/v0.19.3/buildx-v0.19.3.linux-amd64
chmod +x ~/.docker/cli-plugins/docker-buildx
}

16
ci/template.Dockerfile Normal file
View File

@@ -0,0 +1,16 @@
# Small Windows export template (source_godot/tools/template_custom.py), built by template.yml:
# docker buildx build -f ci/template.Dockerfile --output type=local,dest=out source_godot/tools
# The toolchain is a cached layer; the Godot sources and scons objects live in a BuildKit cache mount,
# so a rebuild only recompiles what the new profile changes.
FROM debian:bookworm-slim AS build
RUN apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends \
scons mingw-w64 python3 curl ca-certificates xz-utils >/dev/null \
&& update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix \
&& update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix
ARG GODOT_VER=4.7.2
COPY template_custom.py build_template.sh /tools/
RUN --mount=type=cache,target=/work cd /work && GODOT_VER=$GODOT_VER sh /tools/build_template.sh \
&& mkdir /out && cp godot-$GODOT_VER-stable/bin/godot.windows.template_release.x86_64.exe /out/template.exe
FROM scratch
COPY --from=build /out/template.exe /

View File

@@ -72,7 +72,8 @@
(інша версія Godot або інші модулі) збирає на сервері workflow `template.yml`: сам, коли змінюється
`tools/template_custom.py`, або вручну (Actions → template → Run workflow). Він кладе exe в пререліз
`template-<версія>` як `TinMerezhi-template.exe`, комітить новий `tools/template.sha256` і перезбирає CI-образ
(~20–40 хв, до ~8 ГБ RAM, ~6 ГБ диска). Пререліз не бачить
(перший раз ~15 хв, без змін профілю ~20 с; кеш Docker зберігає тулчейн, вихідні коди й об'єкти scons, тож зміна профілю перезбирає
лише зачеплене; до ~8 ГБ RAM, ~6 ГБ диска). Пререліз не бачить
автооновлення гри (`/releases/latest` віддає лише звичайні релізи). Нові класи рушія в коді: перевір, що їх не вимкнено.
## Реліз
@@ -83,4 +84,6 @@
Збірка йде в локальному Docker-образі `tinmerezhi-ci:4.7.2` (`ci/Dockerfile`: Godot, малий шаблон, fontTools,
go-winres, butler), тож нічого не завантажується щоразу. Образ перезбирає workflow `ci-image.yml`
(сам при зміні `ci/` або `tools/template.sha256`, або вручну); якщо збірка каже, що образу немає, запусти його.
Тести й шість сідів бота балансу йдуть паралельно (~35 с на push). Тег не повторює тести, якщо цей самий коміт
уже пройшов їх на `main`, тож реліз займає менше хвилини.
Гра бачить новий реліз сама (`updater.gd`).

View File

@@ -1,13 +1,16 @@
#!/bin/sh
# Builds the small Windows export template (tools/template_custom.py) from Godot sources.
# Needs: python3 + scons, mingw-w64 (posix threads). About 40 min on 4 cores, ~6 GB RAM, ~5 GB disk.
# Result: godot-<ver>-stable/bin/godot.windows.template_release.x86_64.exe -> upload it to the Gitea
# prerelease "template-<ver>" as TinMerezhi-template.exe and put its sha256 into tools/template.sha256.
# Needs: python3 + scons, mingw-w64 (posix threads). ~13 min on 8 cores (first build), ~8 GB RAM, ~5 GB disk.
# Run again in the same folder: the sources are kept and scons rebuilds only what changed.
# Result: godot-<ver>-stable/bin/godot.windows.template_release.x86_64.exe. On the server this is done by
# the workflow template.yml (ci/template.Dockerfile), which also uploads it and updates tools/template.sha256.
set -e
VER="${GODOT_VER:-4.7.2}"
HERE="$(cd "$(dirname "$0")" && pwd)"
curl -sSL --fail -o "godot-$VER.tar.xz" "https://github.com/godotengine/godot/releases/download/$VER-stable/godot-$VER-stable.tar.xz"
tar xf "godot-$VER.tar.xz"
if [ ! -f "godot-$VER-stable/SConstruct" ]; then
curl -sSL --fail -o "godot-$VER.tar.xz" "https://github.com/godotengine/godot/releases/download/$VER-stable/godot-$VER-stable.tar.xz"
tar xf "godot-$VER.tar.xz" && rm "godot-$VER.tar.xz"
fi
cd "godot-$VER-stable"
scons profile="$HERE/template_custom.py" d3d12=no vulkan=no winrt=no accesskit=no angle=no -j"$(nproc)"
sha256sum bin/godot.windows.template_release.x86_64.exe

View File

@@ -1 +1 @@
ce187c0defb7e2b543cf8f659db7d2e1bb8b2583322433f56274fb7ec10f2bfd
5a3eda63d88b32bd07e6139103232403318ff5c0a8dadc04ea1a8d51bbe7550e