fix(ci): 修复unit_tests set -e 退出问题 + 前端依赖安装移除缓存卷
Preview Deploy / Deploy Preview Environment (pull_request) Failing after 17s
AI Code Review / AI Code Review (pull_request) Failing after 26s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 3m34s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 3m49s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m56s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 1412h49m6s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 1412h49m16s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 1412h49m16s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 1412h49m16s
CI/CD Pipeline / Build Production Worker Image (pull_request) Failing after 1412h49m17s
CI/CD Pipeline / Build Production API Image (pull_request) Failing after 1412h49m17s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 1412h49m18s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 1412h49m18s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 1412h49m18s
CI/CD Pipeline / Check if frontend-only change (pull_request) Has been skipped
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 1413h21m23s
CI/CD Pipeline / Build Production Web Image (pull_request) Failing after 1413h21m24s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 1413h21m25s
CI/CD Pipeline / Production Browser E2E (pull_request) Failing after 1413h21m21s

This commit is contained in:
2026-07-19 18:40:08 +08:00
parent 65888fdfef
commit e6fae99955
3 changed files with 10 additions and 38 deletions
+2
View File
@@ -26,10 +26,12 @@ if [ "${GITHUB_EVENT_NAME:-}" = "pull_request" ] && [ -n "${GITHUB_TOKEN:-}" ];
API_URL="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/files?limit=300"
CHANGED_FILES=$(curl -s -H "Authorization: token ${GITHUB_TOKEN}" "$API_URL" | python3 -c "import sys,json; [print(f['filename']) for f in json.load(sys.stdin) if f['status'] != 'removed']")
echo "改动文件数: $(echo "$CHANGED_FILES" | grep -c . || echo 0)"
set +e
CHANGED_FILES="$CHANGED_FILES" \
SELECTED_TESTS_OUTPUT=/tmp/selected_tests.txt \
python3 scripts/ci/select_unit_tests.py
SELECT_EXIT=$?
set -e
if [ $SELECT_EXIT -eq 0 ]; then
UNIT_TEST_MODE="incremental"
TEST_FILES=$(cat /tmp/selected_tests.txt | tr '\n' ' ')
+7 -35
View File
@@ -1,46 +1,18 @@
#!/bin/sh
# CI 公共步骤:前端依赖安装(在 docker node 容器中运行,带缓存)
# CI 公共步骤:前端依赖安装(在 docker node 容器中运行)
# 用法:step_frontend_install.sh [模式]
# 模式: full (默认) - 完整安装所有依赖
# vitest - 仅安装vitest相关依赖(用于轻量单测job)
# vitest - 同full(保持接口兼容)
set -eu
MODE="${1:-full}"
NPM_CACHE_VOLUME="xiaoxia-npm-cache"
echo "=== 前端依赖安装开始 (模式: $MODE) ==="
# 确保缓存卷存在
docker volume create "$NPM_CACHE_VOLUME" > /dev/null 2>&1 || true
if [ "$MODE" = "vitest" ]; then
# 轻量模式:检查缓存中是否已有node_modules,有则跳过npm ci
echo "检查 vitest 依赖缓存..."
HAS_CACHE=$(docker run --rm \
-v "$NPM_CACHE_VOLUME:/cache" \
docker.m.daocloud.io/library/node:20 \
sh -c 'test -d /cache/node_modules && test -f /cache/package-lock.json && echo "yes" || echo "no"')
if [ "$HAS_CACHE" = "yes" ]; then
echo "✅ 缓存命中,跳过 npm ci"
else
echo "⚠️ 缓存未命中,执行 npm ci..."
docker run --rm \
-v "$PWD:/workspace" \
-v "$NPM_CACHE_VOLUME:/workspace/apps/web/node_modules" \
-w /workspace/apps/web \
docker.m.daocloud.io/library/node:20 \
sh -lc "npm ci --no-audit --no-fund"
fi
else
# 完整模式:执行 npm ci
echo "执行 npm ci (完整模式)..."
docker run --rm \
-v "$PWD:/workspace" \
-v "$NPM_CACHE_VOLUME:/workspace/apps/web/node_modules" \
-w /workspace/apps/web \
docker.m.daocloud.io/library/node:20 \
sh -lc "npm ci --no-audit --no-fund"
fi
docker run --rm \
-v "$PWD:/workspace" \
-w /workspace/apps/web \
docker.m.daocloud.io/library/node:20 \
sh -lc "npm ci --no-audit --no-fund"
echo "=== 前端依赖安装完成 ==="
+1 -3
View File
@@ -1,14 +1,12 @@
#!/bin/sh
# CI 公共步骤:前端命令执行(在 docker node 容器中运行,带缓存)
# CI 公共步骤:前端命令执行(在 docker node 容器中运行)
# 用法:step_frontend_run.sh "要执行的命令"
set -eu
CMD="${1:-echo 'no command'}"
NPM_CACHE_VOLUME="xiaoxia-npm-cache"
docker run --rm \
-v "$PWD:/workspace" \
-v "$NPM_CACHE_VOLUME:/workspace/apps/web/node_modules" \
-w /workspace/apps/web \
docker.m.daocloud.io/library/node:20 \
sh -lc "$CMD"