- 减少IO和step数量
This commit is contained in:
91
.drone.yml
91
.drone.yml
@@ -21,13 +21,8 @@ steps:
|
|||||||
# 0️⃣ 克隆代码
|
# 0️⃣ 克隆代码
|
||||||
- name: clone
|
- name: clone
|
||||||
image: alpine/git:latest
|
image: alpine/git:latest
|
||||||
environment:
|
|
||||||
CA_CRT:
|
|
||||||
from_secret: ca-crt
|
|
||||||
commands:
|
commands:
|
||||||
- apk add --no-cache ca-certificates
|
- apk add --no-cache ca-certificates
|
||||||
- echo "$CA_CRT" > /etc/ssl/certs/ca.crt
|
|
||||||
- update-ca-certificates
|
|
||||||
- git clone https://gitea.local.knowai/tobegold574/knowai.git /drone/src
|
- git clone https://gitea.local.knowai/tobegold574/knowai.git /drone/src
|
||||||
- cd /drone/src
|
- cd /drone/src
|
||||||
- git checkout ${DRONE_BRANCH}
|
- git checkout ${DRONE_BRANCH}
|
||||||
@@ -36,90 +31,38 @@ steps:
|
|||||||
- name: repo-volume
|
- name: repo-volume
|
||||||
mountPath: /drone/src
|
mountPath: /drone/src
|
||||||
|
|
||||||
# 1️⃣ 准备环境
|
# 1️⃣ 验证 + 安装依赖 + 类型检查 + lint + 测试 + 构建
|
||||||
- name: prepare-environment
|
- name: verify-and-build
|
||||||
image: gitea.local.knowai/tobegold574/knowai-base:1.0.0
|
image: gitea.local.knowai/tobegold574/knowai-base:1.0.0
|
||||||
|
environment:
|
||||||
|
NODE_ENV: development
|
||||||
commands:
|
commands:
|
||||||
- cd /drone/src/frontend/knowai-core
|
- cd /drone/src/frontend/knowai-core
|
||||||
- echo "🚀 验证 Node.js 环境..."
|
|
||||||
|
# 验证 Node.js 和 pnpm
|
||||||
- node --version
|
- node --version
|
||||||
- pnpm --version
|
- pnpm --version
|
||||||
- echo "🔍 检查 pnpm 存储路径..."
|
- echo "📦 安装依赖(利用缓存)..."
|
||||||
- pnpm store path
|
- pnpm install --frozen-lockfile --registry=https://registry.npmmirror.com
|
||||||
- echo "🔍 检查项目结构..."
|
|
||||||
- ls -la
|
|
||||||
volumeMounts:
|
|
||||||
- name: repo-volume
|
|
||||||
mountPath: /drone/src
|
|
||||||
|
|
||||||
# 2️⃣ 安装依赖
|
# 执行核心验证
|
||||||
- name: install-dependencies
|
- echo "🔍 TypeScript 类型检查..."
|
||||||
image: gitea.local.knowai/tobegold574/knowai-base:1.0.0
|
|
||||||
commands:
|
|
||||||
- cd /drone/src/frontend/knowai-core
|
|
||||||
- echo "📦 安装项目依赖..."
|
|
||||||
- pnpm install --registry=https://registry.npmmirror.com --no-frozen-lockfile
|
|
||||||
- echo "✅ 依赖安装完成"
|
|
||||||
volumeMounts:
|
|
||||||
- name: repo-volume
|
|
||||||
mountPath: /drone/src
|
|
||||||
- name: pnpm_store_cache
|
|
||||||
mountPath: /pnpm-global/store
|
|
||||||
|
|
||||||
# 3️⃣ 类型检查
|
|
||||||
- name: type-check
|
|
||||||
image: gitea.local.knowai/tobegold574/knowai-base:1.0.0
|
|
||||||
commands:
|
|
||||||
- cd /drone/src/frontend/knowai-core
|
|
||||||
- echo "🔍 执行 TypeScript 类型检查..."
|
|
||||||
- pnpm run type-check
|
- pnpm run type-check
|
||||||
- echo "✅ 类型检查通过"
|
|
||||||
volumeMounts:
|
|
||||||
- name: repo-volume
|
|
||||||
mountPath: /drone/src
|
|
||||||
- name: pnpm_store_cache
|
|
||||||
mountPath: /pnpm-global/store
|
|
||||||
|
|
||||||
# 4️⃣ 代码检查
|
- echo "🔍 ESLint 代码检查..."
|
||||||
- name: lint
|
|
||||||
image: gitea.local.knowai/tobegold574/knowai-base:1.0.0
|
|
||||||
commands:
|
|
||||||
- cd /drone/src/frontend/knowai-core
|
|
||||||
- echo "🔍 执行 ESLint 代码检查..."
|
|
||||||
- pnpm run lint
|
- pnpm run lint
|
||||||
- echo "✅ 代码检查通过"
|
|
||||||
volumeMounts:
|
|
||||||
- name: repo-volume
|
|
||||||
mountPath: /drone/src
|
|
||||||
- name: pnpm_store_cache
|
|
||||||
mountPath: /pnpm-global/store
|
|
||||||
|
|
||||||
# 5️⃣ 运行测试
|
|
||||||
- name: test
|
|
||||||
image: gitea.local.knowai/tobegold574/knowai-base:1.0.0
|
|
||||||
commands:
|
|
||||||
- cd /drone/src/frontend/knowai-core
|
|
||||||
- echo "🧪 运行单元测试..."
|
- echo "🧪 运行单元测试..."
|
||||||
- pnpm run test
|
- pnpm run test
|
||||||
- echo "✅ 测试通过"
|
|
||||||
volumeMounts:
|
|
||||||
- name: repo-volume
|
|
||||||
mountPath: /drone/src
|
|
||||||
- name: pnpm_store_cache
|
|
||||||
mountPath: /pnpm-global/store
|
|
||||||
|
|
||||||
# 6️⃣ 构建验证
|
- echo "🔨 构建产物..."
|
||||||
- name: build
|
|
||||||
image: gitea.local.knowai/tobegold574/knowai-base:1.0.0
|
|
||||||
commands:
|
|
||||||
- cd /drone/src/frontend/knowai-core
|
|
||||||
- echo "🔨 验证构建过程..."
|
|
||||||
- pnpm run build
|
- pnpm run build
|
||||||
- echo "📁 检查构建产物..."
|
|
||||||
- ls -la dist/
|
- ls -la dist/
|
||||||
- echo "✅ 构建验证通过"
|
|
||||||
|
- echo "✅ 核心验证通过"
|
||||||
|
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
|
- name: pnpm-store-cache
|
||||||
|
mountPath: /pnpm-global/store
|
||||||
- name: repo-volume
|
- name: repo-volume
|
||||||
mountPath: /drone/src
|
mountPath: /drone/src
|
||||||
- name: pnpm_store_cache
|
|
||||||
mountPath: /pnpm-global/store
|
|
||||||
|
|||||||
Reference in New Issue
Block a user