remove organization claim logging and add keycloak configuration guide #69
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: Tests | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| jobs: | |
| backend-lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Install dependencies | |
| working-directory: backend | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Run linting | |
| working-directory: backend | |
| run: | | |
| pip install ruff | |
| ruff check . --output-format=concise --exclude database/migrations | |
| simulator-lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Install dependencies | |
| working-directory: simulator | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Run linting | |
| working-directory: simulator | |
| run: | | |
| pip install ruff | |
| ruff check . --output-format=concise | |
| frontend-lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| cache-dependency-path: web/package-lock.json | |
| - name: Install dependencies | |
| working-directory: web | |
| run: npm ci | |
| - name: Run linter | |
| working-directory: web | |
| run: npm run lint | |
| backend-tests: | |
| needs: [backend-lint] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.11", "3.12", "3.13"] | |
| services: | |
| postgres: | |
| image: postgres:15 | |
| env: | |
| POSTGRES_USER: test | |
| POSTGRES_PASSWORD: test | |
| POSTGRES_DB: test | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| redis: | |
| image: redis:7-alpine | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 6379:6379 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Cache pip packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('backend/requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install dependencies | |
| working-directory: backend | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Run unit tests | |
| working-directory: backend | |
| run: | | |
| pytest tests/unit -v --cov=api --cov=database --cov-report=xml --cov-report=term | |
| - name: Run integration tests | |
| working-directory: backend | |
| run: | | |
| pytest tests/integration -v | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| file: ./backend/coverage.xml | |
| flags: backend | |
| name: backend-coverage | |
| frontend-tests: | |
| needs: [frontend-lint] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| cache-dependency-path: web/package-lock.json | |
| - name: Install dependencies | |
| working-directory: web | |
| run: npm ci | |
| - name: Type check | |
| working-directory: web | |
| run: npx tsc --noEmit | |
| e2e-tests: | |
| needs: [backend-tests, frontend-tests] | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:15 | |
| env: | |
| POSTGRES_USER: test | |
| POSTGRES_PASSWORD: test | |
| POSTGRES_DB: test | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| redis: | |
| image: redis:7-alpine | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 6379:6379 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| cache-dependency-path: web/package-lock.json | |
| - name: Install backend dependencies | |
| working-directory: backend | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Install frontend dependencies | |
| working-directory: web | |
| run: npm ci | |
| - name: Install E2E test dependencies | |
| working-directory: tests | |
| run: npm ci | |
| - name: Install Playwright browsers | |
| working-directory: tests | |
| run: npx playwright install --with-deps chromium | |
| continue-on-error: true | |
| - name: Run database migrations | |
| working-directory: backend | |
| run: | | |
| alembic upgrade head | |
| env: | |
| DATABASE_URL: postgresql+asyncpg://test:test@localhost:5432/test | |
| - name: Start backend server | |
| working-directory: backend | |
| run: | | |
| uvicorn main:app --host 0.0.0.0 --port 8000 > /tmp/backend.log 2>&1 & | |
| BACKEND_PID=$! | |
| echo $BACKEND_PID > /tmp/backend.pid | |
| echo "Backend started with PID: $BACKEND_PID" | |
| sleep 3 | |
| env: | |
| DATABASE_URL: postgresql+asyncpg://test:test@localhost:5432/test | |
| REDIS_URL: redis://localhost:6379 | |
| ISSUER_URI: http://localhost:8080/realms/tasks | |
| PUBLIC_ISSUER_URI: http://localhost:8080/realms/tasks | |
| CLIENT_ID: tasks-backend | |
| CLIENT_SECRET: tasks-secret | |
| ENV: test | |
| INFLUXDB_URL: http://localhost:8086 | |
| INFLUXDB_TOKEN: test-token | |
| INFLUXDB_ORG: test | |
| INFLUXDB_BUCKET: test | |
| - name: Build frontend | |
| working-directory: web | |
| run: npm run build | |
| env: | |
| NEXT_PUBLIC_API_URL: http://localhost:8000/graphql | |
| - name: Start frontend server | |
| working-directory: web | |
| run: | | |
| npm start > /tmp/frontend.log 2>&1 & | |
| FRONTEND_PID=$! | |
| echo $FRONTEND_PID > /tmp/frontend.pid | |
| echo "Frontend started with PID: $FRONTEND_PID" | |
| sleep 3 | |
| env: | |
| NEXT_PUBLIC_API_URL: http://localhost:8000/graphql | |
| - name: Wait for backend | |
| run: | | |
| echo "Waiting for backend to start..." | |
| sleep 10 | |
| for i in {1..60}; do | |
| if curl -f -s http://localhost:8000/health > /dev/null 2>&1; then | |
| echo "Backend is ready!" | |
| exit 0 | |
| fi | |
| if [ $i -le 10 ]; then | |
| echo "Attempt $i/60: Backend not ready yet..." | |
| fi | |
| sleep 2 | |
| done | |
| echo "Backend failed to start after 120 seconds" | |
| echo "=== Backend Log ===" | |
| cat /tmp/backend.log || echo "No backend log found" | |
| echo "=== Checking if process is running ===" | |
| ps aux | grep uvicorn || echo "No uvicorn process found" | |
| exit 1 | |
| - name: Wait for frontend | |
| run: | | |
| echo "Waiting for frontend to start..." | |
| sleep 5 | |
| for i in {1..60}; do | |
| if curl -f -s http://localhost:3000 > /dev/null 2>&1; then | |
| echo "Frontend is ready!" | |
| exit 0 | |
| fi | |
| echo "Attempt $i/60: Frontend not ready yet..." | |
| sleep 2 | |
| done | |
| echo "Frontend failed to start after 120 seconds" | |
| echo "=== Frontend Log ===" | |
| cat /tmp/frontend.log || echo "No frontend log found" | |
| exit 1 | |
| - name: Verify servers are running | |
| run: | | |
| echo "=== Verifying servers ===" | |
| if curl -f -s http://localhost:8000/health > /dev/null 2>&1; then | |
| echo "✓ Backend is running" | |
| else | |
| echo "✗ Backend is not running" | |
| echo "Backend log:" | |
| tail -20 /tmp/backend.log || echo "No backend log" | |
| exit 1 | |
| fi | |
| if curl -f -s http://localhost:3000 > /dev/null 2>&1; then | |
| echo "✓ Frontend is running" | |
| else | |
| echo "✗ Frontend is not running" | |
| echo "Frontend log:" | |
| tail -20 /tmp/frontend.log || echo "No frontend log" | |
| exit 1 | |
| fi | |
| echo "=== Server processes ===" | |
| ps aux | grep -E "(uvicorn|node)" | grep -v grep || echo "No server processes found" | |
| - name: Run E2E tests | |
| working-directory: tests | |
| env: | |
| E2E_BASE_URL: http://localhost:3000 | |
| CI: true | |
| run: | | |
| echo "E2E_BASE_URL is set to: $E2E_BASE_URL" | |
| echo "Testing connection to frontend..." | |
| curl -f -s http://localhost:3000 > /dev/null && echo "Frontend is accessible" || echo "Frontend is not accessible" | |
| npx playwright test | |
| - name: Upload Playwright report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: playwright-report | |
| path: tests/playwright-report/ | |
| retention-days: 30 | |
| - name: Upload server logs | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: server-logs | |
| path: | | |
| /tmp/backend.log | |
| /tmp/frontend.log | |
| retention-days: 7 | |
| build: | |
| needs: [backend-tests, frontend-tests, e2e-tests, simulator-lint] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| cache-dependency-path: web/package-lock.json | |
| - name: Install backend dependencies | |
| working-directory: backend | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Install frontend dependencies | |
| working-directory: web | |
| run: npm ci | |
| - name: Build frontend | |
| working-directory: web | |
| run: npm run build | |
| - name: Upload build artifacts | |
| if: success() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: frontend-build | |
| path: web/build | |
| retention-days: 7 |