Files
airdef/.gitea/workflows/build.yml
T
chexit 9b8ef1bcc8
build / mod (push) Failing after 9s
CI: keep the per-push job inside the runner's disk (#102)
Run 140, the first green build since 2 November, knocked Gitea's database
over: from 19:42:52 UTC, right after the mod test binaries were written,
the API answered 500 and 401 and ssh said 'the database system is in
recovery mode' until 19:53:28, eighteen seconds after the job had ended and
its workspace was gone. The tests themselves are innocent (ground_oom peaks
at 113 MiB RSS); what the job leaves behind is not. rustup installed stable
and then the pinned 1.99.1 on top of it (about 1.1 GB), and the debug test
targets of the core and of the mod (669 MB for the mod alone) stayed on
disk through the release build. The runner shares that disk with Gitea and
its database; on 6 November release.yml found 1 GB free there.

The job now installs only the channel pinned in rust-toolchain.toml, deletes
each test target directory once its step is done, and refuses to start with
less than 4 GB free, with the same ::error:: wording as release.yml, after
printing df and free into the log. Both test suites stay complete.

Not verified on the server (no access there). The log now shows the free
space at the start, so the next run confirms or corrects the diagnosis.
2026-11-23 23:08:04 +03:00

94 lines
6.4 KiB
YAML
Raw 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.
# На каждый пуш: только мод (.hmod, один для всех ОС) и релиз build-<номер> с ним.
# Раннер живёт на одной машине с Gitea и другими сервисами (2 ядра, 4 ГБ): сборка мода лёгкая —
# один поток компиляции, низший приоритет, без системных пакетов и без кэша target.
# Диск у раннера тоже общий с базой Gitea: 23.11.2026, дойдя до тестов, джоба уронила базу до конца прогона.
# Поэтому один закреплённый тулчейн вместо stable поверх него и без каталогов target тестов к моменту сборки мода.
# Игра-форк здесь не собирается: только по тегу версии (release.yml, Windows) и вручную (game.yml Linux, desktop.yml macOS).
name: build
on:
# Branches only: the release's own tag (build-N) mustn't start another build.
push:
branches: ['**']
workflow_dispatch:
env:
CARGO_TERM_COLOR: never
CARGO_BUILD_JOBS: "1"
CARGO_INCREMENTAL: "0"
jobs:
mod:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
# Не начинать, когда места мало: иначе сборка займёт диск до конца, а база Gitea на нём падает.
- name: Ресурсы раннера
run: |
df -h / | tail -1
free -m | sed -n '1,2p'
FREE=$(df --output=avail -BM / | tail -1 | tr -dc 0-9)
if [ "$FREE" -lt 4000 ]; then echo "::error::на сервере свободно ${FREE} МБ, нужно хотя бы 4000"; exit 1; fi
# Только закреплённый тулчейн из rust-toolchain.toml: stable ставился раньше и лежал мёртвым грузом.
- name: Rust
run: |
CHANNEL=$(sed -n 's/^channel = "\(.*\)"$/\1/p' rust-toolchain.toml)
if [ -z "$CHANNEL" ]; then echo "::error::rust-toolchain.toml: не прочитан channel"; exit 1; fi
curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain "$CHANNEL" --target wasm32-unknown-unknown
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
# Без actions/cache: кэш-сервер раннера из контейнеров задач недоступен — восстановление
# падало по таймауту, а сохранение вешало «Complete job» на пару минут. Инструмент собирается заново.
- name: Форк Horizon
run: nice -n 19 python3 tools/airdef.py fork
- name: Проверка закреплённого checkout
run: python3 -m unittest discover -s tools -p test_engine_checkout.py
# Системный Python образа — externally managed (PEP 668): без --break-system-packages pip отказывает,
# и тесты со сборкой ниже вообще не запускаются. Контейнер задачи одноразовый, так что --user безопасен.
- name: Проверка generated assets
run: |
python3 -m pip install --user --break-system-packages -r tools/requirements.txt
python3 tools/gen_catalog.py --check
python3 -m unittest discover -s tools -p test_sound_catalog.py
python3 tools/gen_models.py --check
python3 -m unittest discover -s tools -p test_model_bounds.py
# После тестов их каталог target не нужен (модуль собирается под wasm заново), а на диске его место.
- name: Тесты ядра без SDK
working-directory: airdef-core
run: |
HOST=$(rustc -vV | sed -n 's/^host: //p')
nice -n 19 cargo test --target "$HOST"
rm -rf target
- name: Тесты мода
working-directory: airdef-mod
run: |
HOST=$(rustc -vV | sed -n 's/^host: //p')
nice -n 19 cargo test --target "$HOST"
rm -rf target
- name: Мод
run: nice -n 19 python3 tools/airdef.py mod
- name: Релиз
if: github.ref == 'refs/heads/main'
env:
TOKEN: ${{ secrets.RELEASE_TOKEN || gitea.token }}
API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
TAG: build-${{ github.run_number }}
SHA: ${{ github.sha }}
run: |
set -e
mkdir -p out
cp airdef-mod/target/horizon-mod/airdef.hmod out/airdef.hmod
cp airdef-mod/target/horizon-mod/build-identity.json out/build-identity.json
BODY=$(printf 'Сборка %s (%s).\n\n- airdef.hmod — мод, для всех ОС.\n\nИгра-форк Horizon (нужна для мода): собрать у себя — python3 tools/airdef.py all, или скачать из большого релиза v* (Windows), или запустить вручную workflow game (Linux) / desktop (macOS) с этим тегом.\nКак запускать: docs/INSTALL.md.' "$TAG" "$SHA")
DATA=$(BODY="$BODY" python3 -c 'import json,os;print(json.dumps({"tag_name":os.environ["TAG"],"target_commitish":os.environ["SHA"],"name":os.environ["TAG"],"body":os.environ["BODY"]}))')
if [ -z "$TOKEN" ]; then echo "::error::нет токена: добавь секрет RELEASE_TOKEN"; exit 1; fi
CODE=$(curl -sS -o release.json -w '%{http_code}' -X POST -H "Authorization: token $TOKEN" -H "Content-Type: application/json" "$API/releases" -d "$DATA")
if [ "$CODE" != "201" ]; then
echo "::error::Gitea не создала релиз (HTTP $CODE): $(cat release.json). Проверь секрет RELEASE_TOKEN (токен с правом записи в репозиторий)."
exit 1
fi
ID=$(python3 -c 'import json;print(json.load(open("release.json"))["id"])')
curl -sf -X POST -H "Authorization: token $TOKEN" -F "attachment=@out/airdef.hmod" "$API/releases/$ID/assets?name=airdef.hmod" > /dev/null
curl -sf -X POST -H "Authorization: token $TOKEN" -F "attachment=@out/build-identity.json" "$API/releases/$ID/assets?name=build-identity.json" > /dev/null