1.5 KiB
1.5 KiB
2026-03-02 工作日志
Gitea Actions CI 问题排查 - 成功 ✅
问题描述
- CI 输出被截断,看不到详细错误信息
- 多次修改 ci.yml 但输出不变
- PHP 语法检查形同虚设(退出码问题)
- test.yml 和 ci.yml 触发条件混乱
根本原因
- workflow 缓存问题:act runner 缓存了 workflow 文件
- 分支触发问题:ci.yml 只在 main/develop 触发,feature 分支触发的是 test.yml
- find -exec 退出码问题:只反映 find 自身,不反映 php -l 的失败状态
解决方案
- 清除 act 缓存:
rm -rf ~/.cache/act ~/.cache/actcache - 重启 act_runner daemon
- 修改 ci.yml 触发条件为所有分支
- 更新自定义镜像添加 Node.js(gitea-runner-php:latest)
- 修复 PHP 语法检查脚本:正确捕获退出码
- 删除 test.yml,统一使用 ci.yml
最终 CI 配置
on:
push:
branches: ["**"]
pull_request:
branches: [main, develop]
PHP 语法检查(正确版本)
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 文件语法正确"
修复的文件
- index.php(缺少分号)
- ci.yml(多处修改)
- docker/runner/Dockerfile(添加 Node.js)
- 删除 test.yml