5672757e23
CI/CD Pipeline / Check if frontend-only change (push) Has been skipped
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (push) Has been skipped
CI/CD Pipeline / Validate - Migration (alembic) (push) Successful in 2m49s
CI/CD Pipeline / PR Build API Image (push) Has been skipped
CI/CD Pipeline / Validate - Type Check (mypy) (push) Successful in 3m11s
CI/CD Pipeline / PR Build Web Image (push) Has been skipped
CI/CD Pipeline / PR Build Worker Image (push) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2m37s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been skipped
CI/CD Pipeline / Check push changed paths (push) Successful in 4m11s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 3m58s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 4m54s
CI/CD Pipeline / Validate - Code Quality (push) Successful in 9m8s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 5m46s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m36s
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 7m40s
AI Code Review / AI Code Review (pull_request) Failing after 7m3s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 1m41s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 1m28s
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 9m40s
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (push) Successful in 1m0s
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (push) Successful in 1m7s
CI/CD Pipeline / Integration Tests (push) Successful in 4m19s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 1m32s
CI/CD Pipeline / Retag skipped Staging API Image (push) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (push) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (push) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Has been skipped
CI/CD Pipeline / Staging E2E Tests (push) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (push) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (push) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Successful in 3m32s
CI/CD Pipeline / Unit Tests (push) Successful in 15m46s
CI/CD Pipeline / CI Gate (push) Has been skipped
CI/CD Pipeline / Build Production API Image (push) Has been skipped
CI/CD Pipeline / Build Production Web Image (push) Has been skipped
CI/CD Pipeline / Build Production Worker Image (push) Has been skipped
CI/CD Pipeline / Unit Tests (pull_request) Successful in 12m52s
CI/CD Pipeline / Deploy Production (push) Has been skipped
CI/CD Pipeline / Canary Release to Production (push) Has been skipped
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Successful in 32s
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com> Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
80 lines
2.6 KiB
Bash
Executable File
80 lines
2.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# PR构建专用:只构建不输出,验证Dockerfile能否正常构建
|
|
# 缓存:复用宿主机持久 builder (ci-builder-persist) 的层缓存 + ACR registry 缓存兜底
|
|
# 无状态:build-only 不推送,job 结束无需清理(builder 为共享持久资源)
|
|
set -eu
|
|
|
|
NO_CACHE_FLAG=""
|
|
if [ "$1" = "--no-cache" ]; then
|
|
NO_CACHE_FLAG="--no-cache"
|
|
shift
|
|
fi
|
|
|
|
DOCKERFILE="$1"
|
|
IMAGE_TAG="$2"
|
|
CACHE_REF="$3"
|
|
shift 3
|
|
BUILD_ARGS=""
|
|
for arg in "$@"; do
|
|
BUILD_ARGS="$BUILD_ARGS --build-arg $arg"
|
|
done
|
|
|
|
BUILDER_NAME="ci-builder-persist"
|
|
if ! docker buildx inspect "$BUILDER_NAME" > /dev/null 2>&1; then
|
|
echo "持久 builder 不存在,创建中..."
|
|
docker buildx create --name "$BUILDER_NAME" --driver docker-container \
|
|
--driver-opt network=host \
|
|
--buildkitd-flags "--allow-insecure-entitlement network.host" \
|
|
--platform linux/amd64
|
|
fi
|
|
docker buildx use "$BUILDER_NAME"
|
|
docker buildx inspect "$BUILDER_NAME" --bootstrap
|
|
|
|
echo "=== PR Build: build only, no push (persistent builder cache) ==="
|
|
echo "Dockerfile: ${DOCKERFILE}"
|
|
echo "Image tag: ${IMAGE_TAG}"
|
|
echo "Builder: ${BUILDER_NAME}"
|
|
echo ""
|
|
|
|
run_build() {
|
|
docker buildx build \
|
|
$NO_CACHE_FLAG \
|
|
$BUILD_ARGS \
|
|
--cache-from "type=registry,ref=${CACHE_REF}" \
|
|
-f "${DOCKERFILE}" \
|
|
-t "${IMAGE_TAG}" \
|
|
.
|
|
}
|
|
|
|
# PR 构建同样容错:检测到 builder 缓存损坏时,用 flock 串行重建共享 builder 后重试一次
|
|
if ! build_output=$(run_build 2>&1); then
|
|
if echo "$build_output" | grep -qE "parent snapshot.*not found|snapshot.*does not exist|cache.*corrupt|failed to compute cache key|no such file or directory.*cache"; then
|
|
echo "$build_output"
|
|
echo "⚠️ builder 缓存异常,串行重建持久 builder 后重试..."
|
|
LOCK_FILE="/tmp/ci-builder-persist-rebuild.lock"
|
|
exec 9>"$LOCK_FILE"
|
|
flock -w 120 9 || echo "⚠️ 等待重建锁超时,直接重试 build"
|
|
if ! docker buildx inspect "$BUILDER_NAME" --bootstrap >/dev/null 2>&1; then
|
|
echo "🔨 锁内重建持久 builder..."
|
|
docker buildx rm "$BUILDER_NAME" >/dev/null 2>&1 || true
|
|
docker buildx create --name "$BUILDER_NAME" --driver docker-container \
|
|
--driver-opt network=host \
|
|
--buildkitd-flags "--allow-insecure-entitlement network.host" \
|
|
--platform linux/amd64
|
|
docker buildx use "$BUILDER_NAME"
|
|
docker buildx inspect "$BUILDER_NAME" --bootstrap
|
|
else
|
|
echo "✅ builder 已被其他并发 job 重建/恢复,直接复用"
|
|
fi
|
|
run_build
|
|
else
|
|
echo "$build_output"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "$build_output"
|
|
fi
|
|
|
|
echo ""
|
|
echo "PR build OK (build only, no output): ${IMAGE_TAG}"
|