fix: resolve mypy errors, fix arxiv test session isolation, and add premerge script

- Remove unused type:ignore comment in scholars.py
- Fix 51 mypy errors across test files (Any return types, cast(), protocol stubs)
- Fix arxiv unit test failures caused by session isolation (patch_session_factory fixture)
- Fix integration test rate-limit bleed between search and create
- Add scripts/premerge.sh for local CI verification
- Add docs/website/.docusaurus/ to .gitignore

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Justin Visser 2026-03-02 12:46:10 +01:00
parent 49cf7034b2
commit 87aa89b58c
17 changed files with 129 additions and 28 deletions

58
scripts/premerge.sh Executable file
View file

@ -0,0 +1,58 @@
#!/usr/bin/env bash
set -euo pipefail
DC="docker compose -f docker-compose.yml -f docker-compose.dev.yml"
passed=0
failed=0
failures=()
step() {
local label="$1"
shift
printf '\n\033[1;34m── %s\033[0m\n' "$label"
if "$@"; then
printf '\033[1;32m PASS\033[0m %s\n' "$label"
((passed++)) || true
else
printf '\033[1;31m FAIL\033[0m %s\n' "$label"
((failed++)) || true
failures+=("$label")
fi
}
# ── repo hygiene (host-side, no runtime deps) ────────────────────────────────
step "No generated artifacts" ./scripts/check_no_generated_artifacts.sh
step "Env contract parity" python3 scripts/check_env_contract.py
step "API contract drift" python3 scripts/check_frontend_api_contract.py
# ── backend lint + typecheck ─────────────────────────────────────────────────
step "Ruff check" $DC run --rm app ruff check .
step "Ruff format" $DC run --rm app ruff format --check .
step "Mypy" $DC run --rm app mypy app/ --ignore-missing-imports
# ── backend tests ────────────────────────────────────────────────────────────
step "Unit tests" $DC run --rm app python -m pytest tests/unit
step "Integration tests" $DC run --rm app python -m pytest -m integration
# ── frontend ─────────────────────────────────────────────────────────────────
step "Frontend theme tokens" $DC run --rm frontend npm run check:theme-tokens
step "Frontend typecheck" $DC run --rm frontend npm run typecheck
step "Frontend unit tests" $DC run --rm frontend npm run test:run
step "Frontend build" $DC run --rm frontend npm run build
# ── docs ─────────────────────────────────────────────────────────────────────
step "Docs build" npm --prefix docs/website run build
# ── summary ──────────────────────────────────────────────────────────────────
printf '\n\033[1;34m── Summary ─────────────────────────────────────────────\033[0m\n'
printf ' %s passed, %s failed\n' "$passed" "$failed"
if ((failed > 0)); then
printf '\n\033[1;31m Failed steps:\033[0m\n'
for f in "${failures[@]}"; do
printf ' - %s\n' "$f"
done
exit 1
else
printf '\n\033[1;32m All checks passed.\033[0m\n'
fi