New authentication provider with tests #9
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: E2E Tests | |
| on: | |
| push: | |
| branches: [main, new-authentication-provider] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| inputs: | |
| backend_ref: | |
| description: 'Backend-Service branch/tag to use' | |
| required: false | |
| default: 'main' | |
| env: | |
| # Frontend configuration | |
| NEXT_PUBLIC_BACKEND_URL: http://localhost:8085 | |
| NEXT_PUBLIC_BETTER_AUTH_URL: http://localhost:8084/auth | |
| NEXT_PUBLIC_DASHBOARD_HOME_PAGE: /dashboard/flowsheet | |
| NEXT_PUBLIC_VERSION: e2e | |
| NEXT_PUBLIC_DEFAULT_EXPERIENCE: modern | |
| NEXT_PUBLIC_ENABLED_EXPERIENCES: modern,classic | |
| NEXT_PUBLIC_ALLOW_EXPERIENCE_SWITCHING: "true" | |
| NEXT_PUBLIC_ONBOARDING_TEMP_PASSWORD: temppass123 | |
| SESSION_SECRET: e2e-secret-for-testing | |
| APP_ORGANIZATION_ID: test-org-id-0000000000000000001 | |
| # E2E test config | |
| E2E_BASE_URL: http://localhost:3000 | |
| # Backend service ports (E2E profile) | |
| E2E_DB_PORT: 5434 | |
| E2E_AUTH_PORT: 8084 | |
| E2E_BACKEND_PORT: 8085 | |
| jobs: | |
| e2e: | |
| name: E2E Tests | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 45 | |
| steps: | |
| - name: Checkout dj-site | |
| uses: actions/checkout@v4 | |
| with: | |
| path: dj-site | |
| - name: Checkout Backend-Service | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ${{ github.repository_owner }}/Backend-Service | |
| ref: ${{ github.event.inputs.backend_ref || 'main' }} | |
| path: Backend-Service | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| cache-dependency-path: | | |
| dj-site/package-lock.json | |
| Backend-Service/package-lock.json | |
| - name: Create Backend .env file | |
| working-directory: Backend-Service | |
| run: | | |
| cat > .env << 'EOF' | |
| DB_HOST=localhost | |
| DB_PORT=5434 | |
| DB_NAME=wxyc_db | |
| DB_USERNAME=wxyc_admin | |
| DB_PASSWORD='RadioIsEpic$1100' | |
| BETTER_AUTH_SECRET=e2e-auth-secret-for-testing-min-32-chars | |
| BETTER_AUTH_URL=http://localhost:8084/auth | |
| BETTER_AUTH_TRUSTED_ORIGINS=http://localhost:3000 | |
| FRONTEND_SOURCE=http://localhost:3000 | |
| DEFAULT_ORG_SLUG=test-org | |
| DEFAULT_ORG_NAME=Test Organization | |
| APP_ORGANIZATION_ID=test-org-id-0000000000000000001 | |
| E2E_DB_PORT=5434 | |
| E2E_AUTH_PORT=8084 | |
| E2E_BACKEND_PORT=8085 | |
| EOF | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Start backend services with Docker Compose | |
| working-directory: Backend-Service | |
| run: | | |
| # Build and start E2E services | |
| docker compose -f dev_env/docker-compose.yml --env-file .env --profile e2e up -d e2e-db | |
| # Wait for database to be ready | |
| echo "Waiting for database..." | |
| timeout 60 bash -c 'until docker compose -f dev_env/docker-compose.yml --env-file .env --profile e2e exec -T e2e-db pg_isready; do sleep 2; done' | |
| # Run database initialization | |
| docker compose -f dev_env/docker-compose.yml --env-file .env --profile e2e up e2e-db-init | |
| # Start auth and backend services | |
| docker compose -f dev_env/docker-compose.yml --env-file .env --profile e2e up -d e2e-auth e2e-backend | |
| # Wait for services to be healthy | |
| echo "Waiting for auth service..." | |
| timeout 120 bash -c 'until curl -sf http://localhost:8084/healthcheck; do sleep 5; done' | |
| echo "Waiting for backend service..." | |
| timeout 120 bash -c 'until curl -sf http://localhost:8085/healthcheck; do sleep 5; done' | |
| - name: Install Backend-Service dependencies | |
| working-directory: Backend-Service | |
| run: npm ci | |
| - name: Build Backend-Service workspaces | |
| working-directory: Backend-Service | |
| run: npm run build | |
| - name: Set up E2E test users | |
| working-directory: Backend-Service | |
| env: | |
| DB_HOST: localhost | |
| DB_PORT: 5434 | |
| DB_NAME: wxyc_db | |
| DB_USERNAME: wxyc_admin | |
| DB_PASSWORD: 'RadioIsEpic$1100' | |
| BETTER_AUTH_JWKS_URL: http://localhost:8084/auth/.well-known/jwks.json | |
| run: | | |
| # Wait a moment for services to fully stabilize | |
| sleep 5 | |
| npm run setup:e2e-users | |
| - name: Install dj-site dependencies | |
| working-directory: dj-site | |
| run: npm ci | |
| - name: Install Playwright browsers | |
| working-directory: dj-site | |
| run: npx playwright install --with-deps chromium | |
| - name: Build dj-site | |
| working-directory: dj-site | |
| run: npm run build | |
| - name: Start dj-site | |
| working-directory: dj-site | |
| run: | | |
| npm run start & | |
| # Wait for frontend to be ready | |
| echo "Waiting for frontend..." | |
| timeout 60 bash -c 'until curl -sf http://localhost:3000; do sleep 2; done' | |
| - name: Run E2E tests | |
| working-directory: dj-site | |
| run: npm run test:e2e -- --project=chromium --reporter=html --reporter=github | |
| - name: Show service logs on failure | |
| if: failure() | |
| working-directory: Backend-Service | |
| run: | | |
| echo "=== Auth Service Logs ===" | |
| docker compose -f dev_env/docker-compose.yml --env-file .env --profile e2e logs e2e-auth --tail=100 | |
| echo "" | |
| echo "=== Backend Service Logs ===" | |
| docker compose -f dev_env/docker-compose.yml --env-file .env --profile e2e logs e2e-backend --tail=100 | |
| - name: Upload Playwright report | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: playwright-report | |
| path: dj-site/playwright-report/ | |
| retention-days: 30 | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: failure() | |
| with: | |
| name: test-results | |
| path: dj-site/test-results/ | |
| retention-days: 7 | |
| - name: Cleanup | |
| if: always() | |
| working-directory: Backend-Service | |
| run: | | |
| docker compose -f dev_env/docker-compose.yml --env-file .env --profile e2e down -v --remove-orphans |