Skip to content

fix(middleware): Add specific handling for /docs path (ENG-592) #3195

fix(middleware): Add specific handling for /docs path (ENG-592)

fix(middleware): Add specific handling for /docs path (ENG-592) #3195

Workflow file for this run

name: Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest # Reverted to standard runner due to availability issues
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x
- name: Setup PNPM
uses: pnpm/action-setup@v2
with:
version: 10.x
- name: Cache turbo build setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-test-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-test-
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Run Typecheck
run: |
pnpm --filter apis.do build
pnpm --filter @drivly/payload-agent build
# Temporarily disabled typecheck as requested
# pnpm typecheck
echo "Typecheck temporarily disabled as requested"
- name: Run Tests & Install Playwright Browsers Concurrently
run: |
# Start Playwright browser installation in the background
pnpm exec playwright install --with-deps &
PLAYWRIGHT_INSTALL_PID=$!
# Run tests while browsers are installing
pnpm test
# Wait for Playwright installation to complete if it's still running
if ps -p $PLAYWRIGHT_INSTALL_PID > /dev/null; then
echo "Waiting for Playwright browser installation to complete..."
wait $PLAYWRIGHT_INSTALL_PID
fi
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
DATABASE_URI: ${{ secrets.DATABASE_URI }}
PAYLOAD_SECRET: ${{ secrets.PAYLOAD_SECRET }}
- name: Start Dev Server
run: |
# Export all needed environment variables for the server
export DATABASE_URI="${{ secrets.DATABASE_URI }}"
export PAYLOAD_SECRET="${{ secrets.PAYLOAD_SECRET }}"
export RESEND_API_KEY="mock_resend_api_key_for_tests"
# Start server in background with all needed env vars
pnpm dev &
echo $! > .server.pid
env:
DATABASE_URI: ${{ secrets.DATABASE_URI }}
PAYLOAD_SECRET: ${{ secrets.PAYLOAD_SECRET }}
RESEND_API_KEY: mock_resend_api_key_for_tests # Mock Resend for server startup
- name: Wait for Server
run: |
echo "Waiting for server to start..."
MAX_RETRIES=60
RETRY_COUNT=0
# Use /api/health endpoint as specified
until curl -s http://localhost:3000/api/health > /dev/null || [ $RETRY_COUNT -eq $MAX_RETRIES ]; do
echo "Attempt $((RETRY_COUNT+1))/$MAX_RETRIES - Server not ready yet, waiting 1s..."
sleep 1
RETRY_COUNT=$((RETRY_COUNT+1))
done
if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then
echo "Server failed to start after $MAX_RETRIES attempts"
exit 1
fi
# Additional check to confirm main page is also loading
echo "Health check passed. Now verifying main page is accessible..."
if curl -s http://localhost:3000/ -o /dev/null -w "%{http_code}" | grep -q "200"; then
echo "Main page is accessible. Server is ready!"
else
echo "Warning: Health check passed but main page is not accessible yet."
echo "Will proceed with tests, but they might fail if pages aren't ready."
fi
- name: Run Playwright Tests and Chromatic
run: |
# First run Playwright tests to generate the archives needed by Chromatic
# Add retry and longer timeouts to handle potential timing issues
pnpm exec playwright test tests/chromatic --retries=3 --timeout=180000
# Then run Chromatic with auto-accept-changes for first-time snapshots
# Exit immediately after upload to save time
npx chromatic --playwright --project-token=${CHROMATIC_PROJECT_TOKEN} --auto-accept-changes --exit-zero-on-changes --exit-once-uploaded
env:
CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
# Set environment variables for tests
RESEND_API_KEY: mock_resend_api_key_for_tests # Mock Resend for test execution context
CI: true
DATABASE_URI: ${{ secrets.DATABASE_URI }} # Needed for test execution context if tests interact with DB indirectly
PAYLOAD_SECRET: ${{ secrets.PAYLOAD_SECRET }} # Needed for test execution context
TEST_BASE_URL: http://localhost:3000 # Explicitly set the test base URL