style(1b): auto-format + lint-clean the whole codebase (RL1)
Mechanical, semantics-preserving cleanup so the codebase passes the new lint stage:
- ruff format: all 32 Python files (wraps long signatures, normalizes quotes/blank lines).
- nixpkgs-fmt: modules/drone-runner.nix.
- shfmt (-i 2 -ci): scripts/*.sh.
Lint fixes (reviewed, behavior-preserving — no test weakened):
- ruff SIM105: try/except-pass -> contextlib.suppress (abra.py app_config rm; lifecycle.py janitor).
- ruff SIM115: open().read() -> with open() (run_recipe_ci.py redaction-values + gitea-token).
- statix: merge repeated sops `secrets.*` keys into one `secrets = { ... }` (comments kept);
empty fn pattern `{ ... }:` -> `_:` (packages.nix).
- deadnix: drop unused lambda args (flake `self`; configuration.nix `lib`; overlay `final` -> `_`).
Verified on cc-ci: `scripts/lint.sh` -> lint: PASS; nixosConfigurations.cc-ci evaluates;
all Python byte-compiles. The deployed bridge/dashboard/runner source changes hash (reformat),
so cc-ci will be rebuilt to the new closure in W2 before the cold D1-D10 re-verification.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@ -3,6 +3,7 @@ dumps the DB), mutate (drop it), restore (post-hook reloads), assert the restore
|
||||
|
||||
Exercises the recipe's real DB-dump backup hook (postgres + minio are both backupbot-labelled); the
|
||||
postgres marker is the meaningful Docs-metadata data path."""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
@ -18,16 +19,28 @@ def _psql(domain, sql):
|
||||
def test_backup_mutate_restore(deployed, meta):
|
||||
domain = deployed
|
||||
|
||||
_psql(domain, "CREATE TABLE IF NOT EXISTS ci_marker(v text); DELETE FROM ci_marker; "
|
||||
"INSERT INTO ci_marker VALUES('original');")
|
||||
_psql(
|
||||
domain,
|
||||
"CREATE TABLE IF NOT EXISTS ci_marker(v text); DELETE FROM ci_marker; "
|
||||
"INSERT INTO ci_marker VALUES('original');",
|
||||
)
|
||||
assert _psql(domain, "SELECT v FROM ci_marker;") == "original"
|
||||
lifecycle.backup_app(domain)
|
||||
|
||||
_psql(domain, "DROP TABLE ci_marker;")
|
||||
assert _psql(domain, "SELECT to_regclass('public.ci_marker');") in ("", "NULL"), "drop did not take"
|
||||
assert _psql(domain, "SELECT to_regclass('public.ci_marker');") in (
|
||||
"",
|
||||
"NULL",
|
||||
), "drop did not take"
|
||||
|
||||
lifecycle.restore_app(domain)
|
||||
lifecycle.wait_healthy(domain, ok_codes=tuple(meta["HEALTH_OK"]), path=meta["HEALTH_PATH"],
|
||||
deploy_timeout=meta["DEPLOY_TIMEOUT"], http_timeout=meta["HTTP_TIMEOUT"])
|
||||
assert _psql(domain, "SELECT v FROM ci_marker;") == "original", \
|
||||
"restore did not return the pre-mutation postgres state"
|
||||
lifecycle.wait_healthy(
|
||||
domain,
|
||||
ok_codes=tuple(meta["HEALTH_OK"]),
|
||||
path=meta["HEALTH_PATH"],
|
||||
deploy_timeout=meta["DEPLOY_TIMEOUT"],
|
||||
http_timeout=meta["HTTP_TIMEOUT"],
|
||||
)
|
||||
assert (
|
||||
_psql(domain, "SELECT v FROM ci_marker;") == "original"
|
||||
), "restore did not return the pre-mutation postgres state"
|
||||
|
||||
@ -4,6 +4,7 @@ minio + nginx) converges and serves the app over real HTTPS through the gateway.
|
||||
|
||||
Login is OIDC-gated (no live OIDC provider in CI), so the functional assertion is that the frontend
|
||||
SPA is served (unauthenticated landing), not an authenticated flow."""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
@ -27,7 +28,11 @@ def test_playwright_loads_frontend(deployed_app):
|
||||
ctx = browser.new_context(ignore_https_errors=True)
|
||||
page = ctx.new_page()
|
||||
resp = page.goto(url, wait_until="domcontentloaded", timeout=60000)
|
||||
assert resp is not None and resp.status in (200, 301, 302), f"page status {resp and resp.status}"
|
||||
assert resp is not None and resp.status in (
|
||||
200,
|
||||
301,
|
||||
302,
|
||||
), f"page status {resp and resp.status}"
|
||||
assert "<html" in page.content().lower(), "no HTML served by the frontend"
|
||||
finally:
|
||||
browser.close()
|
||||
|
||||
@ -3,6 +3,7 @@ upgrade to current/$REF, assert the app stays healthy and the postgres data surv
|
||||
|
||||
Docs metadata lives in postgres, so the marker is a row in a dedicated `ci_marker` table (the app's
|
||||
own Django migrations don't touch it), read back via `psql` in the `db` service."""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
@ -25,21 +26,35 @@ def old_app(recipe, app_domain, meta, request):
|
||||
lifecycle.janitor()
|
||||
request.addfinalizer(lambda: lifecycle.teardown_app(app_domain))
|
||||
lifecycle.deploy_app(recipe, app_domain, version=prev)
|
||||
lifecycle.wait_healthy(app_domain, ok_codes=tuple(meta["HEALTH_OK"]), path=meta["HEALTH_PATH"],
|
||||
deploy_timeout=meta["DEPLOY_TIMEOUT"], http_timeout=meta["HTTP_TIMEOUT"])
|
||||
lifecycle.wait_healthy(
|
||||
app_domain,
|
||||
ok_codes=tuple(meta["HEALTH_OK"]),
|
||||
path=meta["HEALTH_PATH"],
|
||||
deploy_timeout=meta["DEPLOY_TIMEOUT"],
|
||||
http_timeout=meta["HTTP_TIMEOUT"],
|
||||
)
|
||||
return app_domain, prev
|
||||
|
||||
|
||||
def test_upgrade_preserves_data(old_app, meta):
|
||||
domain, prev = old_app
|
||||
_psql(domain, "CREATE TABLE IF NOT EXISTS ci_marker(v text); DELETE FROM ci_marker; "
|
||||
"INSERT INTO ci_marker VALUES('upgrade-survives');")
|
||||
_psql(
|
||||
domain,
|
||||
"CREATE TABLE IF NOT EXISTS ci_marker(v text); DELETE FROM ci_marker; "
|
||||
"INSERT INTO ci_marker VALUES('upgrade-survives');",
|
||||
)
|
||||
assert _psql(domain, "SELECT v FROM ci_marker;") == "upgrade-survives"
|
||||
|
||||
lifecycle.upgrade_app(domain, version=os.environ.get("VERSION") or None)
|
||||
lifecycle.wait_healthy(domain, ok_codes=tuple(meta["HEALTH_OK"]), path=meta["HEALTH_PATH"],
|
||||
deploy_timeout=meta["DEPLOY_TIMEOUT"], http_timeout=meta["HTTP_TIMEOUT"])
|
||||
lifecycle.wait_healthy(
|
||||
domain,
|
||||
ok_codes=tuple(meta["HEALTH_OK"]),
|
||||
path=meta["HEALTH_PATH"],
|
||||
deploy_timeout=meta["DEPLOY_TIMEOUT"],
|
||||
http_timeout=meta["HTTP_TIMEOUT"],
|
||||
)
|
||||
|
||||
assert lifecycle.http_get(domain, "/") in (200, 301, 302)
|
||||
assert _psql(domain, "SELECT v FROM ci_marker;") == "upgrade-survives", \
|
||||
"postgres data did not survive the upgrade"
|
||||
assert (
|
||||
_psql(domain, "SELECT v FROM ci_marker;") == "upgrade-survives"
|
||||
), "postgres data did not survive the upgrade"
|
||||
|
||||
Reference in New Issue
Block a user