mirror of https://github.com/buster-so/buster.git
183 lines
5.0 KiB
YAML
183 lines
5.0 KiB
YAML
name: Build, Lint, and Unit Tests
|
|
|
|
on:
|
|
pull_request:
|
|
|
|
# Cancel in-progress runs when a new commit is pushed to the same PR
|
|
concurrency:
|
|
group: ci-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
CI: true
|
|
|
|
jobs:
|
|
# 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
|
|
|
|
- name: Setup Node Environment
|
|
uses: ./.github/actions/setup-node-env
|
|
with:
|
|
cache-key: build-lint-unit
|
|
|
|
- name: Build all packages (excluding web)
|
|
run: pnpm turbo build --filter="!@buster-app/web"
|
|
env:
|
|
NODE_ENV: production
|
|
SKIP_ENV_CHECK: true
|
|
TURBO_CACHE_DIR: .turbo
|
|
TURBO_TELEMETRY_DISABLED: 1
|
|
|
|
- name: Typecheck web app
|
|
run: pnpm turbo typecheck --filter=@buster-app/web
|
|
env:
|
|
TURBO_CACHE_DIR: .turbo
|
|
TURBO_TELEMETRY_DISABLED: 1
|
|
|
|
# Lint job - runs in parallel
|
|
lint:
|
|
name: Lint
|
|
runs-on: blacksmith-2vcpu-ubuntu-2404
|
|
timeout-minutes: 5
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node Environment
|
|
uses: ./.github/actions/setup-node-env
|
|
with:
|
|
cache-key: build-lint-unit
|
|
|
|
- name: Lint all packages
|
|
run: pnpm turbo lint
|
|
env:
|
|
TURBO_CACHE_DIR: .turbo
|
|
TURBO_TELEMETRY_DISABLED: 1
|
|
|
|
# Test job - runs after build completes
|
|
test:
|
|
name: Test
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
timeout-minutes: 10
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node Environment
|
|
uses: ./.github/actions/setup-node-env
|
|
with:
|
|
cache-key: build-lint-unit
|
|
|
|
- name: Build required packages
|
|
run: pnpm turbo build --filter="!@buster-app/web"
|
|
env:
|
|
NODE_ENV: production
|
|
SKIP_ENV_CHECK: true
|
|
TURBO_CACHE_DIR: .turbo
|
|
TURBO_TELEMETRY_DISABLED: 1
|
|
|
|
- name: Run all unit tests
|
|
run: pnpm turbo test:unit
|
|
env:
|
|
TURBO_CACHE_DIR: .turbo
|
|
TURBO_TELEMETRY_DISABLED: 1
|
|
|
|
- name: Upload test coverage
|
|
uses: actions/upload-artifact@v4
|
|
if: always()
|
|
with:
|
|
name: coverage
|
|
path: |
|
|
**/coverage/**
|
|
!**/coverage/tmp/**
|
|
retention-days: 7
|
|
|
|
# Services health check - runs in parallel with test job
|
|
services-health:
|
|
name: Services Health Check
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
timeout-minutes: 10
|
|
environment: testing
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node Environment
|
|
uses: ./.github/actions/setup-node-env
|
|
with:
|
|
cache-key: build-lint-unit
|
|
|
|
- name: Cache Homebrew packages
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/Library/Caches/Homebrew
|
|
/usr/local/Cellar/supabase
|
|
/opt/homebrew/Cellar/supabase
|
|
key: ${{ runner.os }}-brew-supabase-${{ hashFiles('.github/workflows/build-lint-unit.yml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-brew-supabase-
|
|
|
|
- name: Install Supabase CLI
|
|
run: |
|
|
brew install supabase/tap/supabase || brew upgrade supabase
|
|
|
|
- name: Build required packages
|
|
run: pnpm turbo build --filter="!@buster-app/web"
|
|
env:
|
|
NODE_ENV: production
|
|
SKIP_ENV_CHECK: true
|
|
TURBO_CACHE_DIR: .turbo
|
|
TURBO_TELEMETRY_DISABLED: 1
|
|
|
|
- name: Start services
|
|
run: |
|
|
pnpm turbo start &
|
|
echo $! > turbo.pid
|
|
echo "Started turbo with PID $(cat turbo.pid)"
|
|
env:
|
|
SKIP_ENV_CHECK: true
|
|
TURBO_CACHE_DIR: .turbo
|
|
TURBO_TELEMETRY_DISABLED: 1
|
|
|
|
- name: Wait for services to be ready
|
|
run: |
|
|
echo "Waiting for services to start..."
|
|
sleep 30
|
|
|
|
# Check each service with retries
|
|
for port in 3000 3001 3002; do
|
|
echo "Checking localhost:$port..."
|
|
max_attempts=30
|
|
attempt=0
|
|
while [ $attempt -lt $max_attempts ]; do
|
|
if curl -f -s -o /dev/null -w "%{http_code}" http://localhost:$port | grep -q "200\|301\|302\|404"; then
|
|
echo "✅ Service on port $port is responding"
|
|
break
|
|
else
|
|
echo "Waiting for service on port $port (attempt $((attempt+1))/$max_attempts)..."
|
|
sleep 2
|
|
attempt=$((attempt+1))
|
|
fi
|
|
done
|
|
if [ $attempt -eq $max_attempts ]; then
|
|
echo "❌ Service on port $port failed to respond"
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
echo "All services are healthy!"
|
|
|
|
- name: Stop services
|
|
if: always()
|
|
run: |
|
|
if [ -f turbo.pid ]; then
|
|
kill $(cat turbo.pid) || true
|
|
rm turbo.pid
|
|
fi |