60 lines
1.4 KiB
YAML
60 lines
1.4 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main, develop]
|
|
pull_request:
|
|
branches: [main, develop]
|
|
|
|
jobs:
|
|
# 代码检查
|
|
lint:
|
|
name: 代码检查
|
|
runs-on: linux
|
|
container:
|
|
image: gitea-runner-php:latest
|
|
steps:
|
|
- name: 检出代码
|
|
uses: actions/checkout@v4
|
|
|
|
- name: 安装依赖
|
|
run: composer install --prefer-dist --no-progress --no-interaction
|
|
|
|
- name: PHP 语法检查
|
|
run: |
|
|
echo "📝 PHP 语法检查..."
|
|
|
|
# 检查每个 PHP 文件
|
|
for file in $(find . -name "*.php" -not -path "./vendor/*"); do
|
|
php -l "$file" > /tmp/lint_$file.txt 2>&1 || true
|
|
done
|
|
|
|
# 合并所有输出
|
|
cat /tmp/lint_*.txt > /tmp/all_lint.txt
|
|
|
|
# 检查是否有错误
|
|
if grep -q "Parse error\|Fatal error\|Syntax error" /tmp/all_lint.txt; then
|
|
echo "❌ PHP 语法错误详情:"
|
|
base64 /tmp/all_lint.txt
|
|
exit 1
|
|
else
|
|
echo "✅ 所有 PHP 文件语法正确"
|
|
fi
|
|
|
|
# 单元测试
|
|
test:
|
|
name: 单元测试
|
|
runs-on: linux
|
|
container:
|
|
image: gitea-runner-php:latest
|
|
needs: lint
|
|
steps:
|
|
- name: 检出代码
|
|
uses: actions/checkout@v4
|
|
|
|
- name: 安装依赖
|
|
run: composer install --prefer-dist --no-progress --no-interaction
|
|
|
|
- name: 运行测试
|
|
run: composer test
|