buster/.github/workflows/api-testing.yml

76 lines
2.8 KiB
YAML

name: API Testing
on:
pull_request:
branches:
- main
jobs:
test:
runs-on: blacksmith-32vcpu-ubuntu-2204
environment: testing
# Service container for Redis (needed by the setup action)
services:
redis:
image: redis
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v4
# Node.js setup removed
- name: Setup Test Environment
uses: ./.github/actions/setup-test-environment
- name: Mount Cargo Home Cache (Sticky Disk)
uses: useblacksmith/stickydisk@v1
with:
key: ${{ github.repository }}-cargo-home # Unique key per repository
path: ~/.cargo # Cache cargo registry/git data
- name: Mount API Target Cache (Sticky Disk)
uses: useblacksmith/stickydisk@v1
with:
key: ${{ github.repository }}-api-target # Unique key per repository
path: ./api/target # Cache build artifacts
- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable # Or specify a version
- name: Run API Tests
working-directory: ./api # Tests run from the api directory
run: cargo test --workspace # Run tests for all packages in the api workspace
env:
RUST_TEST_THREADS: 24
# Use hardcoded default values and secrets
DATABASE_URL: postgres://postgres:postgres@127.0.0.1:54322/postgres
REDIS_URL: redis://localhost:6379 # Connect to the Redis service container
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_SERVICE_ROLE_KEY: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MjM0MzA5Nn0.EGgMpd9zvvHPCOq4DJRLwzJ1iS3GV4AEyzguXGcbEIY' # Use default local value
RUST_LOG: debug # Or adjust as needed
# Sensitive values from Secrets
OPENAI_API_KEY: ${{ secrets.GH_ACTIONS_OPENAI_API_KEY }}
RESEND_API_KEY: ${{ secrets.GH_ACTIONS_RESEND_API_KEY }}
LLM_API_KEY: ${{ secrets.GH_ACTIONS_LLM_API_KEY }}
LLM_BASE_URL: ${{ secrets.GH_ACTIONS_LLM_BASE_URL }}
RERANK_API_KEY: ${{ secrets.GH_ACTIONS_COHERE_API_KEY }}
RERANK_MODEL: rerank-v3.5
RERANK_BASE_URL: https://api.cohere.com/v2/rerank
- name: Stop Supabase # Use the cleanup action
uses: ./.github/actions/stop-supabase
if: always() # Ensure Supabase is stopped even if tests fail