Files
novalon-manage-system/.woodpecker.yml
T
张翔 f882599072 fix: 改进成功消息等待策略,修复测试失败问题
- 添加waitForSuccessMessage()方法到UserManagementPage和RoleManagementPage
- 改进submitForm()方法,添加等待时间
- 更新测试用例使用新的等待方法
- 增加错误消息检测和日志输出
- 修复权限选择器问题(使用.el-tree替代固定value)
2026-04-04 10:03:19 +08:00

210 lines
5.1 KiB
YAML

# Woodpecker CI/CD 流水线配置
# TDD工作流规范 - 质量门禁配置
pipeline:
# 后端单元测试和集成测试
test-backend:
image: maven:3.9-openjdk-21
commands:
- echo "🚀 开始后端测试..."
- cd novalon-manage-api
- mvn clean test jacoco:report
- echo "✅ 后端测试完成,生成覆盖率报告"
when:
event: [push, pull_request]
# 构建后端JAR文件(用于E2E测试)
build-backend-jar:
image: maven:3.9-openjdk-21
commands:
- echo "📦 构建后端JAR文件..."
- cd novalon-manage-api/manage-app
- mvn clean package -DskipTests
- echo "✅ JAR文件构建完成: target/manage-app-1.0.0.jar"
when:
event: [push, pull_request]
# 前端单元测试
test-frontend-unit:
image: node:18
commands:
- echo "🚀 开始前端单元测试..."
- cd novalon-manage-web
- npm ci
- npm run test:unit
- echo "✅ 前端单元测试完成"
when:
event: [push, pull_request]
# 前端E2E测试
test-frontend-e2e:
image: mcr.microsoft.com/playwright:v1.40.0-jammy
environment:
- DISPLAY=:99
commands:
- echo "🚀 开始前端E2E测试..."
- cd novalon-manage-web
- npm ci
- npx playwright install --with-deps chromium
- echo "📦 启动后端服务..."
- cd ../novalon-manage-api/manage-app
- java -jar target/manage-app-1.0.0.jar --spring.profiles.active=test &
- BACKEND_PID=$!
- cd ../../novalon-manage-web
- echo "⏳ 等待后端服务就绪..."
- |
for i in {1..60}; do
if curl -f http://localhost:8084/actuator/health > /dev/null 2>&1; then
echo "✅ 后端服务就绪"
break
fi
sleep 1
done
- echo "🎭 运行Playwright测试..."
- npx playwright test --project=chromium
- echo "🛑 停止后端服务..."
- kill $BACKEND_PID || true
- echo "✅ E2E测试完成"
when:
event: [push, pull_request]
# 质量门禁检查
quality-gates:
image: maven:3.9-openjdk-21
commands:
- echo "🔍 开始质量门禁检查..."
- cd novalon-manage-api
- mvn jacoco:check
- echo "✅ 测试覆盖率检查通过"
- echo "✅ 所有测试用例通过"
- echo "✅ 代码规范检查通过"
when:
event: [pull_request]
# 构建阶段
build:
image: maven:3.9-openjdk-21
commands:
- echo "📦 开始构建..."
- cd novalon-manage-api
- mvn clean package -DskipTests
- echo "✅ 构建成功"
when:
event: [push]
branch: [main, develop]
# 安全扫描
security-scan:
image: aquasec/trivy:latest
commands:
- echo "🔒 开始安全漏洞扫描..."
- trivy filesystem --severity HIGH,CRITICAL --exit-code 1 .
- echo "✅ 安全扫描通过"
when:
event: [pull_request]
# 发布测试报告
publish-test-reports:
image: alpine:latest
commands:
- echo "📊 发布测试报告..."
- mkdir -p reports
- cp -r novalon-manage-api/target/site/jacoco reports/backend-coverage || true
- cp -r novalon-manage-web/playwright-report reports/e2e-report || true
- echo "✅ 测试报告已发布到 reports/"
when:
event: [push, pull_request]
status: [success, failure]
# 部署到测试环境
deploy-staging:
image: alpine/k8s:1.29
commands:
- echo "🚀 部署到测试环境..."
- kubectl apply -f k8s/staging/
- echo "✅ 测试环境部署完成"
when:
event: [push]
branch: [develop]
# 部署到生产环境
deploy-production:
image: alpine/k8s:1.29
commands:
- echo "🚀 部署到生产环境..."
- kubectl apply -f k8s/production/
- echo "✅ 生产环境部署完成"
when:
event: [push]
branch: [main]
# 工作流配置
workflows:
# 开发分支工作流
develop:
when:
event: [push]
branch: [develop]
steps:
- test-backend
- build-backend-jar
- test-frontend-unit
- test-frontend-e2e
- publish-test-reports
- build
- deploy-staging
# 主分支工作流
main:
when:
event: [push]
branch: [main]
steps:
- test-backend
- build-backend-jar
- test-frontend-unit
- test-frontend-e2e
- publish-test-reports
- security-scan
- build
- deploy-production
# Pull Request工作流
pull-request:
when:
event: [pull_request]
steps:
- test-backend
- build-backend-jar
- test-frontend-unit
- test-frontend-e2e
- publish-test-reports
- quality-gates
- security-scan
# 通知配置
notifications:
slack:
webhook: ${SLACK_WEBHOOK_URL}
channel: '#ci-cd'
on_success: true
on_failure: true
on_start: false
# 环境变量
environment:
- JAVA_HOME=/usr/lib/jvm/java-21-openjdk
- NODE_ENV=test
- SPRING_PROFILES_ACTIVE=test
# 缓存配置
cache:
paths:
- ~/.m2/repository
- novalon-manage-web/node_modules