This repository has been archived on 2026-03-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
kb-web/.gitea/workflows/test.yml
T
starmen1265 9427294682
Test CI / 快速测试 (push) Has been cancelled
fix: 使用 container 指定 PHP 镜像
- test.yml / ci.yml: 使用 composer:latest 镜像 (含 PHP)
- deploy.yml: 使用 alpine:latest 镜像 + SSH 密钥配置
- 解决 runner 默认环境缺少 PHP 的问题
2026-03-01 01:01:06 +08:00

65 lines
1.7 KiB
YAML

name: Test CI
on:
push:
branches: ['feature/**', 'bugfix/**', 'refactor/**']
pull_request:
branches: [main, develop]
jobs:
# 快速测试
quick-test:
name: 快速测试
runs-on: linux
container:
image: composer:latest
steps:
- name: 检出代码
run: |
apk add --no-cache git
git clone -b ${{ github.ref_name }} ${{ github.server_url }}/${{ github.repository }}.git .
git checkout ${{ github.sha }}
- name: 检查环境
run: |
echo "PHP: $(php -v | head -1)"
echo "Composer: $(composer --version)"
- name: PHP 语法检查
run: |
echo "📝 PHP 语法检查..."
errors=0
for file in $(find . -name "*.php" -not -path "./vendor/*"); do
output=$(php -l "$file" 2>&1)
if [ $? -ne 0 ]; then
echo "错误: $file"
echo "$output"
errors=$((errors + 1))
fi
done
if [ $errors -eq 0 ]; then
echo "✅ 所有 PHP 文件语法正确"
else
echo "❌ 发现 $errors 个语法错误"
exit 1
fi
- name: 安装依赖
run: composer install --prefer-dist --no-progress --no-interaction
- name: 运行测试
run: |
if composer test 2>/dev/null; then
echo "✅ 测试通过"
else
echo "⚠️ 测试未配置或跳过"
fi
- name: 完成
run: |
echo "=================================="
echo "✅ CI 测试通过!"
echo "分支: ${{ github.ref_name }}"
echo "提交: ${{ github.sha }}"
echo "=================================="