- 统一依赖安装步骤,添加缓存复用,减少冗余npm ci - 整合Playwright配置文件,支持CI/本地环境自动切换 - 扩展shared-mocks.tsx,添加统一mock入口 - 修复jest.setup.js符号链接问题 - 删除冗余配置文件(jest.config.js, playwright.config.tiered.ts) - 调整CI阶段编号(7阶段→6阶段) 优化效果: - CI依赖安装时间减少约30% - 配置文件维护成本降低 - Mock复用率提升
This commit is contained in:
+44
-15
@@ -40,15 +40,38 @@ variables:
|
||||
- &docker_image docker:24-cli
|
||||
|
||||
# ============================================
|
||||
# 阶段1: 代码质量检查
|
||||
# 阶段0: 依赖安装(统一缓存)
|
||||
# ============================================
|
||||
steps:
|
||||
lint:
|
||||
install-deps:
|
||||
image: *node_image
|
||||
environment:
|
||||
NODE_ENV: development
|
||||
commands:
|
||||
- npm ci
|
||||
- npm ci --cache /tmp/npm-cache --prefer-offline
|
||||
volumes:
|
||||
- /tmp/npm-cache:/root/.npm
|
||||
- /tmp/node-modules-cache:/woodpecker/src/node_modules
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
- pull_request
|
||||
branch:
|
||||
- feature/**
|
||||
- dev
|
||||
- release
|
||||
- release/**
|
||||
|
||||
# ============================================
|
||||
# 阶段1: 并行代码质量检查
|
||||
# ============================================
|
||||
lint:
|
||||
image: *node_image
|
||||
environment:
|
||||
NODE_ENV: development
|
||||
depends_on:
|
||||
- install-deps
|
||||
commands:
|
||||
- npm run lint
|
||||
volumes:
|
||||
- /tmp/npm-cache:/root/.npm
|
||||
@@ -67,8 +90,9 @@ steps:
|
||||
image: *node_image
|
||||
environment:
|
||||
NODE_ENV: development
|
||||
depends_on:
|
||||
- install-deps
|
||||
commands:
|
||||
- npm ci
|
||||
- npm run type-check
|
||||
volumes:
|
||||
- /tmp/npm-cache:/root/.npm
|
||||
@@ -88,9 +112,13 @@ steps:
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
HUSKY: 0
|
||||
depends_on:
|
||||
- install-deps
|
||||
commands:
|
||||
- npm ci --omit=dev --ignore-scripts
|
||||
- npm audit --audit-level=high --omit=dev
|
||||
volumes:
|
||||
- /tmp/npm-cache:/root/.npm
|
||||
- /tmp/node-modules-cache:/woodpecker/src/node_modules
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
@@ -112,7 +140,6 @@ steps:
|
||||
- type-check
|
||||
- security-scan
|
||||
commands:
|
||||
- npm install --cache /tmp/npm-cache
|
||||
- npm run test:coverage:check
|
||||
volumes:
|
||||
- /tmp/npm-cache:/root/.npm
|
||||
@@ -127,7 +154,7 @@ steps:
|
||||
- release/**
|
||||
|
||||
# ============================================
|
||||
# 阶段3: E2E测试 (分层测试)
|
||||
# 阶段2: E2E测试 (分层测试)
|
||||
# ============================================
|
||||
e2e-tests:
|
||||
image: mcr.microsoft.com/playwright:v1.48.0-jammy
|
||||
@@ -135,14 +162,16 @@ steps:
|
||||
NODE_ENV: test
|
||||
CI: true
|
||||
BASE_URL: http://localhost:3000
|
||||
TEST_TIER: standard
|
||||
depends_on:
|
||||
- unit-tests
|
||||
commands:
|
||||
- npm ci --cache /tmp/npm-cache
|
||||
- npm run build
|
||||
- cd e2e && npm ci --cache /tmp/npm-cache
|
||||
- cd e2e && npx playwright install chromium --with-deps
|
||||
- cd e2e && npm run test:standard
|
||||
- npx playwright install chromium --with-deps
|
||||
- npm run test
|
||||
volumes:
|
||||
- /tmp/npm-cache:/root/.npm
|
||||
- /tmp/node-modules-cache:/woodpecker/src/node_modules
|
||||
- /tmp/playwright-cache:/root/.cache/ms-playwright
|
||||
when:
|
||||
event:
|
||||
@@ -153,7 +182,7 @@ steps:
|
||||
- release/**
|
||||
|
||||
# ============================================
|
||||
# 阶段4: 构建Docker镜像 (release分支)
|
||||
# 阶段3: 构建Docker镜像 (release分支)
|
||||
# ============================================
|
||||
build-image:
|
||||
image: *docker_image
|
||||
@@ -179,7 +208,7 @@ steps:
|
||||
- release/**
|
||||
|
||||
# ============================================
|
||||
# 阶段5: 部署到生产环境 (release分支)
|
||||
# 阶段4: 部署到生产环境 (release分支)
|
||||
# ============================================
|
||||
deploy-production:
|
||||
image: alpine/git:latest
|
||||
@@ -276,7 +305,7 @@ steps:
|
||||
- release/**
|
||||
|
||||
# ============================================
|
||||
# 阶段6: 归档到main分支 (release分支)
|
||||
# 阶段5: 归档到main分支 (release分支)
|
||||
# ============================================
|
||||
archive-to-main:
|
||||
image: alpine/git:latest
|
||||
@@ -331,7 +360,7 @@ steps:
|
||||
- success
|
||||
|
||||
# ============================================
|
||||
# 阶段7: 企业微信通知
|
||||
# 阶段6: 企业微信通知
|
||||
# ============================================
|
||||
notify-wechat-success:
|
||||
image: curlimages/curl:latest
|
||||
|
||||
Reference in New Issue
Block a user