Files
tgit/infra/uploads-template/.sourcecraft/ci.yaml
T
ElebobaandClaude Opus 5.5 c443190bf4
CI / ruff · mypy · pytest (pull_request) Successful in 4m3s
feat(runner): tgit-runner — сервисы в песочнице на хосте, деплой после push (#13)
- infra/runner/tgit-runner: deploy/restart/remove/list по SSH forced command;
  аргументы не исполняются и не глобятся; архив — только файлы и папки,
  без «..», ≤ 20 МБ, есть main.py; health_url — только localhost
- песочница: uid 10001, read-only, tmpfs noexec, cap-drop ALL,
  no-new-privileges, 128 МБ без swap, 0.25 CPU, 64 PID, --network none
  (сеть — только по egress-allow админа), лимит 10 сервисов, 2 образа
- новая версия стартует рядом (-next) и заменяет старую, только став
  healthy; иначе удаляется, старая работает, exit 3
- бот: после push git archive изменённых services/<name>/ → runner;
  автору — «🚀 работает» или «⛔ не развёрнут» с логом, команде — алерт ⛔;
  удалённая папка → remove; «♻️ Перезапустить» в «Статусе» для админа (S-5)
- examples/escape_attempts: все попытки выбраться — BLOCKED на живом Docker
- install.sh, authorized_keys.example; CD бота обновляет runner на хосте

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 15:36:29 +03:00

53 lines
2.2 KiB
YAML

# CI/CD репозитория загрузок tgit. Шаблон живёт в HSE/tgit: infra/uploads-template/ — правки делать там.
# Бот не даёт менять .sourcecraft/ и .tgit/ из Telegram (SPEC C-16).
on:
push:
- workflows: [check-and-deploy]
filter:
branches: ["main"]
workflows:
check-and-deploy:
settings:
max_cube_duration: 10m
tasks:
- name: check
cubes:
# The API doesn't tell which commit a run is for — the bot reads it from this log (ADR-014). Keep it first.
- name: meta
image: ghcr.io/astral-sh/uv:0.8-python3.12-bookworm-slim
script:
- echo "TGIT_COMMIT_SHA=$SOURCECRAFT_COMMIT_SHA"
- name: compile
needs: ["-"]
image: ghcr.io/astral-sh/uv:0.8-python3.12-bookworm-slim
script:
- python -m compileall -q -x '(^|/)\.' .
- name: lint
needs: ["-"]
image: ghcr.io/astral-sh/uv:0.8-python3.12-bookworm-slim
script:
- uvx ruff@0.13 check .
- name: security
needs: ["-"]
image: ghcr.io/astral-sh/uv:0.8-python3.12-bookworm-slim
script:
- uvx bandit@1.8 -q -r services -ll
- name: tests
needs: ["-"]
image: ghcr.io/astral-sh/uv:0.8-python3.12-bookworm-slim
script:
- python .tgit/run_tests.py
- name: deploy
needs: [check]
cubes:
- name: deploy
# full (non-slim) image: has git for diffing the pushed commit
image: ghcr.io/astral-sh/uv:0.8-python3.12-bookworm
script:
- python .tgit/changed_services.py > changed.txt
- cat changed.txt
# Разворачивает бот сразу после push (tgit-runner, #13); здесь — только список для лога.
# Когда CI переедет сюда целиком (#11), бот будет ждать зелёного check перед деплоем.
- 'echo "$(wc -l < changed.txt) service(s) changed — deployed by the bot via tgit-runner"'