mirror of https://github.com/buster-so/buster.git
Refactor CI workflows to streamline dependency installation and improve cache handling. Removed redundant install job, fixed pnpm store permissions, and optimized production dependency preparation in Docker build workflow.
This commit is contained in:
parent
f5f4dc7fca
commit
1ef508bb32
|
@ -12,16 +12,14 @@ env:
|
|||
CI: true
|
||||
|
||||
jobs:
|
||||
# First, install dependencies once and cache them
|
||||
install:
|
||||
name: Install Dependencies
|
||||
runs-on: blacksmith-2vcpu-ubuntu-2404
|
||||
timeout-minutes: 5
|
||||
# Build job - runs in parallel
|
||||
build:
|
||||
name: Build
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 2
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
|
@ -38,57 +36,14 @@ jobs:
|
|||
run: |
|
||||
STORE_PATH=$(pnpm store path --silent)
|
||||
if [ -d "$STORE_PATH" ]; then
|
||||
# Clear corrupted cache entries
|
||||
find "$STORE_PATH" -type f ! -perm -u+r -delete 2>/dev/null || true
|
||||
find "$STORE_PATH" -type d ! -perm -u+rx -delete 2>/dev/null || true
|
||||
# Fix permissions on remaining files
|
||||
sudo chown -R $(whoami):$(whoami) "$STORE_PATH" || true
|
||||
chmod -R u+rw "$STORE_PATH" || true
|
||||
fi
|
||||
|
||||
- name: Check if lockfile changed
|
||||
id: lockfile-check
|
||||
run: |
|
||||
if git diff HEAD~1 HEAD --name-only | grep -q "pnpm-lock.yaml"; then
|
||||
echo "changed=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "changed=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Fetch dependencies (if lockfile changed)
|
||||
if: steps.lockfile-check.outputs.changed == 'true'
|
||||
run: pnpm fetch --frozen-lockfile
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile --prefer-offline
|
||||
|
||||
# Build job - runs in parallel
|
||||
build:
|
||||
name: Build
|
||||
needs: install
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 9.15.0
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: useblacksmith/setup-node@v5
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
- name: Get pnpm store directory
|
||||
shell: bash
|
||||
run: |
|
||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||
|
||||
- name: Mount pnpm store sticky disk
|
||||
uses: useblacksmith/stickydisk@v1
|
||||
with:
|
||||
key: ${{ github.repository }}-pnpm-store
|
||||
path: ${{ env.STORE_PATH }}
|
||||
|
||||
- name: Mount Turbo cache sticky disk
|
||||
uses: useblacksmith/stickydisk@v1
|
||||
with:
|
||||
|
@ -96,9 +51,7 @@ jobs:
|
|||
path: ./.turbo
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
rm -rf node_modules
|
||||
pnpm install --frozen-lockfile --prefer-offline
|
||||
run: pnpm install --frozen-lockfile --prefer-offline
|
||||
|
||||
- name: Build all packages (excluding web)
|
||||
run: pnpm build --filter='!@buster-app/web'
|
||||
|
@ -108,7 +61,6 @@ jobs:
|
|||
# Lint job - runs in parallel
|
||||
lint:
|
||||
name: Lint
|
||||
needs: install
|
||||
runs-on: blacksmith-2vcpu-ubuntu-2404
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
|
@ -124,17 +76,19 @@ jobs:
|
|||
uses: useblacksmith/setup-node@v5
|
||||
with:
|
||||
node-version: 22
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Get pnpm store directory
|
||||
shell: bash
|
||||
- name: Fix pnpm store permissions
|
||||
run: |
|
||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||
|
||||
- name: Mount pnpm store sticky disk
|
||||
uses: useblacksmith/stickydisk@v1
|
||||
with:
|
||||
key: ${{ github.repository }}-pnpm-store
|
||||
path: ${{ env.STORE_PATH }}
|
||||
STORE_PATH=$(pnpm store path --silent)
|
||||
if [ -d "$STORE_PATH" ]; then
|
||||
# Clear corrupted cache entries
|
||||
find "$STORE_PATH" -type f ! -perm -u+r -delete 2>/dev/null || true
|
||||
find "$STORE_PATH" -type d ! -perm -u+rx -delete 2>/dev/null || true
|
||||
# Fix permissions on remaining files
|
||||
sudo chown -R $(whoami):$(whoami) "$STORE_PATH" || true
|
||||
chmod -R u+rw "$STORE_PATH" || true
|
||||
fi
|
||||
|
||||
- name: Mount Turbo cache sticky disk
|
||||
uses: useblacksmith/stickydisk@v1
|
||||
|
@ -143,9 +97,7 @@ jobs:
|
|||
path: ./.turbo
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
rm -rf node_modules
|
||||
pnpm install --frozen-lockfile --prefer-offline
|
||||
run: pnpm install --frozen-lockfile --prefer-offline
|
||||
|
||||
- name: Lint all packages (excluding web)
|
||||
run: pnpm lint --filter='!@buster-app/web'
|
||||
|
@ -153,7 +105,6 @@ jobs:
|
|||
# Test job - runs in parallel
|
||||
test:
|
||||
name: Test
|
||||
needs: install
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
|
@ -169,17 +120,19 @@ jobs:
|
|||
uses: useblacksmith/setup-node@v5
|
||||
with:
|
||||
node-version: 22
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Get pnpm store directory
|
||||
shell: bash
|
||||
- name: Fix pnpm store permissions
|
||||
run: |
|
||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||
|
||||
- name: Mount pnpm store sticky disk
|
||||
uses: useblacksmith/stickydisk@v1
|
||||
with:
|
||||
key: ${{ github.repository }}-pnpm-store
|
||||
path: ${{ env.STORE_PATH }}
|
||||
STORE_PATH=$(pnpm store path --silent)
|
||||
if [ -d "$STORE_PATH" ]; then
|
||||
# Clear corrupted cache entries
|
||||
find "$STORE_PATH" -type f ! -perm -u+r -delete 2>/dev/null || true
|
||||
find "$STORE_PATH" -type d ! -perm -u+rx -delete 2>/dev/null || true
|
||||
# Fix permissions on remaining files
|
||||
sudo chown -R $(whoami):$(whoami) "$STORE_PATH" || true
|
||||
chmod -R u+rw "$STORE_PATH" || true
|
||||
fi
|
||||
|
||||
- name: Mount Turbo cache sticky disk
|
||||
uses: useblacksmith/stickydisk@v1
|
||||
|
@ -188,9 +141,7 @@ jobs:
|
|||
path: ./.turbo
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
rm -rf node_modules
|
||||
pnpm install --frozen-lockfile --prefer-offline
|
||||
run: pnpm install --frozen-lockfile --prefer-offline
|
||||
|
||||
- name: Run all unit tests (excluding web)
|
||||
run: pnpm test:unit --filter='!@buster-app/web'
|
||||
|
|
|
@ -88,35 +88,19 @@ jobs:
|
|||
ls -la dist/
|
||||
cd ../..
|
||||
|
||||
- name: Mount production deps sticky disk
|
||||
uses: useblacksmith/stickydisk@v1
|
||||
with:
|
||||
key: ${{ github.repository }}-prod-deps-${{ github.ref_name }}
|
||||
path: /tmp/prod-deps-cache
|
||||
|
||||
- name: Prepare production dependencies
|
||||
run: |
|
||||
echo "🧹 Preparing production-only dependencies..."
|
||||
# Use cached directory if it exists, otherwise create new
|
||||
if [ -d "/tmp/prod-deps-cache/node_modules" ]; then
|
||||
echo "Using cached production dependencies"
|
||||
mkdir -p /tmp/prod-deps
|
||||
cp -r /tmp/prod-deps-cache/* /tmp/prod-deps/ 2>/dev/null || true
|
||||
else
|
||||
echo "Building fresh production dependencies"
|
||||
mkdir -p /tmp/prod-deps/apps/server
|
||||
cp package.json pnpm-lock.yaml pnpm-workspace.yaml /tmp/prod-deps/
|
||||
cp -r packages /tmp/prod-deps/
|
||||
cp apps/server/package.json /tmp/prod-deps/apps/server/
|
||||
fi
|
||||
# Create a temporary directory for production deps
|
||||
mkdir -p /tmp/prod-deps/apps/server
|
||||
cp package.json pnpm-lock.yaml pnpm-workspace.yaml /tmp/prod-deps/
|
||||
cp -r packages /tmp/prod-deps/
|
||||
cp apps/server/package.json /tmp/prod-deps/apps/server/
|
||||
|
||||
# Install/update production dependencies
|
||||
# Install production dependencies only
|
||||
cd /tmp/prod-deps
|
||||
pnpm install --frozen-lockfile --prod --ignore-scripts --no-optional
|
||||
|
||||
# Update cache
|
||||
cp -r node_modules /tmp/prod-deps-cache/
|
||||
|
||||
# Copy back to workspace
|
||||
cd -
|
||||
mkdir -p docker-context
|
||||
|
|
Loading…
Reference in New Issue