feat(bot): клиент SourceCraft API — прогоны, логи кубов, sha коммита, ретраи
- SourceCraftClient (httpx): list_runs, get_run, get_cube_logs (постранично), run_commit_sha; ретраи на сетевые ошибки и 5xx с экспоненциальной задержкой, 4xx — SourceCraftError без повторов - модели: RunStatus/EventType из swagger, «1970-01-01» = не задано, failed_cubes без служебных #-кубов - у прогона в API нет sha → куб check/meta в tgit-uploads печатает TGIT_COMMIT_SHA (ADR-014) - CLI: python -m app.sourcecraft.cli runs - тесты на реальных ответах API (фикстуры), порог покрытия 45 → 80 Refs #10 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -29,6 +29,18 @@ class AccessSettings(BaseSettings):
|
||||
return value
|
||||
|
||||
|
||||
class SourceCraftSettings(BaseSettings):
|
||||
model_config = SettingsConfigDict(**_ENV, env_prefix="SOURCECRAFT_")
|
||||
|
||||
token: SecretStr = SecretStr("")
|
||||
api_url: str = "https://api.sourcecraft.tech"
|
||||
uploads_repo: str = "rogachevegorushka/tgit-uploads"
|
||||
# Web link to a CI run. The SPA answers 200 on any path, so the format is unverified — adjust if it 404s in UI.
|
||||
run_url_template: str = "https://sourcecraft.dev/{repo}/cicd/runs/{run}"
|
||||
timeout: float = Field(default=30.0, gt=0)
|
||||
max_attempts: int = Field(default=5, ge=1)
|
||||
|
||||
|
||||
class RuntimeSettings(BaseSettings):
|
||||
model_config = _ENV
|
||||
|
||||
@@ -46,4 +58,5 @@ class Settings(BaseSettings):
|
||||
|
||||
telegram: TelegramSettings = Field(default_factory=TelegramSettings)
|
||||
access: AccessSettings = Field(default_factory=AccessSettings)
|
||||
sourcecraft: SourceCraftSettings = Field(default_factory=SourceCraftSettings)
|
||||
runtime: RuntimeSettings = Field(default_factory=RuntimeSettings)
|
||||
|
||||
Reference in New Issue
Block a user