From 0c8f1f790b8e0403f5c97696a262b5615ad36dfc Mon Sep 17 00:00:00 2001 From: Lacky1234union Date: Mon, 19 Oct 2026 00:37:04 +0300 Subject: [PATCH] =?UTF-8?q?fix(config):=20=D0=BF=D0=BE=D0=BB=D0=B5=20uploa?= =?UTF-8?q?ds=5Fci=20=D0=B2=D0=BC=D0=B5=D1=81=D1=82=D0=BE=20ci=20=E2=80=94?= =?UTF-8?q?=20=D1=80=D0=B0=D0=BD=D0=BD=D0=B5=D1=80=D1=8B=20CI=20=D0=B2?= =?UTF-8?q?=D1=8B=D1=81=D1=82=D0=B0=D0=B2=D0=BB=D1=8F=D1=8E=D1=82=20CI=3Dt?= =?UTF-8?q?rue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit У Settings нет префикса env, поэтому переменная CI=true с раннера Gitea попадала в поле ci и роняла создание настроек во всех тестах. Refs #11 Co-Authored-By: Claude Opus 5.5 --- app/config.py | 3 ++- app/main.py | 10 +++++----- tests/test_config.py | 10 +++++++++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/config.py b/app/config.py index 6b0829a..82e81a0 100644 --- a/app/config.py +++ b/app/config.py @@ -148,7 +148,8 @@ class Settings(BaseSettings): llm: LLMSettings = Field(default_factory=LLMSettings) sourcecraft: SourceCraftSettings = Field(default_factory=SourceCraftSettings) git: GitSettings = Field(default_factory=GitSettings) - ci: CISettings = Field(default_factory=CISettings) + # not `ci`: Settings has no env prefix, and CI runners export CI=true + uploads_ci: CISettings = Field(default_factory=CISettings) docker: DockerSettings = Field(default_factory=DockerSettings) runner: RunnerSettings = Field(default_factory=RunnerSettings) runtime: RuntimeSettings = Field(default_factory=RuntimeSettings) diff --git a/app/main.py b/app/main.py index 2e642b2..4ea75bf 100644 --- a/app/main.py +++ b/app/main.py @@ -100,7 +100,7 @@ async def run(settings: Settings) -> None: ) repo = UploadsRepo(settings.git) runner = RunnerClient(settings.runner) if settings.runner.host else None - ci = make_ci(settings.ci) + ci = make_ci(settings.uploads_ci) deployer = Deployer(repo, runner, alerts) if runner else None # Without CI and runner there is nothing to watch: the push message just says what was pushed pipeline = ( @@ -111,9 +111,9 @@ async def run(settings: Settings) -> None: ci, deployer, commit_url_template=settings.git.commit_url_template, - poll_interval=settings.ci.poll_interval, - max_poll_interval=settings.ci.max_poll_interval, - run_timeout=timedelta(minutes=settings.ci.run_timeout_minutes), + poll_interval=settings.uploads_ci.poll_interval, + max_poll_interval=settings.uploads_ci.max_poll_interval, + run_timeout=timedelta(minutes=settings.uploads_ci.run_timeout_minutes), ) if ci or deployer else None @@ -150,7 +150,7 @@ async def run(settings: Settings) -> None: "via proxy" if proxy else "direct", "on" if docker else "off", settings.llm.provider if agent else "off", - settings.ci.provider if ci else "off", + settings.uploads_ci.provider if ci else "off", settings.runner.host or "off", ) try: diff --git a/tests/test_config.py b/tests/test_config.py index a711c81..2cfc722 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -3,7 +3,7 @@ from pathlib import Path import pytest from pydantic import ValidationError -from app.config import AccessSettings +from app.config import AccessSettings, Settings from app.texts import load_texts @@ -21,3 +21,11 @@ def test_texts_with_missing_key_fail_fast(tmp_path: Path) -> None: (tmp_path / "texts.yaml").write_text("menu: {commit: x}\n", encoding="utf-8") with pytest.raises(ValidationError): load_texts(tmp_path) + + +def test_ci_runner_env_does_not_break_settings(monkeypatch: pytest.MonkeyPatch) -> None: + # Gitea/GitHub runners export CI=true; it must not collide with a settings field + monkeypatch.setenv("CI", "true") + monkeypatch.setenv("TELEGRAM_BOT_TOKEN", "42:x") + + assert Settings().uploads_ci.provider == "none"