mirror of https://github.com/buster-so/buster.git
always run tests
This commit is contained in:
parent
19eea365a4
commit
5d4b4e8124
|
@ -17,7 +17,7 @@ runs:
|
||||||
override: true
|
override: true
|
||||||
|
|
||||||
- name: Cache Rust dependencies
|
- name: Cache Rust dependencies
|
||||||
uses: Swatinem/rust-cache@v2
|
uses: useblacksmith/rust-cache@v3
|
||||||
|
|
||||||
- name: Install Diesel CLI
|
- name: Install Diesel CLI
|
||||||
shell: bash
|
shell: bash
|
||||||
|
@ -27,7 +27,7 @@ runs:
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
echo "Starting Supabase..."
|
echo "Starting Supabase..."
|
||||||
supabase start
|
supabase start --exclude postgrest,studio
|
||||||
|
|
||||||
echo "Waiting a bit for services to stabilize after start..."
|
echo "Waiting a bit for services to stabilize after start..."
|
||||||
sleep 15 # Adjust if needed, Supabase start should block but sometimes a small delay helps
|
sleep 15 # Adjust if needed, Supabase start should block but sometimes a small delay helps
|
||||||
|
|
|
@ -4,11 +4,6 @@ on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
paths:
|
|
||||||
- 'api/**'
|
|
||||||
- '.github/workflows/api-testing.yml'
|
|
||||||
- '.github/actions/setup-test-environment/action.yml' # Rerun if common setup changes
|
|
||||||
- '.github/actions/stop-supabase/action.yml'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
|
|
|
@ -4,19 +4,15 @@ on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
paths:
|
|
||||||
- 'cli/**' # Trigger on changes in the cli directory
|
|
||||||
- '.github/workflows/cli-testing.yml' # Also run if the workflow file itself changes
|
|
||||||
- '.github/actions/setup-test-environment/action.yml' # Rerun if common setup changes
|
|
||||||
- '.github/actions/stop-supabase/action.yml'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: blacksmith-16vcpu-ubuntu-2204 # Using a powerful runner as requested
|
runs-on: blacksmith-16vcpu-ubuntu-2204 # Using a powerful runner as requested
|
||||||
environment: testing # Add the environment key
|
environment: testing
|
||||||
|
|
||||||
# Service container for Redis (needed by the setup action)
|
# Service containers
|
||||||
services:
|
services:
|
||||||
|
# Redis needed by API
|
||||||
redis:
|
redis:
|
||||||
image: redis
|
image: redis
|
||||||
ports:
|
ports:
|
||||||
|
@ -27,28 +23,77 @@ jobs:
|
||||||
--health-timeout 5s
|
--health-timeout 5s
|
||||||
--health-retries 5
|
--health-retries 5
|
||||||
|
|
||||||
|
# API service built from Dockerfile
|
||||||
|
api:
|
||||||
|
image: local-api-test:latest # Use the locally built image
|
||||||
|
ports:
|
||||||
|
- 3001:3001
|
||||||
|
options: >-
|
||||||
|
--health-cmd "curl -f http://localhost:3001/health || exit 1"
|
||||||
|
--health-interval 10s
|
||||||
|
--health-timeout 5s
|
||||||
|
--health-retries 5
|
||||||
|
env:
|
||||||
|
# Core Supabase/DB/Redis vars - use service names or host IP
|
||||||
|
# Runner host IP is often 172.17.0.1, Supabase runs directly on host via setup action
|
||||||
|
DATABASE_URL: postgres://postgres:postgres@172.17.0.1:54322/postgres
|
||||||
|
POOLER_URL: postgres://postgres:postgres@172.17.0.1:54322/postgres
|
||||||
|
REDIS_URL: redis://redis:6379 # Connect to redis service container
|
||||||
|
JWT_SECRET: 'super-secret-jwt-token-with-at-least-32-characters-long' # Use default local value
|
||||||
|
SUPABASE_URL: http://172.17.0.1:54321 # Default local URL on host
|
||||||
|
SUPABASE_SERVICE_ROLE_KEY: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MjM0MzA5Nn0.EGgMpd9zvvHPCOq4DJRLwzJ1iS3GV4AEyzguXGcbEIY' # Use default local value
|
||||||
|
|
||||||
|
# Non-sensitive / Default values
|
||||||
|
ENVIRONMENT: development
|
||||||
|
# BUSTER_URL might not be relevant for CLI tests
|
||||||
|
LOG_LEVEL: debug
|
||||||
|
PORT: 3001 # API server port within container
|
||||||
|
RUST_LOG: debug
|
||||||
|
|
||||||
|
# Sensitive values from Secrets (passed to API container)
|
||||||
|
OPENAI_API_KEY: ${{ secrets.GH_ACTIONS_OPENAI_API_KEY }}
|
||||||
|
RESEND_API_KEY: ${{ secrets.GH_ACTIONS_RESEND_API_KEY }}
|
||||||
|
COHERE_API_KEY: ${{ secrets.GH_ACTIONS_COHERE_API_KEY }}
|
||||||
|
LLM_API_KEY: ${{ secrets.GH_ACTIONS_LLM_API_KEY }}
|
||||||
|
LLM_BASE_URL: ${{ secrets.GH_ACTIONS_LLM_BASE_URL }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# Node.js setup removed - not needed for cargo test
|
# --- Build API Docker Image with Blacksmith Caching ---
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Setup Test Environment
|
- name: Build and Load API Docker Image
|
||||||
|
uses: useblacksmith/build-push-action@v1
|
||||||
|
with:
|
||||||
|
context: ./api
|
||||||
|
file: ./api/Dockerfile
|
||||||
|
push: false # Do not push, load locally for service container
|
||||||
|
load: true # Load the image into the runner's Docker daemon
|
||||||
|
tags: local-api-test:latest # Tag for the service definition
|
||||||
|
|
||||||
|
# --- Setup Supabase Environment on Host ---
|
||||||
|
- name: Setup Test Environment # Runs Supabase, migrations, seeding on host
|
||||||
uses: ./.github/actions/setup-test-environment
|
uses: ./.github/actions/setup-test-environment
|
||||||
|
|
||||||
- name: Run CLI Tests
|
- name: Run CLI Tests
|
||||||
working-directory: ./cli # Tests run from the cli directory
|
working-directory: ./cli # Tests run from the cli directory
|
||||||
run: cargo test --workspace # Run tests for all packages in the cli workspace
|
run: cargo test --workspace # Run tests for all packages in the cli workspace
|
||||||
env:
|
env:
|
||||||
# Use hardcoded default values and secrets
|
# Point to services on host (DB/Supabase/Redis) and API container
|
||||||
DATABASE_URL: postgres://postgres:postgres@127.0.0.1:54322/postgres
|
DATABASE_URL: postgres://postgres:postgres@127.0.0.1:54322/postgres
|
||||||
REDIS_URL: redis://localhost:6379 # Connect to the Redis service container
|
REDIS_URL: redis://localhost:6379 # Tests run on host, connect to exposed Redis port
|
||||||
JWT_SECRET: 'super-secret-jwt-token-with-at-least-32-characters-long' # Use default local value
|
JWT_SECRET: 'super-secret-jwt-token-with-at-least-32-characters-long' # Use default local value
|
||||||
SUPABASE_URL: http://127.0.0.1:54321 # Default local URL
|
SUPABASE_URL: http://127.0.0.1:54321 # Tests run on host
|
||||||
SUPABASE_SERVICE_ROLE_KEY: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MjM0MzA5Nn0.EGgMpd9zvvHPCOq4DJRLwzJ1iS3GV4AEyzguXGcbEIY' # Use default local value
|
SUPABASE_SERVICE_ROLE_KEY: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MjM0MzA5Nn0.EGgMpd9zvvHPCOq4DJRLwzJ1iS3GV4AEyzguXGcbEIY' # Use default local value
|
||||||
RUST_LOG: debug # Or adjust as needed
|
RUST_LOG: debug # Or adjust as needed
|
||||||
|
BUSTER_API_URL: http://api:3001 # Point CLI tests to the API service container
|
||||||
|
|
||||||
# Add any other environment variables your CLI tests might require
|
# Secrets are passed to the API container, not needed directly by CLI tests
|
||||||
|
|
||||||
- name: Stop Supabase # Use the cleanup action
|
- name: Stop Supabase # Use the cleanup action
|
||||||
uses: ./.github/actions/stop-supabase
|
uses: ./.github/actions/stop-supabase
|
||||||
|
|
|
@ -4,19 +4,15 @@ on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
paths:
|
|
||||||
- 'web/**'
|
|
||||||
- '.github/workflows/web-testing.yml'
|
|
||||||
- '.github/actions/setup-test-environment/action.yml' # Rerun if common setup changes
|
|
||||||
- '.github/actions/stop-supabase/action.yml'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: blacksmith-16vcpu-ubuntu-2204
|
runs-on: blacksmith-16vcpu-ubuntu-2204
|
||||||
environment: testing
|
environment: testing
|
||||||
|
|
||||||
# Service container for Redis (needed by the setup action and potentially API)
|
# Service containers
|
||||||
services:
|
services:
|
||||||
|
# Redis needed by API
|
||||||
redis:
|
redis:
|
||||||
image: redis
|
image: redis
|
||||||
ports:
|
ports:
|
||||||
|
@ -27,46 +23,32 @@ jobs:
|
||||||
--health-timeout 5s
|
--health-timeout 5s
|
||||||
--health-retries 5
|
--health-retries 5
|
||||||
|
|
||||||
steps:
|
# API service built from Dockerfile
|
||||||
- name: Checkout code
|
api:
|
||||||
uses: actions/checkout@v4
|
image: local-api-test:latest # Use the locally built image
|
||||||
|
ports:
|
||||||
- name: Set up Node.js # Still needed for frontend build/test commands
|
- 3001:3001
|
||||||
uses: actions/setup-node@v4
|
options: >-
|
||||||
with:
|
--health-cmd "curl -f http://localhost:3001/health || exit 1"
|
||||||
node-version: '20'
|
--health-interval 10s
|
||||||
|
--health-timeout 5s
|
||||||
- name: Setup Test Environment
|
--health-retries 5
|
||||||
uses: ./.github/actions/setup-test-environment
|
|
||||||
|
|
||||||
# Build/Run/Wait steps remain for web testing as it needs the API server running
|
|
||||||
- name: Build API Server
|
|
||||||
working-directory: ./api
|
|
||||||
run: cargo build --release
|
|
||||||
env:
|
env:
|
||||||
# Potentially needed if build process requires env vars, though unlikely
|
# Core Supabase/DB/Redis vars - use service names or host IP
|
||||||
DATABASE_URL: postgres://postgres:postgres@127.0.0.1:54322/postgres
|
# Runner host IP is often 172.17.0.1, Supabase runs directly on host via setup action
|
||||||
|
DATABASE_URL: postgres://postgres:postgres@172.17.0.1:54322/postgres
|
||||||
- name: Run API Server
|
POOLER_URL: postgres://postgres:postgres@172.17.0.1:54322/postgres
|
||||||
working-directory: ./api
|
REDIS_URL: redis://redis:6379 # Connect to redis service container
|
||||||
run: |
|
|
||||||
./target/release/server & # Run in background
|
|
||||||
echo $! > /tmp/api-server.pid # Store PID for later cleanup
|
|
||||||
env:
|
|
||||||
# Core Supabase/DB/Redis vars - use hardcoded values and secrets
|
|
||||||
DATABASE_URL: postgres://postgres:postgres@127.0.0.1:54322/postgres
|
|
||||||
POOLER_URL: postgres://postgres:postgres@127.0.0.1:54322/postgres # Assuming pooler uses same DB
|
|
||||||
REDIS_URL: redis://localhost:6379 # Use localhost as it runs on the runner accessing the service
|
|
||||||
JWT_SECRET: 'super-secret-jwt-token-with-at-least-32-characters-long' # Use default local value
|
JWT_SECRET: 'super-secret-jwt-token-with-at-least-32-characters-long' # Use default local value
|
||||||
SUPABASE_URL: http://127.0.0.1:54321 # Default local URL
|
SUPABASE_URL: http://172.17.0.1:54321 # Default local URL on host
|
||||||
SUPABASE_SERVICE_ROLE_KEY: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MjM0MzA5Nn0.EGgMpd9zvvHPCOq4DJRLwzJ1iS3GV4AEyzguXGcbEIY' # Use default local value
|
SUPABASE_SERVICE_ROLE_KEY: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MjM0MzA5Nn0.EGgMpd9zvvHPCOq4DJRLwzJ1iS3GV4AEyzguXGcbEIY' # Use default local value
|
||||||
|
|
||||||
# Non-sensitive / Default values
|
# Non-sensitive / Default values
|
||||||
ENVIRONMENT: development
|
ENVIRONMENT: development
|
||||||
BUSTER_URL: http://localhost:3000
|
BUSTER_URL: http://localhost:3000 # This likely refers to the web app URL, keep as localhost
|
||||||
BUSTER_WH_TOKEN: buster-wh-token
|
BUSTER_WH_TOKEN: buster-wh-token
|
||||||
LOG_LEVEL: debug
|
LOG_LEVEL: debug
|
||||||
PORT: 3001 # API server port
|
PORT: 3001 # API server port within container
|
||||||
RUST_LOG: debug
|
RUST_LOG: debug
|
||||||
|
|
||||||
# Sensitive values from Secrets
|
# Sensitive values from Secrets
|
||||||
|
@ -76,20 +58,45 @@ jobs:
|
||||||
LLM_API_KEY: ${{ secrets.GH_ACTIONS_LLM_API_KEY }}
|
LLM_API_KEY: ${{ secrets.GH_ACTIONS_LLM_API_KEY }}
|
||||||
LLM_BASE_URL: ${{ secrets.GH_ACTIONS_LLM_BASE_URL }}
|
LLM_BASE_URL: ${{ secrets.GH_ACTIONS_LLM_BASE_URL }}
|
||||||
|
|
||||||
- name: Wait for API Server
|
steps:
|
||||||
run: |
|
- name: Checkout code
|
||||||
echo "Waiting for API server (localhost:3001) to be ready..."
|
uses: actions/checkout@v4
|
||||||
n=0
|
|
||||||
until [ "$n" -ge 30 ] || curl -f http://localhost:3001/health; do
|
- name: Setup Node.js (Blacksmith Cache)
|
||||||
n=$((n+1))
|
uses: useblacksmith/setup-node@v5
|
||||||
echo "Waiting for API... Attempt $n/30"
|
with:
|
||||||
sleep 2
|
node-version: '20'
|
||||||
done
|
|
||||||
if ! curl -f http://localhost:3001/health; then
|
- name: Mount NPM Cache (Sticky Disk)
|
||||||
echo "::error::API server did not become ready in time."
|
uses: useblacksmith/stickydisk@v1
|
||||||
exit 1
|
with:
|
||||||
fi
|
key: ${{ github.repository }}-npm-cache # Unique key per repository
|
||||||
echo "API server is ready."
|
path: ~/.npm
|
||||||
|
|
||||||
|
- name: Mount node_modules (Sticky Disk)
|
||||||
|
uses: useblacksmith/stickydisk@v1
|
||||||
|
with:
|
||||||
|
key: ${{ github.repository }}-node-modules # Unique key per repository
|
||||||
|
path: ./web/node_modules # Mount directly into the web directory's node_modules
|
||||||
|
|
||||||
|
# --- Setup Supabase Environment ---
|
||||||
|
- name: Setup Test Environment # Runs Supabase, migrations, seeding on host
|
||||||
|
uses: ./.github/actions/setup-test-environment
|
||||||
|
|
||||||
|
# --- Build API Docker Image with Blacksmith Caching ---
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Build and Load API Docker Image
|
||||||
|
uses: useblacksmith/build-push-action@v1
|
||||||
|
with:
|
||||||
|
context: ./api
|
||||||
|
file: ./api/Dockerfile
|
||||||
|
push: false # Do not push, load locally for service container
|
||||||
|
load: true # Load the image into the runner's Docker daemon
|
||||||
|
tags: local-api-test:latest # Tag for the service definition
|
||||||
|
|
||||||
- name: Run Frontend E2E Tests
|
- name: Run Frontend E2E Tests
|
||||||
working-directory: ./web
|
working-directory: ./web
|
||||||
|
@ -100,13 +107,13 @@ jobs:
|
||||||
npm run build # If needed
|
npm run build # If needed
|
||||||
npm run test:e2e
|
npm run test:e2e
|
||||||
env:
|
env:
|
||||||
# API runs on localhost within the runner
|
# Point to the API service container
|
||||||
NEXT_PUBLIC_API_URL: http://localhost:3001
|
NEXT_PUBLIC_API_URL: http://api:3001
|
||||||
NEXT_PUBLIC_URL: http://localhost:3000 # Assuming default URL for the app itself
|
NEXT_PUBLIC_URL: http://localhost:3000 # Assuming default URL for the app itself
|
||||||
# Use Supabase details - default URL and secret anon key
|
# Use Supabase details - pointing to Supabase running on the HOST (127.0.0.1)
|
||||||
NEXT_PUBLIC_SUPABASE_URL: http://127.0.0.1:54321 # Default local URL
|
NEXT_PUBLIC_SUPABASE_URL: http://127.0.0.1:54321 # Default local URL on host
|
||||||
NEXT_PUBLIC_SUPABASE_ANON_KEY: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODIzNDMwOTZ9.7UIsMFfHYKxH7bUJCRfxd6lr7CSXGF7UxtZQO10FMMo' # Use default local value
|
NEXT_PUBLIC_SUPABASE_ANON_KEY: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODIzNDMwOTZ9.7UIsMFfHYKxH7bUJCRfxd6lr7CSXGF7UxtZQO10FMMo' # Use default local value
|
||||||
NEXT_PUBLIC_WEB_SOCKET_URL: ws://localhost:3001 # Assuming WS connects to API
|
NEXT_PUBLIC_WEB_SOCKET_URL: ws://api:3001 # Point WS to API service container
|
||||||
|
|
||||||
# Pass any other required NEXT_PUBLIC_ variables
|
# Pass any other required NEXT_PUBLIC_ variables
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue