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 语法检查..." 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" || true errors=$((errors + 1)) fi done if [ $errors -eq 0 ]; then echo "✅ 所有 PHP 文件语法正确" else echo "❌ 发现 $errors 个语法错误" exit 1 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