fix(gtea): ruff format + check all gtea files and bridge.py
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing

Clears cc-ci self-test lint failures:
- ruff format: 9 files reformatted (all gtea test files + test_discovery.py)
- ruff check --fix: bridge.py UP017 (datetime.UTC alias) + 6 gtea check errors
- manifest.py B007: rename unused loop variable path → _path (no auto-fix available)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
autonomic-bot
2026-06-15 21:52:01 +00:00
co-authored by Claude Sonnet 4.6
parent d832b353e4
commit 2d865f06cb
11 changed files with 127 additions and 76 deletions
+35 -20
View File
@@ -42,6 +42,7 @@ def _ssl_ctx():
global _SSL_CTX
if _SSL_CTX is None:
import ssl
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
@@ -80,10 +81,17 @@ def _ensure_admin(domain: str) -> tuple[str, str]:
lifecycle.exec_in_app(
domain,
[
"gitea", "admin", "user", "create", "--admin",
"--username", _ADMIN_USER,
"--password", password,
"--email", _ADMIN_EMAIL,
"gitea",
"admin",
"user",
"create",
"--admin",
"--username",
_ADMIN_USER,
"--password",
password,
"--email",
_ADMIN_EMAIL,
"--must-change-password=false",
],
timeout=120,
@@ -93,9 +101,14 @@ def _ensure_admin(domain: str) -> tuple[str, str]:
lifecycle.exec_in_app(
domain,
[
"gitea", "admin", "user", "change-password",
"--username", _ADMIN_USER,
"--password", password,
"gitea",
"admin",
"user",
"change-password",
"--username",
_ADMIN_USER,
"--password",
password,
],
timeout=60,
)
@@ -132,9 +145,12 @@ def _gitea_api(
def _create_marker_repo(domain: str, user: str, password: str) -> bool:
"""Create ci-marker repo with auto_init=True. Returns True if created or already exists."""
status, _ = _gitea_api(
domain, "/user/repos", method="POST",
domain,
"/user/repos",
method="POST",
body={"name": _MARKER_REPO, "private": False, "auto_init": True, "default_branch": "main"},
user=user, password=password,
user=user,
password=password,
)
return status in (201, 409)
@@ -142,17 +158,18 @@ def _create_marker_repo(domain: str, user: str, password: str) -> bool:
def _delete_marker_repo(domain: str, user: str, password: str) -> bool:
"""Delete ci-marker repo. Returns True if deleted or already gone."""
status, _ = _gitea_api(
domain, f"/repos/{user}/{_MARKER_REPO}", method="DELETE",
user=user, password=password,
domain,
f"/repos/{user}/{_MARKER_REPO}",
method="DELETE",
user=user,
password=password,
)
return status in (204, 404)
def marker_repo_exists(domain: str, user: str, password: str) -> bool:
"""Check whether the ci-marker repo is present. Called by test_*.py overlays."""
status, _ = _gitea_api(
domain, f"/repos/{user}/{_MARKER_REPO}", user=user, password=password
)
status, _ = _gitea_api(domain, f"/repos/{user}/{_MARKER_REPO}", user=user, password=password)
return status == 200
@@ -161,9 +178,7 @@ def admin_creds(domain: str) -> tuple[str, str]:
existing = _load_creds(domain)
if existing:
return existing
raise RuntimeError(
f"No admin creds for {domain} — was ops.pre_install called for this run?"
)
raise RuntimeError(f"No admin creds for {domain} — was ops.pre_install called for this run?")
def pre_install(ctx):
@@ -205,7 +220,7 @@ def pre_restore(ctx):
generic.assert_serving(ctx.domain, ctx.meta)
ok = _delete_marker_repo(ctx.domain, user, password)
assert ok, f"pre_restore: could not delete {_MARKER_REPO} repo on {ctx.domain}"
assert not marker_repo_exists(ctx.domain, user, password), (
f"pre_restore: {_MARKER_REPO} still present after delete — divergence did not take"
)
assert not marker_repo_exists(
ctx.domain, user, password
), f"pre_restore: {_MARKER_REPO} still present after delete — divergence did not take"
print(f" gitea ops: {_MARKER_REPO!r} deleted (diverged from backup state)", flush=True)