Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

Fail CI on undefined names in the backend

Juan Denis05e651be9d6d
diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-ci.yml
index 86e22937..d400e978 100644
--- a/.github/workflows/backend-ci.yml
+++ b/.github/workflows/backend-ci.yml
@@ -48,6 +48,15 @@ jobs:
# Lowering the floor requires editing BASELINE_COUNT in the same commit.
working-directory: backend
run: python tests/check_test_count.py
+ - name: Undefined names
+ # A name used before it exists only fails when that line runs, so a
+ # rarely-taken branch ships broken: two routes that always 500'd on a
+ # missing import, and a Stop button that crashed on a shadowing local
+ # import. Pyflakes catches both statically in about a second.
+ working-directory: backend
+ run: |
+ pip install ruff==0.14.14
+ ruff check --select F821,F823 app tests
# Sharded because this job WAS the entire wait: 21m50s of a ~22m pipeline,
# while every other workflow finished inside a minute. Splitting the suite
diff --git a/scripts/preflight.sh b/scripts/preflight.sh
index 34669ec8..e20e5d5f 100644
--- a/scripts/preflight.sh
+++ b/scripts/preflight.sh
@@ -71,6 +71,22 @@ if ! (cd "$REPO/backend" && "$PYTHON" tests/check_test_count.py); then
note_fail 'test-count ratchet'
fi
+# ---------------------------------------------------------------------------
+# 1b. Undefined names (same check as the CI ratchet job).
+# ---------------------------------------------------------------------------
+banner 'undefined names'
+if command -v ruff >/dev/null 2>&1 || "$PYTHON" -m ruff --version >/dev/null 2>&1; then
+ ruff_cmd='ruff'
+ command -v ruff >/dev/null 2>&1 || ruff_cmd="$PYTHON -m ruff"
+ # shellcheck disable=SC2086
+ if ! (cd "$REPO/backend" && $ruff_cmd check --select F821,F823 app tests); then
+ note_fail 'undefined names'
+ fi
+else
+ echo 'ruff not installed (pip install ruff==0.14.14) -- CI runs this check' >&2
+ note_skip 'undefined names (ruff not installed)'
+fi
+
# ---------------------------------------------------------------------------
# 2. Backend ratchets, censuses, and guards.
#