chore: Add playwright tests for app in local-only mode #1
Workflow file for this run
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] | |
| pull_request: | |
| branches: [main] | |
| workflow_call: | |
| # Allow this workflow to be called by other workflows | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| e2e-tests: | |
| name: End-to-End Tests | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 20 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: '.nvmrc' | |
| cache-dependency-path: 'yarn.lock' | |
| cache: 'yarn' | |
| - name: Install dependencies | |
| run: yarn install | |
| - name: Build dependencies | |
| run: make ci-build | |
| - name: Setup Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Start infrastructure services | |
| run: | | |
| # Set environment variables | |
| export HYPERDX_API_KEY="test-api-key" | |
| export HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE="default" | |
| export HYPERDX_LOG_LEVEL="info" | |
| # Start infrastructure services only (ClickHouse, MongoDB, OTEL Collector) | |
| docker-compose -f docker-compose.e2e.yml up -d | |
| # Wait for infrastructure services to be ready | |
| echo "Waiting for infrastructure services..." | |
| timeout 120 bash -c 'until curl -f http://localhost:8124/ping; do sleep 2; done' | |
| timeout 120 bash -c 'until nc -z localhost 27018; do sleep 2; done' | |
| echo "Infrastructure services are ready!" | |
| - name: Start API server | |
| run: | | |
| cd packages/api | |
| MONGO_URI=mongodb://localhost:27018/hyperdx-e2e \ | |
| CLICKHOUSE_HOST=http://localhost:8124 \ | |
| CLICKHOUSE_USER=default \ | |
| CLICKHOUSE_PASSWORD="" \ | |
| CLICKHOUSE_DATABASE=default \ | |
| HYPERDX_API_KEY=test-api-key \ | |
| PORT=8000 \ | |
| NODE_ENV=test \ | |
| yarn build | |
| MONGO_URI=mongodb://localhost:27018/hyperdx-e2e \ | |
| CLICKHOUSE_HOST=http://localhost:8124 \ | |
| CLICKHOUSE_USER=default \ | |
| CLICKHOUSE_PASSWORD="" \ | |
| CLICKHOUSE_DATABASE=default \ | |
| HYPERDX_API_KEY=test-api-key \ | |
| PORT=8000 \ | |
| NODE_ENV=test \ | |
| yarn start & | |
| # Wait for API to be ready | |
| timeout 120 bash -c 'until curl -f http://localhost:8000/health; do sleep 2; done' | |
| echo "API server is ready!" | |
| - name: Start frontend app | |
| run: | | |
| cd packages/app | |
| HYPERDX_API_URL=http://localhost:8000 \ | |
| NEXT_PUBLIC_HYPERDX_API_URL=http://localhost:8000 \ | |
| NODE_ENV=test \ | |
| yarn build | |
| HYPERDX_API_URL=http://localhost:8000 \ | |
| NEXT_PUBLIC_HYPERDX_API_URL=http://localhost:8000 \ | |
| NODE_ENV=test \ | |
| PORT=3000 \ | |
| yarn start & | |
| # Wait for App to be ready | |
| timeout 120 bash -c 'until curl -f http://localhost:3000/api/health; do sleep 2; done' | |
| echo "Frontend app is ready!" | |
| - name: Install Playwright browsers | |
| run: | | |
| cd packages/app | |
| npx playwright install --with-deps chromium | |
| - name: Run Playwright tests | |
| run: | | |
| cd packages/app | |
| npx playwright test | |
| env: | |
| PLAYWRIGHT_BASE_URL: http://localhost:3000 | |
| E2E_MODE: true | |
| # Enable full authentication testing in CI | |
| E2E_AUTH_MODE: true | |
| - name: Upload Playwright report | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: playwright-report | |
| path: packages/app/playwright-report/ | |
| retention-days: 30 | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-results | |
| path: packages/app/test-results/ | |
| retention-days: 30 | |
| - name: Stop Docker services | |
| if: always() | |
| run: | | |
| docker-compose -f docker-compose.e2e.yml down -v | |
| - name: Comment PR with test results | |
| uses: actions/github-script@v7 | |
| if: always() && github.event_name == 'pull_request' | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| try { | |
| const resultsPath = path.join('packages/app/test-results/results.json'); | |
| if (fs.existsSync(resultsPath)) { | |
| const results = JSON.parse(fs.readFileSync(resultsPath, 'utf8')); | |
| const { stats } = results; | |
| const body = `## 🎭 Playwright Test Results | |
| **Tests:** ${stats.expected + stats.unexpected + stats.flaky + stats.skipped} | |
| **✅ Passed:** ${stats.expected} | |
| **❌ Failed:** ${stats.unexpected} | |
| **⚠️ Flaky:** ${stats.flaky} | |
| **⏭️ Skipped:** ${stats.skipped} | |
| **⏱️ Duration:** ${Math.round(stats.duration / 1000)}s | |
| ${stats.unexpected > 0 ? '❌ Some tests failed. Check the [Playwright report](https://github.com/' + context.repo.owner + '/' + context.repo.repo + '/actions/runs/' + context.runId + ') for details.' : '✅ All tests passed!'}`; | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: body | |
| }); | |
| } | |
| } catch (error) { | |
| console.log('Could not post test results:', error.message); | |
| } |