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/ci.yml
T
starmen1265 1beb9d3476
Test CI / 快速测试 (push) Successful in 8s
fix: 语法错误时明确列出错误文件名
2026-03-02 00:19:31 +08:00

59 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 语法检查 ==="
ERRORS=0
# 检查每个文件,把错误的文件名记录下来
for file in $(find . -name "*.php" -not -path "./vendor/*"); do
if ! php -l "$file" > /dev/null 2>&1; then
echo "❌ 错误文件: $file"
ERRORS=$((ERRORS + 1))
fi
done
if [ $ERRORS -gt 0 ]; then
echo "=== 发现 $ERRORS 个语法错误 ==="
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