Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 390e4d0a80 | |||
| cac3f91ab7 | |||
| 47e2775634 | |||
| 50f12d65ee |
+9
-13
@@ -2,7 +2,7 @@ name: CI
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main, develop]
|
branches: ["**"]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main, develop]
|
branches: [main, develop]
|
||||||
|
|
||||||
@@ -20,25 +20,21 @@ jobs:
|
|||||||
- name: 安装依赖
|
- name: 安装依赖
|
||||||
run: composer install --prefer-dist --no-progress --no-interaction
|
run: composer install --prefer-dist --no-progress --no-interaction
|
||||||
|
|
||||||
- name: PHP 语法检查2
|
- name: PHP 语法检查
|
||||||
run: |
|
run: |
|
||||||
echo "=== PHP 语法检查 ==="
|
errors=0
|
||||||
ERRORS=0
|
|
||||||
|
|
||||||
# 检查每个文件,把错误的文件名记录下来
|
|
||||||
for file in $(find . -name "*.php" -not -path "./vendor/*"); do
|
for file in $(find . -name "*.php" -not -path "./vendor/*"); do
|
||||||
if ! php -l "$file" > /dev/null 2>&1; then
|
if ! php -l "$file" > /dev/null 2>&1; then
|
||||||
echo "❌ 错误文件: $file"
|
echo "❌ 语法错误: $file"
|
||||||
ERRORS=$((ERRORS + 1))
|
php -l "$file"
|
||||||
|
errors=$((errors + 1))
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
if [ $errors -gt 0 ]; then
|
||||||
if [ $ERRORS -gt 0 ]; then
|
echo "发现 $errors 个语法错误"
|
||||||
echo "=== 发现 $ERRORS 个语法错误 ==="
|
|
||||||
exit 1
|
exit 1
|
||||||
else
|
|
||||||
echo "=== 所有 PHP 文件语法正确 ==="
|
|
||||||
fi
|
fi
|
||||||
|
echo "✅ 所有 PHP 文件语法正确"
|
||||||
|
|
||||||
# 单元测试
|
# 单元测试
|
||||||
test:
|
test:
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
name: Test CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: ['feature/**', 'bugfix/**', 'refactor/**']
|
|
||||||
pull_request:
|
|
||||||
branches: [main, develop]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
# 快速测试
|
|
||||||
quick-test:
|
|
||||||
name: 快速测试
|
|
||||||
runs-on: linux
|
|
||||||
container:
|
|
||||||
image: gitea-runner-php:latest
|
|
||||||
steps:
|
|
||||||
- name: 检出代码
|
|
||||||
run: |
|
|
||||||
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)"
|
|
||||||
echo "Node: $(node -v)"
|
|
||||||
|
|
||||||
- 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 "=================================="
|
|
||||||
@@ -28,7 +28,7 @@ kb-web/
|
|||||||
├── 文档1.md
|
├── 文档1.md
|
||||||
└── 文档2.md
|
└── 文档2.md
|
||||||
```
|
```
|
||||||
1
|
|
||||||
## 部署步骤
|
## 部署步骤
|
||||||
|
|
||||||
### 1. 上传文件
|
### 1. 上传文件
|
||||||
|
|||||||
Reference in New Issue
Block a user