This commit is contained in:
parent
fd711a22c8
commit
3df33ae4ce
@ -87,10 +87,30 @@ jobs:
|
||||
|
||||
- name: Install Bun
|
||||
run: |
|
||||
echo "=== Installing Bun ==="
|
||||
echo "Current working directory: $(pwd)"
|
||||
echo "Current user: $(whoami)"
|
||||
echo "Home directory: $HOME"
|
||||
|
||||
# 设置Bun安装路径
|
||||
export BUN_INSTALL="$HOME/.bun"
|
||||
echo "BUN_INSTALL=$BUN_INSTALL" >> $GITHUB_ENV
|
||||
echo "PATH=$BUN_INSTALL/bin:${PATH}" >> $GITHUB_ENV
|
||||
|
||||
# 检查缓存是否存在
|
||||
if [ -d "$BUN_INSTALL" ]; then
|
||||
echo "✅ Bun cache found at $BUN_INSTALL"
|
||||
ls -la "$BUN_INSTALL" || true
|
||||
else
|
||||
echo "❌ No Bun cache found, will install fresh"
|
||||
fi
|
||||
|
||||
# 安装Bun
|
||||
curl -fsSL https://bun.sh/install | bash
|
||||
echo "BUN_INSTALL=/root/.bun" >> $GITHUB_ENV
|
||||
echo "PATH=/root/.bun/bin:${PATH}" >> $GITHUB_ENV
|
||||
/root/.bun/bin/bun --version
|
||||
|
||||
# 验证安装
|
||||
"$BUN_INSTALL/bin/bun" --version
|
||||
echo "✅ Bun installed successfully"
|
||||
|
||||
- name: Configure npm registry (npmmirror) and canvas mirror
|
||||
run: |
|
||||
@ -100,22 +120,55 @@ jobs:
|
||||
- name: Install dependencies cache (Bun)
|
||||
uses: https://gitea.cn/actions/cache@v3
|
||||
with:
|
||||
path: /root/.bun
|
||||
path: ~/.bun
|
||||
key: bun-${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('bun.lock') }}
|
||||
restore-keys: |
|
||||
bun-${{ runner.os }}-${{ matrix.node }}-
|
||||
bun-${{ runner.os }}-
|
||||
|
||||
- name: Install dependencies cache (node_modules)
|
||||
uses: https://gitea.cn/actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
node_modules
|
||||
apps/admin/node_modules
|
||||
apps/user/node_modules
|
||||
packages/ui/node_modules
|
||||
key: nm-${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('bun.lock') }}
|
||||
apps/*/node_modules
|
||||
packages/*/node_modules
|
||||
key: node-modules-${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('bun.lock', 'package.json', 'apps/*/package.json', 'packages/*/package.json') }}
|
||||
restore-keys: |
|
||||
nm-${{ runner.os }}-${{ matrix.node }}-
|
||||
node-modules-${{ runner.os }}-${{ matrix.node }}-
|
||||
node-modules-${{ runner.os }}-
|
||||
|
||||
- name: Cache status check and setup
|
||||
run: |
|
||||
echo "=== Cache Status Check ==="
|
||||
echo "Checking cache restoration status..."
|
||||
|
||||
# 检查各种缓存目录
|
||||
echo "Bun cache: $([ -d ~/.bun ] && echo '✅ Found' || echo '❌ Missing')"
|
||||
echo "node_modules: $([ -d node_modules ] && echo '✅ Found' || echo '❌ Missing')"
|
||||
echo "Turbo cache: $([ -d .turbo ] && echo '✅ Found' || echo '❌ Missing')"
|
||||
|
||||
# 显示缓存大小
|
||||
if [ -d ~/.bun ]; then
|
||||
echo "Bun cache size: $(du -sh ~/.bun 2>/dev/null || echo 'unknown')"
|
||||
fi
|
||||
if [ -d node_modules ]; then
|
||||
echo "node_modules size: $(du -sh node_modules 2>/dev/null || echo 'unknown')"
|
||||
fi
|
||||
if [ -d .turbo ]; then
|
||||
echo "Turbo cache size: $(du -sh .turbo 2>/dev/null || echo 'unknown')"
|
||||
fi
|
||||
|
||||
echo "=== Cache Setup ==="
|
||||
# 确保缓存目录存在且权限正确
|
||||
mkdir -p ~/.bun ~/.cache .turbo
|
||||
chmod -R 755 ~/.bun ~/.cache .turbo 2>/dev/null || true
|
||||
|
||||
# 设置Bun环境变量
|
||||
echo "BUN_INSTALL_CACHE_DIR=$HOME/.cache/bun" >> $GITHUB_ENV
|
||||
echo "BUN_INSTALL_BIN_DIR=$HOME/.bun/bin" >> $GITHUB_ENV
|
||||
|
||||
echo "✅ Cache directories prepared"
|
||||
|
||||
- name: Turborepo cache (.turbo)
|
||||
uses: https://gitea.cn/actions/cache@v3
|
||||
@ -126,7 +179,43 @@ jobs:
|
||||
turbo-${{ runner.os }}-
|
||||
|
||||
- name: Install dependencies (bun)
|
||||
run: bun install
|
||||
run: |
|
||||
echo "=== Dependency Installation Debug ==="
|
||||
echo "Current directory: $(pwd)"
|
||||
echo "Bun version: $(bun --version)"
|
||||
|
||||
# 检查node_modules缓存状态
|
||||
if [ -d "node_modules" ]; then
|
||||
echo "✅ node_modules cache found"
|
||||
echo "node_modules size: $(du -sh node_modules 2>/dev/null || echo 'unknown')"
|
||||
echo "node_modules contents: $(ls -la node_modules | head -10)"
|
||||
else
|
||||
echo "❌ No node_modules cache found"
|
||||
fi
|
||||
|
||||
# 检查bun.lock文件
|
||||
if [ -f "bun.lock" ]; then
|
||||
echo "✅ bun.lock found"
|
||||
echo "bun.lock hash: $(sha256sum bun.lock)"
|
||||
else
|
||||
echo "❌ No bun.lock found"
|
||||
fi
|
||||
|
||||
echo "=== Starting dependency installation ==="
|
||||
time bun install --frozen-lockfile
|
||||
|
||||
echo "=== Installation completed ==="
|
||||
echo "Final node_modules size: $(du -sh node_modules 2>/dev/null || echo 'unknown')"
|
||||
|
||||
# 验证缓存效果
|
||||
echo "=== Cache Effectiveness Check ==="
|
||||
if [ -d "node_modules" ] && [ "$(find node_modules -name '*.js' | wc -l)" -gt 100 ]; then
|
||||
echo "✅ Dependencies installed successfully"
|
||||
echo "Package count: $(ls node_modules | wc -l)"
|
||||
else
|
||||
echo "⚠️ Dependencies may not be fully installed"
|
||||
fi
|
||||
|
||||
|
||||
- name: Decide build target (admin/user/both)
|
||||
run: |
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user