update profile page and UX experience #34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Auth Server Tests | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - feat/** | |
| paths: | |
| - 'auth-server/**' | |
| - '.github/workflows/test-auth.yml' | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - 'auth-server/**' | |
| - '.github/workflows/test-auth.yml' | |
| jobs: | |
| test: | |
| name: Run Auth Server Tests | |
| runs-on: ubuntu-latest | |
| # PostgreSQL service for database tests | |
| services: | |
| postgres: | |
| image: postgres:16 | |
| env: | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: auth_test | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| defaults: | |
| run: | |
| working-directory: ./auth-server | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'pnpm' | |
| cache-dependency-path: './auth-server/pnpm-lock.yaml' | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Setup environment variables | |
| run: | | |
| cat > .env.local << EOF | |
| # Database | |
| DATABASE_URL=postgresql://postgres:postgres@localhost:5432/auth_test | |
| # Better Auth | |
| BETTER_AUTH_SECRET=${{ secrets.BETTER_AUTH_SECRET || 'test-secret-key-for-ci-do-not-use-in-production-min-32-chars' }} | |
| BETTER_AUTH_URL=http://localhost:3001 | |
| # CORS Configuration | |
| ALLOWED_ORIGINS=http://localhost:3000,http://localhost:3001 | |
| # Client-side configuration | |
| NEXT_PUBLIC_BETTER_AUTH_URL=http://localhost:3001 | |
| NEXT_PUBLIC_APP_NAME=Auth Server CI | |
| NEXT_PUBLIC_ORG_NAME=RoboLearn | |
| # Email (test mode - no actual emails sent) | |
| [email protected] | |
| EMAIL_PROVIDER=console | |
| # Node environment | |
| NODE_ENV=test | |
| # Disable email verification for automated testing | |
| DISABLE_EMAIL_VERIFICATION=true | |
| EOF | |
| - name: Run database migrations | |
| run: pnpm db:push | |
| - name: Seed test data | |
| run: pnpm seed:setup | |
| - name: Start auth server in background | |
| run: | | |
| pnpm dev & | |
| echo $! > .server.pid | |
| # Wait for server to be ready (max 120 seconds for first compilation) | |
| echo "Waiting for Next.js to compile and server to be ready..." | |
| for i in {1..120}; do | |
| # Check health endpoint (verifies server AND database connection) | |
| if curl -sf http://localhost:3001/api/health > /dev/null 2>&1; then | |
| echo "✅ Server is healthy and ready!" | |
| curl -s http://localhost:3001/api/health | |
| break | |
| fi | |
| if [ $i -eq 120 ]; then | |
| echo "❌ Server failed to start within 120 seconds" | |
| echo "Last 50 lines of server logs:" | |
| tail -50 .next/trace || echo "No trace file found" | |
| exit 1 | |
| fi | |
| # Show progress every 10 seconds | |
| if [ $((i % 10)) -eq 0 ]; then | |
| echo "Still waiting... ($i/120 seconds)" | |
| fi | |
| sleep 1 | |
| done | |
| - name: Create admin user via Better Auth API | |
| run: | | |
| echo "Creating admin user through Better Auth signup..." | |
| curl -X POST http://localhost:3001/api/auth/sign-up/email \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"email":"[email protected]","password":"RoboLearnAdmin2024!SecureTest","name":"Admin User"}' \ | |
| -v || echo "Admin user might already exist (that's okay)" | |
| - name: Run API tests | |
| run: pnpm test-api | |
| timeout-minutes: 5 | |
| - name: Run E2E tests | |
| run: pnpm test-e2e | |
| timeout-minutes: 5 | |
| - name: Stop auth server | |
| if: always() | |
| run: | | |
| if [ -f .server.pid ]; then | |
| kill $(cat .server.pid) || true | |
| rm .server.pid | |
| fi | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results | |
| path: | | |
| auth-server/test-results.json | |
| auth-server/tests/**/*.log | |
| retention-days: 7 | |
| security-audit: | |
| name: Security Audit | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: ./auth-server | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'pnpm' | |
| cache-dependency-path: './auth-server/pnpm-lock.yaml' | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Run security audit | |
| run: pnpm audit --audit-level=moderate | |
| continue-on-error: true | |
| - name: Check for outdated dependencies | |
| run: pnpm outdated | |
| continue-on-error: true |