Enforce Rust code health gate
Deploy / deploy (push) Successful in 29s
CI / Rust Checks (push) Failing after 4m51s
CI / UI Checks (push) Has been skipped
CI / Frontend E2E (push) Has been skipped
CI / Deployment Manifests (push) Has been skipped

This commit is contained in:
github-ops
2026-06-20 20:53:46 +00:00
parent 6a952f983f
commit 81efa2f0fb
3 changed files with 92 additions and 5 deletions
+1 -1
View File
@@ -90,7 +90,7 @@ shell env file.
- новые `.rs` файлы не больше 1000 строк;
- существующие крупные файлы не должны расти сверх текущего baseline;
- крупные inline test modules подсвечиваются как debt.
- крупные inline test modules запрещены вне legacy allowlist.
```bash
./scripts/check-rust-code-health.sh
+6 -4
View File
@@ -1,9 +1,9 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
ROOT_DIR="${CRANK_RUST_HEALTH_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
DEFAULT_MAX_LINES=1000
DEFAULT_MAX_LINES="${CRANK_RUST_HEALTH_DEFAULT_MAX_LINES:-1000}"
# Existing debt baseline. New files must stay under DEFAULT_MAX_LINES. These
# files are allowed to exist, but CI fails if they grow further.
@@ -46,7 +46,8 @@ while IFS=: read -r file line _; do
fi
lines="$(wc -l < "$file" | tr -d ' ')"
if (( lines > DEFAULT_MAX_LINES / 2 )); then
echo "warning: $rel contains inline tests and has $lines lines; prefer tests/ for integration-style tests" >&2
echo "error: $rel contains inline tests and has $lines lines; move integration-style tests to tests/" >&2
status=1
fi
done < <(
grep -RIn --include='*.rs' '^[[:space:]]*mod tests[[:space:]]*{' \
@@ -61,7 +62,8 @@ Rust code health failed.
Rules:
- new Rust files must stay at or below 1000 lines;
- existing large files are pinned to the current baseline and must not grow;
- when touching a large file, prefer extracting modules or moving integration-style tests to tests/.
- large inline test modules are forbidden outside the legacy allowlist;
- when touching a large file, extract modules or move integration-style tests to tests/.
EOF
fi