mirror of https://github.com/buster-so/buster.git
ok trying again with env setup
This commit is contained in:
parent
7108137eb4
commit
0c5c9eafff
|
@ -1,29 +1,13 @@
|
||||||
name: 'Setup Test Environment'
|
name: 'Setup Test Environment'
|
||||||
description: 'Installs tools, starts Supabase, runs migrations/seeds, and exports env vars.'
|
description: 'Installs tools, starts Supabase, runs migrations, and seeds the database.'
|
||||||
|
|
||||||
outputs:
|
|
||||||
database-url:
|
|
||||||
description: 'Supabase DB Connection URL'
|
|
||||||
value: ${{ steps.start_supabase.outputs.db_url }}
|
|
||||||
supabase-url:
|
|
||||||
description: 'Supabase API URL'
|
|
||||||
value: ${{ steps.start_supabase.outputs.supabase_url }}
|
|
||||||
supabase-anon-key:
|
|
||||||
description: 'Supabase Anon Key'
|
|
||||||
value: ${{ steps.start_supabase.outputs.supabase_anon_key }}
|
|
||||||
supabase-service-role-key:
|
|
||||||
description: 'Supabase Service Role Key'
|
|
||||||
value: ${{ steps.start_supabase.outputs.supabase_service_role_key }}
|
|
||||||
jwt-secret:
|
|
||||||
description: 'Supabase JWT Secret'
|
|
||||||
value: ${{ steps.start_supabase.outputs.jwt_secret }}
|
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
- name: Install Supabase CLI
|
- name: Setup Supabase CLI
|
||||||
shell: bash
|
uses: supabase/setup-cli@v1
|
||||||
run: npm install --global supabase@latest
|
with:
|
||||||
|
version: latest # Or pin to a specific version
|
||||||
|
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
|
@ -39,71 +23,37 @@ runs:
|
||||||
shell: bash
|
shell: bash
|
||||||
run: cargo install diesel_cli --no-default-features --features postgres
|
run: cargo install diesel_cli --no-default-features --features postgres
|
||||||
|
|
||||||
- name: Start Supabase & Set Outputs
|
- name: Start Supabase
|
||||||
id: start_supabase
|
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
supabase start &> supabase_output.log &
|
echo "Starting Supabase..."
|
||||||
echo "Waiting for Supabase services to initialize..."
|
supabase start
|
||||||
sleep 30 # Initial wait time, adjust as needed
|
|
||||||
|
|
||||||
# Wait for DB to be connectable
|
echo "Waiting a bit for services to stabilize after start..."
|
||||||
n=0
|
sleep 15 # Adjust if needed, Supabase start should block but sometimes a small delay helps
|
||||||
until [ "$n" -ge 30 ] || pg_isready -h 127.0.0.1 -p 54322 -U postgres; do
|
|
||||||
n=$((n+1))
|
echo "Checking Supabase status..."
|
||||||
echo "Waiting for DB... Attempt $n/30"
|
supabase status
|
||||||
sleep 2
|
if [ $? -ne 0 ]; then
|
||||||
done
|
echo "::error::Supabase failed to start correctly."
|
||||||
if ! pg_isready -h 127.0.0.1 -p 54322 -U postgres; then
|
# Attempt to fetch logs if possible (might not be available easily with setup-cli)
|
||||||
echo "::error::Supabase DB did not become ready in time."
|
# supabase logs --project-ref local # This might need project-ref
|
||||||
cat supabase_output.log
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Supabase services seem ready. Extracting config..."
|
echo "Supabase started."
|
||||||
cat supabase_output.log
|
|
||||||
|
|
||||||
# Extract variables and set them as outputs
|
|
||||||
DB_URL_VAL=$(grep 'DB URL:' supabase_output.log | sed 's/.*DB URL: *//')
|
|
||||||
SUPABASE_URL_VAL=$(grep 'API URL:' supabase_output.log | sed 's/.*API URL: *//')
|
|
||||||
SUPABASE_ANON_KEY_VAL=$(grep 'anon key:' supabase_output.log | sed 's/.*anon key: *//')
|
|
||||||
SUPABASE_SERVICE_ROLE_KEY_VAL=$(grep 'service_role key:' supabase_output.log | sed 's/.*service_role key: *//')
|
|
||||||
JWT_SECRET_VAL=$(grep 'JWT secret:' supabase_output.log | sed 's/.*JWT secret: *//')
|
|
||||||
|
|
||||||
# Check if variables were extracted
|
|
||||||
if [ -z "$DB_URL_VAL" ] || [ -z "$SUPABASE_URL_VAL" ] || [ -z "$SUPABASE_ANON_KEY_VAL" ] || [ -z "$SUPABASE_SERVICE_ROLE_KEY_VAL" ] || [ -z "$JWT_SECRET_VAL" ]; then
|
|
||||||
echo "::error::Failed to extract Supabase configuration from output."
|
|
||||||
cat supabase_output.log
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "db_url=$DB_URL_VAL" >> $GITHUB_OUTPUT
|
|
||||||
echo "supabase_url=$SUPABASE_URL_VAL" >> $GITHUB_OUTPUT
|
|
||||||
echo "supabase_anon_key=$SUPABASE_ANON_KEY_VAL" >> $GITHUB_OUTPUT
|
|
||||||
echo "supabase_service_role_key=$SUPABASE_SERVICE_ROLE_KEY_VAL" >> $GITHUB_OUTPUT
|
|
||||||
echo "jwt_secret=$JWT_SECRET_VAL" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
echo "Supabase started and configured."
|
|
||||||
|
|
||||||
- name: Run Migrations
|
- name: Run Migrations
|
||||||
working-directory: ./api # Assuming migrations are always relative to api
|
working-directory: ./api # Assuming migrations are always relative to api
|
||||||
shell: bash
|
shell: bash
|
||||||
run: diesel migration run
|
run: diesel migration run
|
||||||
env:
|
env:
|
||||||
# Use the output from the previous step
|
DATABASE_URL: postgres://postgres:postgres@127.0.0.1:54322/postgres
|
||||||
DATABASE_URL: ${{ steps.start_supabase.outputs.db_url }}
|
|
||||||
|
|
||||||
- name: Seed Database
|
- name: Seed Database
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
# Extract connection details from DB_URL
|
# Use hardcoded default credentials for local Supabase
|
||||||
DB_URL_VAL="${{ steps.start_supabase.outputs.db_url }}"
|
PGPASSWORD=postgres psql -h 127.0.0.1 -p 54322 -U postgres -d postgres -f ./api/libs/database/seed.sql
|
||||||
PGUSER=$(echo "$DB_URL_VAL" | awk -F '[/:]' '{print $4}')
|
|
||||||
PGPASSWORD=$(echo "$DB_URL_VAL" | awk -F '[:@]' '{print $3}')
|
|
||||||
PGHOST=$(echo "$DB_URL_VAL" | awk -F '[@:]' '{print $4}')
|
|
||||||
PGPORT=$(echo "$DB_URL_VAL" | awk -F '[:/]' '{print $6}')
|
|
||||||
PGDATABASE=$(echo "$DB_URL_VAL" | awk -F '/' '{print $NF}')
|
|
||||||
|
|
||||||
PGPASSWORD=$PGPASSWORD psql -h $PGHOST -p $PGPORT -U $PGUSER -d $PGDATABASE -f ./api/libs/database/seed.sql
|
|
||||||
env:
|
env:
|
||||||
DATABASE_URL: ${{ steps.start_supabase.outputs.db_url }}
|
DATABASE_URL: postgres://postgres:postgres@127.0.0.1:54322/postgres # Also set here just in case seed script needs it
|
|
@ -33,19 +33,18 @@ jobs:
|
||||||
# Node.js setup removed
|
# Node.js setup removed
|
||||||
|
|
||||||
- name: Setup Test Environment
|
- name: Setup Test Environment
|
||||||
id: setup_env # Give an ID to reference outputs
|
|
||||||
uses: ./.github/actions/setup-test-environment
|
uses: ./.github/actions/setup-test-environment
|
||||||
|
|
||||||
- name: Run API Tests
|
- name: Run API Tests
|
||||||
working-directory: ./api # Tests run from the api directory
|
working-directory: ./api # Tests run from the api directory
|
||||||
run: cargo test --workspace # Run tests for all packages in the api workspace
|
run: cargo test --workspace # Run tests for all packages in the api workspace
|
||||||
env:
|
env:
|
||||||
# Pass necessary env vars from setup action outputs
|
# Use hardcoded default values and secrets
|
||||||
DATABASE_URL: ${{ steps.setup_env.outputs.database-url }}
|
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 # Connect to the Redis service container
|
||||||
JWT_SECRET: ${{ steps.setup_env.outputs.jwt-secret }}
|
JWT_SECRET: ${{ secrets.GH_ACTIONS_SUPABASE_JWT_SECRET }} # Use secret
|
||||||
SUPABASE_URL: ${{ steps.setup_env.outputs.supabase-url }}
|
SUPABASE_URL: http://127.0.0.1:54321 # Default local URL
|
||||||
SUPABASE_SERVICE_ROLE_KEY: ${{ steps.setup_env.outputs.supabase-service-role-key }}
|
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.GH_ACTIONS_SUPABASE_SERVICE_ROLE_KEY }} # Use secret
|
||||||
RUST_LOG: debug # Or adjust as needed
|
RUST_LOG: debug # Or adjust as needed
|
||||||
|
|
||||||
# Sensitive values from Secrets
|
# Sensitive values from Secrets
|
||||||
|
|
|
@ -32,50 +32,23 @@ jobs:
|
||||||
|
|
||||||
# Node.js setup removed - not needed for cargo test
|
# Node.js setup removed - not needed for cargo test
|
||||||
|
|
||||||
- name: Install Supabase CLI
|
|
||||||
run: npm install --global supabase@latest
|
|
||||||
|
|
||||||
- name: Install Rust
|
|
||||||
uses: actions-rs/toolchain@v1
|
|
||||||
with:
|
|
||||||
toolchain: stable
|
|
||||||
profile: minimal
|
|
||||||
override: true
|
|
||||||
|
|
||||||
- name: Cache Rust dependencies
|
|
||||||
uses: Swatinem/rust-cache@v2
|
|
||||||
# Consider a different cache key if CLI dependencies are separate
|
|
||||||
# with:
|
|
||||||
# key: ${{ runner.os }}-cargo-cli-${{ hashFiles('**/cli/Cargo.lock') }}
|
|
||||||
|
|
||||||
- name: Install Diesel CLI
|
|
||||||
run: cargo install diesel_cli --no-default-features --features postgres
|
|
||||||
|
|
||||||
- name: Setup Test Environment
|
- name: Setup Test Environment
|
||||||
id: setup_env # Give an ID to reference outputs
|
|
||||||
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:
|
||||||
# Pass necessary env vars from setup action outputs
|
# Use hardcoded default values and secrets
|
||||||
DATABASE_URL: ${{ steps.setup_env.outputs.database-url }}
|
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 # Connect to the Redis service container
|
||||||
JWT_SECRET: ${{ steps.setup_env.outputs.jwt-secret }}
|
JWT_SECRET: ${{ secrets.GH_ACTIONS_SUPABASE_JWT_SECRET }} # Use secret
|
||||||
SUPABASE_URL: ${{ steps.setup_env.outputs.supabase-url }}
|
SUPABASE_URL: http://127.0.0.1:54321 # Default local URL
|
||||||
SUPABASE_SERVICE_ROLE_KEY: ${{ steps.setup_env.outputs.supabase-service-role-key }}
|
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.GH_ACTIONS_SUPABASE_SERVICE_ROLE_KEY }} # Use secret
|
||||||
RUST_LOG: debug # Or adjust as needed
|
RUST_LOG: debug # Or adjust as needed
|
||||||
|
|
||||||
# Add any other environment variables your CLI tests might require
|
# Add any other environment variables your CLI tests might require
|
||||||
|
|
||||||
# Sensitive values from Secrets (if needed by CLI tests)
|
|
||||||
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 }}
|
|
||||||
|
|
||||||
- name: Stop Supabase # Use the cleanup action
|
- name: Stop Supabase # Use the cleanup action
|
||||||
uses: ./.github/actions/stop-supabase
|
uses: ./.github/actions/stop-supabase
|
||||||
if: always() # Ensure Supabase is stopped even if tests fail
|
if: always() # Ensure Supabase is stopped even if tests fail
|
||||||
|
|
|
@ -36,7 +36,6 @@ jobs:
|
||||||
node-version: '20'
|
node-version: '20'
|
||||||
|
|
||||||
- name: Setup Test Environment
|
- name: Setup Test Environment
|
||||||
id: setup_env # Give an ID to reference outputs
|
|
||||||
uses: ./.github/actions/setup-test-environment
|
uses: ./.github/actions/setup-test-environment
|
||||||
|
|
||||||
# Build/Run/Wait steps remain for web testing as it needs the API server running
|
# Build/Run/Wait steps remain for web testing as it needs the API server running
|
||||||
|
@ -45,7 +44,7 @@ jobs:
|
||||||
run: cargo build --release
|
run: cargo build --release
|
||||||
env:
|
env:
|
||||||
# Potentially needed if build process requires env vars, though unlikely
|
# Potentially needed if build process requires env vars, though unlikely
|
||||||
DATABASE_URL: ${{ steps.setup_env.outputs.database-url }}
|
DATABASE_URL: postgres://postgres:postgres@127.0.0.1:54322/postgres
|
||||||
|
|
||||||
- name: Run API Server
|
- name: Run API Server
|
||||||
working-directory: ./api
|
working-directory: ./api
|
||||||
|
@ -53,13 +52,13 @@ jobs:
|
||||||
./target/release/server & # Run in background
|
./target/release/server & # Run in background
|
||||||
echo $! > /tmp/api-server.pid # Store PID for later cleanup
|
echo $! > /tmp/api-server.pid # Store PID for later cleanup
|
||||||
env:
|
env:
|
||||||
# Core Supabase/DB/Redis vars from setup action outputs
|
# Core Supabase/DB/Redis vars - use hardcoded values and secrets
|
||||||
DATABASE_URL: ${{ steps.setup_env.outputs.database-url }}
|
DATABASE_URL: postgres://postgres:postgres@127.0.0.1:54322/postgres
|
||||||
POOLER_URL: ${{ steps.setup_env.outputs.database-url }} # Assuming pooler uses same DB
|
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
|
REDIS_URL: redis://localhost:6379 # Use localhost as it runs on the runner accessing the service
|
||||||
JWT_SECRET: ${{ steps.setup_env.outputs.jwt-secret }}
|
JWT_SECRET: ${{ secrets.GH_ACTIONS_SUPABASE_JWT_SECRET }} # Use secret
|
||||||
SUPABASE_URL: ${{ steps.setup_env.outputs.supabase-url }}
|
SUPABASE_URL: http://127.0.0.1:54321 # Default local URL
|
||||||
SUPABASE_SERVICE_ROLE_KEY: ${{ steps.setup_env.outputs.supabase-service-role-key }}
|
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.GH_ACTIONS_SUPABASE_SERVICE_ROLE_KEY }} # Use secret
|
||||||
|
|
||||||
# Non-sensitive / Default values
|
# Non-sensitive / Default values
|
||||||
ENVIRONMENT: development
|
ENVIRONMENT: development
|
||||||
|
@ -76,7 +75,6 @@ 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
|
- name: Wait for API Server
|
||||||
run: |
|
run: |
|
||||||
echo "Waiting for API server (localhost:3001) to be ready..."
|
echo "Waiting for API server (localhost:3001) to be ready..."
|
||||||
|
@ -104,9 +102,9 @@ jobs:
|
||||||
# API runs on localhost within the runner
|
# API runs on localhost within the runner
|
||||||
NEXT_PUBLIC_API_URL: http://localhost:3001
|
NEXT_PUBLIC_API_URL: http://localhost: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 from the setup action outputs
|
# Use Supabase details - default URL and secret anon key
|
||||||
NEXT_PUBLIC_SUPABASE_URL: ${{ steps.setup_env.outputs.supabase-url }}
|
NEXT_PUBLIC_SUPABASE_URL: http://127.0.0.1:54321 # Default local URL
|
||||||
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ steps.setup_env.outputs.supabase-anon-key }}
|
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.GH_ACTIONS_SUPABASE_ANON_KEY }} # Use secret
|
||||||
NEXT_PUBLIC_WEB_SOCKET_URL: ws://localhost:3001 # Assuming WS connects to API
|
NEXT_PUBLIC_WEB_SOCKET_URL: ws://localhost:3001 # Assuming WS connects to API
|
||||||
|
|
||||||
# Pass any other required NEXT_PUBLIC_ variables
|
# Pass any other required NEXT_PUBLIC_ variables
|
||||||
|
|
Loading…
Reference in New Issue