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 environment: NODE_ENV: test CI: true depends_on: - deploy-staging when: - event: pull_request # ========== 阶段3:生产验证(部署前) ========== # 性能测试(在tests_suite中运行) performance-test: image: python:3.13 commands: - cd tests_suite - pip install -r requirements.txt - pytest tests/performance/ -v --no-cov 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 - performance-test - security-test - deploy-staging - deploy-production