Skip to content
Merged
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
91 changes: 91 additions & 0 deletions .github/actions/e2e-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: E2E Setup
description: |
Shared setup for E2E test workflows: sets the HDX_E2E_* port env vars and
common Playwright env vars, then runs Node.js setup, dependency install,
build, Playwright browser install, and starts the E2E Docker Compose stack
(MongoDB + ClickHouse) with health checks. The caller is responsible for
`actions/checkout`, running Playwright, uploading artifacts, and tearing
down the Docker stack.
runs:
using: composite
steps:
# E2E port configuration (slot 0 defaults — must match scripts/test-e2e.sh)
- name: Set E2E environment variables
shell: bash
run: |
MONGO_PORT=21100
echo "HDX_E2E_SLOT=0" >> $GITHUB_ENV
echo "HDX_E2E_OPAMP_PORT=20320" >> $GITHUB_ENV
echo "HDX_E2E_CH_PORT=20500" >> $GITHUB_ENV
echo "HDX_E2E_CH_NATIVE_PORT=20600" >> $GITHUB_ENV
echo "HDX_E2E_API_PORT=21000" >> $GITHUB_ENV
echo "HDX_E2E_MONGO_PORT=$MONGO_PORT" >> $GITHUB_ENV
echo "HDX_E2E_APP_LOCAL_PORT=21200" >> $GITHUB_ENV
echo "HDX_E2E_APP_PORT=21300" >> $GITHUB_ENV
echo "MONGO_URI=mongodb://localhost:$MONGO_PORT/hyperdx-e2e" >> $GITHUB_ENV
echo "E2E_FULLSTACK=true" >> $GITHUB_ENV
echo "E2E_UNIQUE_USER=true" >> $GITHUB_ENV
echo "E2E_API_HEALTH_CHECK_MAX_RETRIES=60" >> $GITHUB_ENV

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: .nvmrc
cache-dependency-path: yarn.lock
cache: yarn

- name: Install dependencies
shell: bash
run: yarn install

- name: Build dependencies
shell: bash
run: npx nx run-many -t ci:build

- name: Install Playwright browsers
shell: bash
run: cd packages/app && npx playwright install --with-deps chromium

- name: Start E2E Docker Compose
shell: bash
run: |
# Pre-pull images with retries to handle transient Docker Hub timeouts
for attempt in 1 2 3; do
if docker compose -p e2e-0 -f packages/app/tests/e2e/docker-compose.yml pull; then
echo "Docker images pulled successfully on attempt $attempt"
break
fi
if [ "$attempt" -eq 3 ]; then
echo "Failed to pull Docker images after 3 attempts"
exit 1
fi
echo "Docker pull failed (attempt $attempt/3), retrying in 10s..."
sleep 10
done
docker compose -p e2e-0 -f packages/app/tests/e2e/docker-compose.yml up -d
echo "Waiting for MongoDB..."
for i in $(seq 1 30); do
if docker compose -p e2e-0 -f packages/app/tests/e2e/docker-compose.yml exec -T db mongosh --quiet --eval "db.adminCommand({ping:1})" >/dev/null 2>&1; then
echo "MongoDB is ready"
break
fi
if [ "$i" -eq 30 ]; then
echo "MongoDB failed to become ready after 30 seconds"
exit 1
fi
echo "Waiting for MongoDB... ($i/30)"
sleep 1
done
echo "Waiting for ClickHouse..."
for i in $(seq 1 60); do
if curl -sf http://localhost:${HDX_E2E_CH_PORT}/ping >/dev/null 2>&1; then
echo "ClickHouse is ready"
break
fi
if [ "$i" -eq 60 ]; then
echo "ClickHouse failed to become ready after 60 seconds"
exit 1
fi
echo "Waiting for ClickHouse... ($i/60)"
sleep 1
done
35 changes: 35 additions & 0 deletions .github/actions/e2e-teardown/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: E2E Teardown
description: |
Upload Playwright artifacts and stop the E2E Docker Compose stack.
Always runs (even on failure) so containers are cleaned up and reports
are available for failed runs.
inputs:
artifact-suffix:
description: >
Suffix appended to artifact names, e.g. "1" → playwright-report-1.
required: true
runs:
using: composite
steps:
- name: Upload Playwright report
uses: actions/upload-artifact@v7
if: always()
with:
name: playwright-report-${{ inputs.artifact-suffix }}
path: packages/app/playwright-report/
retention-days: 30

- name: Upload test results
uses: actions/upload-artifact@v7
if: always()
with:
name: test-results-${{ inputs.artifact-suffix }}
path: packages/app/test-results/
retention-days: 30

- name: Stop E2E containers
if: always()
shell: bash
run:
docker compose -p e2e-0 -f packages/app/tests/e2e/docker-compose.yml
down -v
99 changes: 5 additions & 94 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,109 +14,20 @@ jobs:
matrix:
shard: [1, 2, 3, 4]

# E2E port configuration (slot 0 defaults — must match scripts/test-e2e.sh)
env:
HDX_E2E_SLOT: '0'
HDX_E2E_OPAMP_PORT: '20320'
HDX_E2E_CH_PORT: '20500'
HDX_E2E_CH_NATIVE_PORT: '20600'
HDX_E2E_API_PORT: '21000'
HDX_E2E_MONGO_PORT: '21100'
HDX_E2E_APP_LOCAL_PORT: '21200'
HDX_E2E_APP_PORT: '21300'

steps:
- name: Checkout
uses: actions/checkout@v6

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
cache-dependency-path: 'yarn.lock'
cache: 'yarn'

- name: Install dependencies
run: yarn install

- name: Build dependencies
run: npx nx run-many -t ci:build

- name: Install Playwright browsers
run: cd packages/app && npx playwright install --with-deps chromium

- name: Start E2E Docker Compose
run: |
# Pre-pull images with retries to handle transient Docker Hub timeouts
for attempt in 1 2 3; do
if docker compose -p e2e-0 -f packages/app/tests/e2e/docker-compose.yml pull; then
echo "Docker images pulled successfully on attempt $attempt"
break
fi
if [ "$attempt" -eq 3 ]; then
echo "Failed to pull Docker images after 3 attempts"
exit 1
fi
echo "Docker pull failed (attempt $attempt/3), retrying in 10s..."
sleep 10
done
docker compose -p e2e-0 -f packages/app/tests/e2e/docker-compose.yml up -d
echo "Waiting for MongoDB..."
for i in $(seq 1 30); do
if docker compose -p e2e-0 -f packages/app/tests/e2e/docker-compose.yml exec -T db mongosh --quiet --eval "db.adminCommand({ping:1})" >/dev/null 2>&1; then
echo "MongoDB is ready"
break
fi
if [ "$i" -eq 30 ]; then
echo "MongoDB failed to become ready after 30 seconds"
exit 1
fi
echo "Waiting for MongoDB... ($i/30)"
sleep 1
done
echo "Waiting for ClickHouse..."
for i in $(seq 1 60); do
if curl -sf http://localhost:${HDX_E2E_CH_PORT}/ping >/dev/null 2>&1; then
echo "ClickHouse is ready"
break
fi
if [ "$i" -eq 60 ]; then
echo "ClickHouse failed to become ready after 60 seconds"
exit 1
fi
echo "Waiting for ClickHouse... ($i/60)"
sleep 1
done
- name: E2E setup
uses: ./.github/actions/e2e-setup

- name: Run Playwright tests (full-stack mode)
env:
E2E_FULLSTACK: 'true'
E2E_UNIQUE_USER: 'true'
E2E_API_HEALTH_CHECK_MAX_RETRIES: '60'
MONGO_URI:
mongodb://localhost:${{ env.HDX_E2E_MONGO_PORT }}/hyperdx-e2e
run: |
cd packages/app
yarn test:e2e --shard=${{ matrix.shard }}/4

- name: Upload Playwright report
uses: actions/upload-artifact@v7
if: always()
with:
name: playwright-report-${{ matrix.shard }}
path: packages/app/playwright-report/
retention-days: 30

- name: Upload test results
uses: actions/upload-artifact@v7
- name: E2E teardown
if: always()
uses: ./.github/actions/e2e-teardown
with:
name: test-results-${{ matrix.shard }}
path: packages/app/test-results/
retention-days: 30

- name: Stop E2E containers
if: always()
run:
docker compose -p e2e-0 -f packages/app/tests/e2e/docker-compose.yml
down -v
artifact-suffix: ${{ matrix.shard }}
Loading