test: 拆分慢速迁移测试并优化 pre-push
- 迁移测试标记 migration,单独运行约 130 秒 - 非迁移测试约 90 秒,日常开发跑快速集 - pre-push 默认跳过 migration;改迁移/模型/迁移测试时自动全量 - FULL_TESTS=1 可强制全量,不删除任何迁移测试
This commit is contained in:
+11
-2
@@ -18,6 +18,7 @@ fi
|
||||
|
||||
python_files=()
|
||||
frontend_changed=0
|
||||
migration_changed=0
|
||||
while read -r local_ref local_sha remote_ref remote_sha; do
|
||||
[ -z "$local_sha" ] && continue
|
||||
if [ "$local_sha" = "0000000000000000000000000000000000000000" ]; then
|
||||
@@ -37,6 +38,9 @@ while read -r local_ref local_sha remote_ref remote_sha; do
|
||||
web/frontend/*)
|
||||
frontend_changed=1
|
||||
;;
|
||||
web/backend/migrations/*|web/backend/models.py|tests/test_migrations.py|tests/test_migration_*.py|tests/test_login_attempt_migration.py)
|
||||
migration_changed=1
|
||||
;;
|
||||
esac
|
||||
done <<< "$changed_paths"
|
||||
done <<< "$push_lines"
|
||||
@@ -88,6 +92,11 @@ ensure_test_mysql() {
|
||||
|
||||
ensure_test_mysql
|
||||
|
||||
echo "[pre-push] 运行 pytest..."
|
||||
./dev.sh test -q
|
||||
if [ "${FULL_TESTS:-0}" = "1" ] || [ "$migration_changed" -eq 1 ]; then
|
||||
echo "[pre-push] 运行全量 pytest(含迁移测试)..."
|
||||
./dev.sh test -q
|
||||
else
|
||||
echo "[pre-push] 运行 pytest(跳过慢速迁移测试;FULL_TESTS=1 可跑全量)..."
|
||||
./dev.sh test -q -m "not migration"
|
||||
fi
|
||||
echo "[pre-push] pytest 通过"
|
||||
|
||||
Reference in New Issue
Block a user