4ec1a3f4dd
refactor(测试): 重构用户数据加载逻辑以支持数组格式 fix(数据库): 修正数据库连接配置和凭证 test: 添加新的导航和用户管理测试场景 docs: 生成UAT测试报告和最终报告 ci: 更新Woodpecker CI配置和测试命令 build: 添加application-test.yml配置文件 chore: 清理旧的测试场景文件
209 lines
5.5 KiB
YAML
209 lines
5.5 KiB
YAML
pipeline:
|
|
# 代码质量检查阶段
|
|
code-quality:
|
|
image: node:18-alpine
|
|
group: quality
|
|
commands:
|
|
- cd novalon-manage-web
|
|
- npm install
|
|
- npm run lint
|
|
- npm run type-check
|
|
when:
|
|
event: [push, pull_request]
|
|
|
|
# 后端单元测试阶段
|
|
backend-unit-tests:
|
|
image: maven:3.9-eclipse-temurin-17
|
|
group: test
|
|
environment:
|
|
SPRING_PROFILES_ACTIVE: test
|
|
commands:
|
|
- cd novalon-manage-api
|
|
- mvn clean test -DskipTests=false
|
|
- mvn jacoco:report
|
|
when:
|
|
event: [push, pull_request]
|
|
|
|
# 前端单元测试阶段
|
|
frontend-unit-tests:
|
|
image: node:18-alpine
|
|
group: test
|
|
commands:
|
|
- cd novalon-manage-web
|
|
- npm install
|
|
- npm run test -- src/test
|
|
- npm run test:coverage
|
|
when:
|
|
event: [push, pull_request]
|
|
|
|
# 启动测试环境
|
|
start-test-env:
|
|
image: docker:latest
|
|
group: e2e
|
|
volumes:
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
|
commands:
|
|
- docker-compose -f docker-compose.test.yml up -d
|
|
- sleep 30
|
|
- docker-compose -f docker-compose.test.yml ps
|
|
when:
|
|
event: [push, pull_request]
|
|
|
|
# E2E测试阶段
|
|
e2e-tests:
|
|
image: mcr.microsoft.com/playwright:v1.58.2-jammy
|
|
group: e2e
|
|
environment:
|
|
BASE_URL: http://frontend-test:80
|
|
CI: true
|
|
commands:
|
|
- cd novalon-manage-web
|
|
- npm ci
|
|
- npx playwright install --with-deps chromium
|
|
- npx playwright test --reporter=json --reporter=html --reporter=junit
|
|
- cp test-results/custom-report.json test-results/custom-report.json
|
|
when:
|
|
event: [push, pull_request]
|
|
depends_on:
|
|
- start-test-env
|
|
|
|
# UAT测试阶段
|
|
uat-tests:
|
|
image: mcr.microsoft.com/playwright:v1.58.2-jammy
|
|
group: uat
|
|
environment:
|
|
TEST_BASE_URL: http://frontend-test:80
|
|
API_BASE_URL: http://backend-test:8084
|
|
HEADLESS_BROWSER: "true"
|
|
CI: true
|
|
commands:
|
|
- cd uat-tests
|
|
- npm ci
|
|
- npx playwright install --with-deps chromium
|
|
- npx playwright test --config=playwright.config.ts --reporter=json --reporter=html --reporter=junit --project=chromium
|
|
- node quality-gate.js || echo "Quality gate check completed"
|
|
when:
|
|
event: [push, pull_request]
|
|
depends_on:
|
|
- start-test-env
|
|
|
|
# 性能测试阶段
|
|
performance-tests:
|
|
image: node:18-alpine
|
|
group: performance
|
|
environment:
|
|
BASE_URL: http://frontend-test:80
|
|
commands:
|
|
- cd novalon-manage-web
|
|
- npm ci
|
|
- npm run test:performance
|
|
when:
|
|
event: [push, pull_request]
|
|
branch: [main, develop]
|
|
depends_on:
|
|
- uat-tests
|
|
|
|
# 质量门禁检查
|
|
quality-gate:
|
|
image: node:18-alpine
|
|
group: quality-gate
|
|
commands:
|
|
- cd novalon-manage-web
|
|
- node e2e/qualityGate.js check test-results/custom-report.json
|
|
when:
|
|
event: [push, pull_request]
|
|
depends_on:
|
|
- e2e-tests
|
|
|
|
# 测试趋势分析
|
|
trend-analysis:
|
|
image: node:18-alpine
|
|
group: analysis
|
|
commands:
|
|
- cd novalon-manage-web
|
|
- node e2e/testTrendAnalyzer.js add test-results/custom-report.json
|
|
- node e2e/testTrendAnalyzer.js report
|
|
when:
|
|
event: [push, pull_request]
|
|
depends_on:
|
|
- e2e-tests
|
|
|
|
# 清理测试环境
|
|
cleanup:
|
|
image: docker:latest
|
|
group: cleanup
|
|
volumes:
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
|
commands:
|
|
- docker-compose -f docker-compose.test.yml down -v
|
|
when:
|
|
status: [success, failure]
|
|
depends_on:
|
|
- quality-gate
|
|
- trend-analysis
|
|
- uat-tests
|
|
|
|
# 生成测试报告
|
|
generate-reports:
|
|
image: node:18-alpine
|
|
group: reports
|
|
commands:
|
|
- cd novalon-manage-web
|
|
- mkdir -p reports
|
|
- cp -r test-results/* reports/ 2>/dev/null || true
|
|
- cp -r playwright-report/* reports/ 2>/dev/null || true
|
|
when:
|
|
event: [push, pull_request]
|
|
depends_on:
|
|
- e2e-tests
|
|
|
|
# 发布测试报告
|
|
publish-reports:
|
|
image: alpine:latest
|
|
group: publish
|
|
secrets: [forgejo_token]
|
|
commands:
|
|
- apk add --no-cache git
|
|
- git config --global user.email "ci@novalon.com"
|
|
- git config --global user.name "CI Bot"
|
|
- git clone --depth 1 https://$${FORGEJO_TOKEN}@forgejo.example.com/novalon/novalon-manage-system.git reports-repo
|
|
- cd reports-repo
|
|
- git checkout gh-pages || git checkout -b gh-pages
|
|
- rm -rf *
|
|
- cp -r ../novalon-manage-web/reports/* .
|
|
- git add .
|
|
- git commit -m "Update test reports [skip ci]" || true
|
|
- git push origin gh-pages || true
|
|
when:
|
|
event: [push]
|
|
branch: [main, develop]
|
|
depends_on:
|
|
- generate-reports
|
|
|
|
# 通知
|
|
notify:
|
|
image: alpine:latest
|
|
group: notify
|
|
secrets: [notify_webhook]
|
|
commands:
|
|
- apk add --no-cache curl
|
|
- |
|
|
curl -X POST $${NOTIFY_WEBHOOK} \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"text": "Pipeline ${CI_PIPELINE_STATUS}: ${CI_REPO_NAME} - ${CI_COMMIT_BRANCH}",
|
|
"attachments": [{
|
|
"title": "Build Details",
|
|
"fields": [
|
|
{"title": "Branch", "value": "${CI_COMMIT_BRANCH}", "short": true},
|
|
{"title": "Commit", "value": "${CI_COMMIT_SHA:0:8}", "short": true},
|
|
{"title": "Author", "value": "${CI_COMMIT_AUTHOR}", "short": true},
|
|
{"title": "Status", "value": "${CI_PIPELINE_STATUS}", "short": true}
|
|
]
|
|
}]
|
|
}'
|
|
when:
|
|
status: [success, failure]
|
|
depends_on:
|
|
- publish-reports
|