From 1beb9d347670f77c0db7b8c1c60dde36216ddde2 Mon Sep 17 00:00:00 2001 From: starmen1265 Date: Mon, 2 Mar 2026 00:19:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=AF=AD=E6=B3=95=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=97=B6=E6=98=8E=E7=A1=AE=E5=88=97=E5=87=BA=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/ci.yml | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 805ecb1..9b5446a 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -22,22 +22,19 @@ jobs: - name: PHP 语法检查 run: | - echo "=== 开始 PHP 语法检查 ===" + echo "=== PHP 语法检查 ===" + ERRORS=0 - # 保存所有 php -l 输出到文件 - > /tmp/lint_output.txt + # 检查每个文件,把错误的文件名记录下来 for file in $(find . -name "*.php" -not -path "./vendor/*"); do - echo ">>> 检查文件: $file" >> /tmp/lint_output.txt - php -l "$file" >> /tmp/lint_output.txt 2>&1 - echo "" >> /tmp/lint_output.txt + if ! php -l "$file" > /dev/null 2>&1; then + echo "❌ 错误文件: $file" + ERRORS=$((ERRORS + 1)) + fi done - # 显示输出 - cat /tmp/lint_output.txt - - # 检查是否有错误 - if grep -q "Parse error\|Fatal error\|Syntax error" /tmp/lint_output.txt; then - echo "=== 发现语法错误,CI 失败 ===" + if [ $ERRORS -gt 0 ]; then + echo "=== 发现 $ERRORS 个语法错误 ===" exit 1 else echo "=== 所有 PHP 文件语法正确 ==="