Files
xiaoxia 6a873e057b
CI/CD Pipeline / Check if frontend-only change (push) Has been skipped
CI/CD Pipeline / PR Build API Image (push) Has been skipped
CI/CD Pipeline / PR Build Web Image (push) Has been skipped
CI/CD Pipeline / PR Build Worker Image (push) Has been skipped
CI/CD Pipeline / Build Production API Image (push) Has been skipped
CI/CD Pipeline / Build Production Worker Image (push) Has been skipped
CI/CD Pipeline / Build Production Web Image (push) Has been skipped
CI/CD Pipeline / Deploy Production (push) Has been skipped
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (push) Failing after 14m59s
CI/CD Pipeline / Integration Tests (push) Failing after 15m1s
CI/CD Pipeline / Unit Tests (push) Failing after 15m1s
CI/CD Pipeline / Build Staging Worker Image (push) Failing after 15m2s
CI/CD Pipeline / Build Staging Web Image (push) Failing after 15m2s
CI/CD Pipeline / Frontend Lint (push) Failing after 15m2s
CI/CD Pipeline / Validate - Migration (alembic) (push) Failing after 15m2s
CI/CD Pipeline / Build Staging API Image (push) Failing after 15m2s
CI/CD Pipeline / Validate - Type Check (mypy) (push) Failing after 15m2s
CI/CD Pipeline / Validate - Code Quality (push) Failing after 15m3s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Has been cancelled
CI/CD Pipeline / Staging E2E Tests (push) Has been cancelled
CI/CD Pipeline / Staging API Integration Tests (push) Has been cancelled
CI/CD Pipeline / ACR Image Cleanup (push) Has been cancelled
ci: Agent提交前自动格式化 + AI审查与auto-approve联动 (#746)
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com>
Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
2026-07-23 01:24:36 +08:00

34 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Agent提交前自动格式化脚本
# 用法:./scripts/format.sh [path1 path2 ...]
# 不传参数则格式化所有后端代码
set -euo pipefail
cd "$(dirname "$0")/.."
echo "=== 代码格式化 ==="
# 后端:black + isort(顺序:先isort后black,与pyproject.toml配置一致)
if command -v black &>/dev/null && command -v isort &>/dev/null; then
TARGETS="${@:-alembic apps packages tests scripts}"
echo "后端格式化: $TARGETS"
python3 -m isort $TARGETS
python3 -m black $TARGETS
echo "✅ 后端格式化完成"
else
echo "⚠️ 未安装black/isort,跳过后端格式化"
fi
# 前端:prettier + eslint --fix(如果有前端改动)
if [ -d "apps/web" ] && command -v npx &>/dev/null; then
if [ "$#" -eq 0 ] || echo "$@" | grep -q "apps/web"; then
echo "前端格式化: apps/web"
(cd apps/web && npx eslint src --ext .ts,.tsx --fix 2>/dev/null || true)
(cd apps/web && npx prettier --write "src/**/*.{ts,tsx,css,json}" 2>/dev/null || true)
echo "✅ 前端格式化完成"
fi
fi
echo "=== 格式化全部完成 ==="