be5d5ede90
refactor: 重构后端查询逻辑和API响应处理 fix: 修复用户角色更新和文件上传问题 test: 添加前端性能测试脚本和E2E测试用例 chore: 更新依赖版本和配置文件 docs: 添加环境检查脚本和测试文档 style: 统一表格标签样式和路由命名 perf: 优化前端页面加载速度和响应时间
213 lines
5.6 KiB
YAML
213 lines
5.6 KiB
YAML
pipeline:
|
|
build:
|
|
image: maven:3.9-eclipse-temurin-21
|
|
commands:
|
|
- cd novalon-manage-api
|
|
- mvn clean install -DskipTests -B
|
|
|
|
package:
|
|
image: maven:3.9-eclipse-temurin-21
|
|
commands:
|
|
- cd novalon-manage-api
|
|
- mvn package -DskipTests -B
|
|
depends_on:
|
|
- build
|
|
|
|
docker-build-gateway:
|
|
image: docker:latest
|
|
commands:
|
|
- cd novalon-manage-api/manage-gateway
|
|
- docker build -t novalon/manage-gateway:${CI_COMMIT_SHA:0:8} .
|
|
- docker tag novalon/manage-gateway:${CI_COMMIT_SHA:0:8} novalon/manage-gateway:latest
|
|
volumes:
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
|
depends_on:
|
|
- package
|
|
|
|
docker-build-app:
|
|
image: docker:latest
|
|
commands:
|
|
- cd novalon-manage-api/manage-app
|
|
- docker build -t novalon/manage-app:${CI_COMMIT_SHA:0:8} .
|
|
- docker tag novalon/manage-app:${CI_COMMIT_SHA:0:8} novalon/manage-app:latest
|
|
volumes:
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
|
depends_on:
|
|
- package
|
|
|
|
deploy-staging:
|
|
image: alpine:latest
|
|
commands:
|
|
- echo "Deploying to staging environment"
|
|
- echo "Branch: ${CI_COMMIT_BRANCH}"
|
|
- echo "Commit: ${CI_COMMIT_SHA}"
|
|
secrets: [ staging_ssh_key ]
|
|
when:
|
|
- event: push
|
|
branch: develop
|
|
depends_on:
|
|
- docker-build-gateway
|
|
- docker-build-app
|
|
|
|
deploy-production:
|
|
image: alpine:latest
|
|
commands:
|
|
- echo "Deploying to production environment"
|
|
- echo "Branch: ${CI_COMMIT_BRANCH}"
|
|
- echo "Commit: ${CI_COMMIT_SHA}"
|
|
secrets: [ production_ssh_key ]
|
|
when:
|
|
- event: push
|
|
branch: main
|
|
depends_on:
|
|
- docker-build-gateway
|
|
- docker-build-app
|
|
|
|
# ========== 阶段1:快速反馈(提交时) ==========
|
|
# 后端单元测试(在novalon-manage-api项目中运行)
|
|
backend-unit-test:
|
|
image: maven:3.9-eclipse-temurin-21
|
|
commands:
|
|
- cd novalon-manage-api
|
|
- mvn clean verify -B
|
|
- echo "测试覆盖率报告已生成在 target/site/jacoco/index.html"
|
|
depends_on:
|
|
- build
|
|
when:
|
|
- event: push
|
|
|
|
# SonarQube代码质量检查
|
|
sonarqube-scan:
|
|
image: maven:3.9-eclipse-temurin-21
|
|
commands:
|
|
- cd novalon-manage-api
|
|
- mvn clean verify sonar:sonar -Dsonar.host.url=${SONAR_HOST_URL} -Dsonar.login=${SONAR_TOKEN} -B
|
|
secrets: [ sonar_host_url, sonar_token ]
|
|
depends_on:
|
|
- backend-unit-test
|
|
when:
|
|
- event: pull_request
|
|
|
|
# 前端单元测试(在novalon-manage-web项目中运行)
|
|
frontend-unit-test:
|
|
image: node:20
|
|
commands:
|
|
- cd novalon-manage-web
|
|
- npm install
|
|
- npm run test:unit
|
|
when:
|
|
- event: push
|
|
|
|
# ========== 阶段2:全面验证(合并前) ==========
|
|
# 集成测试(在tests_suite中运行)
|
|
integration-test:
|
|
image: python:3.13
|
|
commands:
|
|
- cd tests_suite
|
|
- pip install -r requirements.txt
|
|
- playwright install chromium
|
|
- pytest tests/integration/ -v --tb=short --no-cov
|
|
depends_on:
|
|
- build
|
|
when:
|
|
- event: pull_request
|
|
|
|
# E2E测试(在tests_suite中运行)
|
|
e2e-test:
|
|
image: python:3.13
|
|
commands:
|
|
- cd tests_suite
|
|
- pip install -r requirements.txt
|
|
- playwright install chromium
|
|
- pytest tests/e2e/ -v --tb=short --no-cov
|
|
depends_on:
|
|
- deploy-staging
|
|
when:
|
|
- event: pull_request
|
|
|
|
# 前端E2E测试(在novalon-manage-web中运行)
|
|
frontend-e2e-test:
|
|
image: mcr.microsoft.com/playwright:v1.42.0-jammy
|
|
commands:
|
|
- cd novalon-manage-web
|
|
- npm ci
|
|
- npx playwright install --with-deps chromium
|
|
- npx playwright test --reporter=json --reporter=html --output=playwright-report
|
|
environment:
|
|
NODE_ENV: test
|
|
CI: true
|
|
PLAYWRIGHT_HEADLESS: true
|
|
depends_on:
|
|
- deploy-staging
|
|
when:
|
|
- event: pull_request
|
|
|
|
# 前端E2E测试完整套件(每日运行)
|
|
frontend-e2e-test-full:
|
|
image: mcr.microsoft.com/playwright:v1.42.0-jammy
|
|
commands:
|
|
- cd novalon-manage-web
|
|
- npm ci
|
|
- npx playwright install --with-deps chromium
|
|
- npx playwright test --reporter=json --reporter=html --reporter=junit --output=playwright-report
|
|
environment:
|
|
NODE_ENV: test
|
|
CI: true
|
|
PLAYWRIGHT_HEADLESS: true
|
|
depends_on:
|
|
- deploy-staging
|
|
when:
|
|
- event: push
|
|
branch: main
|
|
|
|
# ========== 阶段3:生产验证(部署前) ==========
|
|
# 性能测试(在tests_suite中运行)
|
|
performance-test:
|
|
image: node:20
|
|
commands:
|
|
- npm install -g k6
|
|
- chmod +x run-performance-tests.sh
|
|
- ./run-performance-tests.sh http://localhost:8084 http://localhost:3001
|
|
environment:
|
|
BASE_URL: http://localhost:8084
|
|
FRONTEND_URL: http://localhost:3001
|
|
depends_on:
|
|
- deploy-staging
|
|
when:
|
|
- event: tag
|
|
|
|
# 安全测试(在tests_suite中运行)
|
|
security-test:
|
|
image: python:3.13
|
|
commands:
|
|
- cd tests_suite
|
|
- pip install -r requirements.txt
|
|
- pytest tests/security/ -v --no-cov
|
|
depends_on:
|
|
- deploy-staging
|
|
when:
|
|
- event: deployment
|
|
|
|
notify:
|
|
image: plugins/slack
|
|
settings:
|
|
webhook: ${SLACK_WEBHOOK}
|
|
channel: ci-cd
|
|
username: woodpecker
|
|
icon_url: https://woodpecker-ci.org/img/logo.svg
|
|
when:
|
|
- status: [ success, failure ]
|
|
depends_on:
|
|
- build
|
|
- package
|
|
- backend-unit-test
|
|
- sonarqube-scan
|
|
- frontend-unit-test
|
|
- integration-test
|
|
- e2e-test
|
|
- frontend-e2e-test
|
|
- frontend-e2e-test-full
|
|
- performance-test
|
|
- security-test
|
|
- deploy-staging
|
|
- deploy-production |