Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
lint-and-typecheck:
name: Lint & Type Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Type check
run: npx tsc --noEmit

unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Run unit tests
run: npm run test:run

- name: Upload coverage
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report
path: coverage/
retention-days: 7

build:
name: Build
runs-on: ubuntu-latest
env:
NEXT_PUBLIC_BACKEND_URL: http://localhost:8080
NEXT_PUBLIC_BETTER_AUTH_URL: http://localhost:8082/auth
NEXT_PUBLIC_DASHBOARD_HOME_PAGE: /dashboard/flowsheet
NEXT_PUBLIC_VERSION: ci
NEXT_PUBLIC_DEFAULT_EXPERIENCE: modern
NEXT_PUBLIC_ENABLED_EXPERIENCES: modern,classic
NEXT_PUBLIC_ALLOW_EXPERIENCE_SWITCHING: "true"
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build
188 changes: 188 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
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
NEXT_PUBLIC_APP_ORGANIZATION: test-org
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 -- --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
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

# testing
/coverage
/test-results/
/playwright-report/
/playwright/.cache/

# next.js
/.next/
Expand Down Expand Up @@ -39,3 +42,7 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts
e2e/.auth
e2e/.e2e-ports
e2e/.djsite.log
e2e/.djsite.pid
Loading
Loading