fix: 修复 PHP 语法检查退出码问题,优化触发条件
This commit is contained in:
+15
-3
@@ -2,9 +2,9 @@ name: CI
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main, develop, "**"] # 所有分支
|
branches: ["**"]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main, develop, "**"] # 所有分支
|
branches: [main, develop]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# 代码检查
|
# 代码检查
|
||||||
@@ -22,7 +22,19 @@ jobs:
|
|||||||
|
|
||||||
- name: PHP 语法检查
|
- name: PHP 语法检查
|
||||||
run: |
|
run: |
|
||||||
find . -name "*.php" -not -path "./vendor/*" -exec php -l {} \;
|
errors=0
|
||||||
|
for file in $(find . -name "*.php" -not -path "./vendor/*"); do
|
||||||
|
if ! php -l "$file" > /dev/null 2>&1; then
|
||||||
|
echo "❌ 语法错误: $file"
|
||||||
|
php -l "$file"
|
||||||
|
errors=$((errors + 1))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ $errors -gt 0 ]; then
|
||||||
|
echo "发现 $errors 个语法错误"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "✅ 所有 PHP 文件语法正确"
|
||||||
|
|
||||||
# 单元测试
|
# 单元测试
|
||||||
test:
|
test:
|
||||||
|
|||||||
Reference in New Issue
Block a user