780 lines
33 KiB
YAML
780 lines
33 KiB
YAML
name: UI E2E Tests
|
|
permissions:
|
|
contents: read # Required for checkout or repository metadata reads.
|
|
|
|
on:
|
|
workflow_call:
|
|
secrets:
|
|
ANTHROPIC_API_KEY:
|
|
required: false
|
|
AWS_ACCESS_KEY_ID:
|
|
required: true
|
|
AWS_SECRET_ACCESS_KEY:
|
|
required: true
|
|
DOCKERHUB_LIMITED_TOKEN:
|
|
required: true
|
|
FIREWORKS_ACCOUNT_ID:
|
|
required: true
|
|
FIREWORKS_API_KEY:
|
|
required: true
|
|
GCP_JWT_KEY:
|
|
required: true
|
|
OPENAI_API_KEY:
|
|
required: true
|
|
R2_ACCESS_KEY_ID:
|
|
required: true
|
|
R2_SECRET_ACCESS_KEY:
|
|
required: true
|
|
S3_ACCESS_KEY_ID:
|
|
required: true
|
|
S3_SECRET_ACCESS_KEY:
|
|
required: true
|
|
TOGETHER_API_KEY:
|
|
required: false
|
|
inputs:
|
|
is_merge_group:
|
|
required: true
|
|
type: boolean
|
|
|
|
jobs:
|
|
ui-tests-no-network:
|
|
name: ui-tests-no-network
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
if: github.repository == 'tensorzero/tensorzero'
|
|
steps:
|
|
- name: Set DNS
|
|
run: echo "127.0.0.1 howdy.tensorzero.com" | sudo tee -a /etc/hosts
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
persist-credentials: false
|
|
- name: Setup Node
|
|
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
with:
|
|
node-version: "24.13.0"
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
|
|
with:
|
|
username: tensorzero
|
|
password: ${{ secrets.DOCKERHUB_LIMITED_TOKEN }}
|
|
|
|
- name: Pull container images
|
|
run: |
|
|
./ci/docker-pull-with-retry.sh \
|
|
tensorzero/gateway-dev:sha-$GITHUB_SHA \
|
|
tensorzero/ui-dev:sha-$GITHUB_SHA \
|
|
tensorzero/mock-provider-api:sha-$GITHUB_SHA \
|
|
tensorzero/fixtures:sha-$GITHUB_SHA
|
|
docker tag tensorzero/gateway-dev:sha-$GITHUB_SHA tensorzero/gateway:sha-$GITHUB_SHA
|
|
docker tag tensorzero/ui-dev:sha-$GITHUB_SHA tensorzero/ui:sha-$GITHUB_SHA
|
|
|
|
- name: Start docker containers without external network access
|
|
working-directory: ui
|
|
env:
|
|
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
|
|
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
|
run: |
|
|
# Environment variables shared by the gateway and ui containers
|
|
echo "TENSORZERO_GATEWAY_URL=http://gateway:3000" >> fixtures/.env
|
|
echo "TENSORZERO_GATEWAY_TAG=sha-$GITHUB_SHA" >> fixtures/.env
|
|
echo "TENSORZERO_UI_TAG=sha-$GITHUB_SHA" >> fixtures/.env
|
|
echo "TENSORZERO_MOCK_PROVIDER_API_TAG=sha-$GITHUB_SHA" >> fixtures/.env
|
|
echo "TENSORZERO_FIXTURES_TAG=sha-$GITHUB_SHA" >> fixtures/.env
|
|
echo "TENSORZERO_GATEWAY_CONFIG=/app/config/empty.toml" >> fixtures/.env
|
|
|
|
export TENSORZERO_SKIP_LARGE_FIXTURES=1
|
|
docker compose -f fixtures/docker-compose.e2e.yml -f fixtures/docker-compose.ui.yml -f ../ci/internal-network.yml up --no-build -d
|
|
|
|
- name: Print Docker Compose logs
|
|
if: always()
|
|
working-directory: ui
|
|
run: docker compose -f fixtures/docker-compose.e2e.yml -f fixtures/docker-compose.ui.yml logs -t
|
|
|
|
- name: Print container health checks
|
|
if: always()
|
|
working-directory: ui
|
|
run: docker inspect --format "{{json .State.Health }}" $(docker compose -f fixtures/docker-compose.e2e.yml -f fixtures/docker-compose.ui.yml ps -q ui) | jq
|
|
|
|
ui-tests-gateway-prefix:
|
|
name: ui-tests-gateway-prefix
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 45
|
|
steps:
|
|
- name: Set DNS
|
|
run: echo "127.0.0.1 howdy.tensorzero.com" | sudo tee -a /etc/hosts
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
persist-credentials: false
|
|
- name: Setup Node
|
|
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
with:
|
|
node-version: "24.13.0"
|
|
|
|
- name: Setup `pnpm`
|
|
run: |
|
|
for attempt in 1 2 3; do
|
|
if timeout 5m npm install -g pnpm@10.15.0; then
|
|
break
|
|
fi
|
|
if [ $attempt -eq 3 ]; then
|
|
echo "Failed to install pnpm after 3 attempts"
|
|
exit 1
|
|
fi
|
|
sleep $((10 * attempt))
|
|
done
|
|
|
|
- name: Install `pnpm` dependencies
|
|
run: |
|
|
for attempt in 1 2 3; do
|
|
if timeout 5m pnpm install --frozen-lockfile; then
|
|
break
|
|
fi
|
|
if [ $attempt -eq 3 ]; then
|
|
echo "Failed to install pnpm dependencies after 3 attempts"
|
|
exit 1
|
|
fi
|
|
sleep $((10 * attempt))
|
|
done
|
|
|
|
- name: Setup Playwright
|
|
timeout-minutes: 20
|
|
run: |
|
|
for attempt in 1 2 3; do
|
|
# Wait for any background apt operation to finish before each attempt —
|
|
# `--with-deps` shells out to apt-get and otherwise races the dpkg lock.
|
|
./ci/wait-for-dpkg.sh 120
|
|
# Per-attempt timeout so a hung apt fetch is killed and the retry actually fires.
|
|
if timeout 5m pnpm --filter=tensorzero-ui exec playwright install --with-deps chromium; then
|
|
break
|
|
fi
|
|
if [ $attempt -eq 3 ]; then
|
|
echo "Failed to install Playwright after 3 attempts"
|
|
exit 1
|
|
fi
|
|
sleep $((10 * attempt))
|
|
done
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
|
|
with:
|
|
username: tensorzero
|
|
password: ${{ secrets.DOCKERHUB_LIMITED_TOKEN }}
|
|
|
|
- name: Pull container images
|
|
run: |
|
|
./ci/docker-pull-with-retry.sh \
|
|
tensorzero/gateway-dev:sha-$GITHUB_SHA \
|
|
tensorzero/ui-dev:sha-$GITHUB_SHA \
|
|
tensorzero/mock-provider-api:sha-$GITHUB_SHA \
|
|
tensorzero/fixtures:sha-$GITHUB_SHA
|
|
docker tag tensorzero/gateway-dev:sha-$GITHUB_SHA tensorzero/gateway:sha-$GITHUB_SHA
|
|
docker tag tensorzero/ui-dev:sha-$GITHUB_SHA tensorzero/ui:sha-$GITHUB_SHA
|
|
|
|
- name: Start Docker containers and apply fixtures
|
|
working-directory: ui
|
|
env:
|
|
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
|
|
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
|
S3_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
S3_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
# Fall back to HTTP download for fork PRs (secrets unavailable)
|
|
TENSORZERO_DOWNLOAD_FIXTURES_WITHOUT_CREDENTIALS: ${{ github.event.pull_request.head.repo.full_name != github.repository && '1' || '' }}
|
|
run: |
|
|
# We set all of the environment variables for both the gateway and ui containers here
|
|
# The 'ui-tests-e2e' job tests that the UI container starts without some of these variables set,
|
|
echo "FIREWORKS_API_KEY=not_used" >> fixtures/.env
|
|
echo "ANTHROPIC_API_KEY=not_used" >> fixtures/.env
|
|
echo "OPENAI_API_KEY=not_used" >> fixtures/.env
|
|
echo "TENSORZERO_INTERNAL_MOCK_PROVIDER_API=http://mock-provider-api:3030" >> fixtures/.env
|
|
echo "S3_ACCESS_KEY_ID=$S3_ACCESS_KEY_ID" >> fixtures/.env
|
|
echo "S3_SECRET_ACCESS_KEY=$S3_SECRET_ACCESS_KEY" >> fixtures/.env
|
|
echo "TENSORZERO_GATEWAY_URL=http://gateway:3000/custom/prefix" >> fixtures/.env
|
|
echo "TENSORZERO_GATEWAY_CONFIG=/app/config/base-path.toml" >> fixtures/.env
|
|
echo "TENSORZERO_GATEWAY_TAG=sha-$GITHUB_SHA" >> fixtures/.env
|
|
echo "TENSORZERO_UI_TAG=sha-$GITHUB_SHA" >> fixtures/.env
|
|
echo "TENSORZERO_MOCK_PROVIDER_API_TAG=sha-$GITHUB_SHA" >> fixtures/.env
|
|
echo "TENSORZERO_FIXTURES_TAG=sha-$GITHUB_SHA" >> fixtures/.env
|
|
export TENSORZERO_SKIP_LARGE_FIXTURES=1
|
|
docker compose -f fixtures/docker-compose.e2e.yml -f fixtures/docker-compose.ui.yml up --no-build -d
|
|
docker compose -f fixtures/docker-compose.e2e.yml -f fixtures/docker-compose.ui.yml wait fixtures
|
|
|
|
- name: Run UI base-path E2E tests
|
|
id: e2e_tests
|
|
env:
|
|
TENSORZERO_CI: 1
|
|
run: pnpm ui:test:e2e-base-path
|
|
|
|
- name: Print Docker Compose logs
|
|
if: always()
|
|
working-directory: ui
|
|
run: docker compose -f fixtures/docker-compose.e2e.yml -f fixtures/docker-compose.ui.yml logs -t
|
|
|
|
- name: Check for correct base-path in logs
|
|
working-directory: ui
|
|
run: |
|
|
docker compose -f fixtures/docker-compose.e2e.yml -f fixtures/docker-compose.ui.yml logs -t | grep "/custom/prefix"
|
|
|
|
- name: Print ClickHouse error logs
|
|
if: always()
|
|
run: docker exec fixtures-clickhouse-1 cat /var/log/clickhouse-server/clickhouse-server.err.log
|
|
|
|
- name: Print ClickHouse trace logs
|
|
if: always()
|
|
run: docker exec fixtures-clickhouse-1 cat /var/log/clickhouse-server/clickhouse-server.log
|
|
|
|
- name: Upload Playwright artifacts
|
|
if: failure()
|
|
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
|
with:
|
|
name: playwright-report-e2e-base-path
|
|
path: |
|
|
ui/playwright-report/
|
|
ui/test-results/
|
|
retention-days: 7
|
|
|
|
ui-tests-e2e-mock:
|
|
name: ui-tests-e2e-mock
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 60
|
|
# Same conditions as ui-tests-e2e-main
|
|
if: ${{ (github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') || inputs.is_merge_group }}
|
|
steps:
|
|
- name: Check out the repo
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
with:
|
|
node-version: "24.13.0"
|
|
|
|
- name: Setup `pnpm`
|
|
run: |
|
|
for attempt in 1 2 3; do
|
|
if timeout 5m npm install -g pnpm@10.15.0; then
|
|
break
|
|
fi
|
|
if [ $attempt -eq 3 ]; then
|
|
echo "Failed to install pnpm after 3 attempts"
|
|
exit 1
|
|
fi
|
|
sleep $((10 * attempt))
|
|
done
|
|
|
|
- name: Install `pnpm` dependencies
|
|
run: |
|
|
for attempt in 1 2 3; do
|
|
if timeout 5m pnpm install --frozen-lockfile; then
|
|
break
|
|
fi
|
|
if [ $attempt -eq 3 ]; then
|
|
echo "Failed to install pnpm dependencies after 3 attempts"
|
|
exit 1
|
|
fi
|
|
sleep $((10 * attempt))
|
|
done
|
|
|
|
- name: Setup Playwright
|
|
timeout-minutes: 20
|
|
run: |
|
|
for attempt in 1 2 3; do
|
|
# Wait for any background apt operation to finish before each attempt —
|
|
# `--with-deps` shells out to apt-get and otherwise races the dpkg lock.
|
|
./ci/wait-for-dpkg.sh 120
|
|
# Per-attempt timeout so a hung apt fetch is killed and the retry actually fires.
|
|
if timeout 5m pnpm --filter=tensorzero-ui exec playwright install --with-deps chromium; then
|
|
break
|
|
fi
|
|
if [ $attempt -eq 3 ]; then
|
|
echo "Failed to install Playwright after 3 attempts"
|
|
exit 1
|
|
fi
|
|
sleep $((10 * attempt))
|
|
done
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
|
|
with:
|
|
username: tensorzero
|
|
password: ${{ secrets.DOCKERHUB_LIMITED_TOKEN }}
|
|
|
|
- name: Pull container images
|
|
run: |
|
|
./ci/docker-pull-with-retry.sh \
|
|
tensorzero/gateway-dev:sha-$GITHUB_SHA \
|
|
tensorzero/ui-dev:sha-$GITHUB_SHA \
|
|
tensorzero/mock-provider-api:sha-$GITHUB_SHA \
|
|
tensorzero/fixtures:sha-$GITHUB_SHA
|
|
docker tag tensorzero/gateway-dev:sha-$GITHUB_SHA tensorzero/gateway:sha-$GITHUB_SHA
|
|
docker tag tensorzero/ui-dev:sha-$GITHUB_SHA tensorzero/ui:sha-$GITHUB_SHA
|
|
|
|
- name: Set common fixture environment variables
|
|
working-directory: ui
|
|
env:
|
|
S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
|
|
S3_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
|
|
run: |
|
|
# Environment variables shared by the gateway and ui containers
|
|
echo "TENSORZERO_CLICKHOUSE_URL=http://chuser:chpassword@clickhouse:8123/tensorzero_ui_fixtures" >> fixtures/.env
|
|
echo "TENSORZERO_GATEWAY_URL=http://gateway:3000" >> fixtures/.env
|
|
echo "TENSORZERO_GATEWAY_TAG=sha-$GITHUB_SHA" >> fixtures/.env
|
|
echo "TENSORZERO_UI_TAG=sha-$GITHUB_SHA" >> fixtures/.env
|
|
echo "TENSORZERO_MOCK_PROVIDER_API_TAG=sha-$GITHUB_SHA" >> fixtures/.env
|
|
echo "TENSORZERO_FIXTURES_TAG=sha-$GITHUB_SHA" >> fixtures/.env
|
|
echo "TENSORZERO_INTERNAL_MOCK_PROVIDER_API=http://mock-provider-api:3030" >> fixtures/.env
|
|
# S3 credentials are required - gateway validates object store at startup
|
|
echo "S3_ACCESS_KEY_ID=$S3_ACCESS_KEY_ID" >> fixtures/.env
|
|
echo "S3_SECRET_ACCESS_KEY=$S3_SECRET_ACCESS_KEY" >> fixtures/.env
|
|
# Dummy values - not used since mock server handles requests
|
|
echo "ANTHROPIC_API_KEY=not_used" >> fixtures/.env-gateway
|
|
echo "FIREWORKS_API_KEY=not_used" >> fixtures/.env-gateway
|
|
echo "OPENAI_API_KEY=not_used" >> fixtures/.env-gateway
|
|
echo "TOGETHER_API_KEY=not_used" >> fixtures/.env-gateway
|
|
|
|
- name: Start docker containers
|
|
env:
|
|
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
|
|
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
|
run: |
|
|
export TENSORZERO_SKIP_LARGE_FIXTURES=1
|
|
docker compose -f ui/fixtures/docker-compose.e2e.yml -f ui/fixtures/docker-compose.ui.yml up --no-build -d
|
|
docker compose -f ui/fixtures/docker-compose.e2e.yml -f ui/fixtures/docker-compose.ui.yml wait fixtures
|
|
|
|
- name: Run UI E2E tests that use the mock server
|
|
id: e2e_tests_mock
|
|
env:
|
|
TENSORZERO_CI: 1
|
|
TENSORZERO_CLICKHOUSE_URL: "http://chuser:chpassword@localhost:8123/tensorzero_ui_fixtures"
|
|
TENSORZERO_GATEWAY_URL: "http://gateway:3000"
|
|
run: pnpm ui:test:e2e --grep "@mock"
|
|
|
|
- name: Print docker compose logs
|
|
if: always()
|
|
run: |
|
|
docker compose -f ui/fixtures/docker-compose.e2e.yml -f ui/fixtures/docker-compose.ui.yml logs -t
|
|
|
|
- name: Upload Playwright artifacts
|
|
if: failure()
|
|
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
|
with:
|
|
name: playwright-report-e2e-mock
|
|
path: |
|
|
ui/playwright-report/
|
|
ui/test-results/
|
|
retention-days: 7
|
|
|
|
# Main E2E test job - uses provider-proxy for HTTP-level caching of provider API calls.
|
|
# Replaces the previous ui-tests-e2e-credentials and ui-tests-e2e-existing-model-inference-cache jobs.
|
|
ui-tests-e2e-main:
|
|
name: ui-tests-e2e-main (${{ matrix.auth_mode }})
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 60
|
|
if: ${{ github.repository == 'tensorzero/tensorzero' && ((github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') || inputs.is_merge_group) }}
|
|
|
|
strategy:
|
|
matrix:
|
|
auth_mode: ${{ fromJSON('["no_gateway_auth", "gateway_auth_with_ui_server_key", "gateway_auth_with_browser_key"]') }}
|
|
|
|
steps:
|
|
- name: Check out the repo
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Cleanup disk space
|
|
run: bash ci/free-disk-space.sh
|
|
|
|
- name: Setup GCP credentials
|
|
env:
|
|
GCP_JWT_KEY: ${{ secrets.GCP_JWT_KEY }}
|
|
run: echo "$GCP_JWT_KEY" > $GITHUB_WORKSPACE/gcp_jwt_key.json
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
with:
|
|
node-version: "24.13.0"
|
|
|
|
- name: Setup `pnpm`
|
|
run: |
|
|
for attempt in 1 2 3; do
|
|
if timeout 5m npm install -g pnpm@10.15.0; then
|
|
break
|
|
fi
|
|
if [ $attempt -eq 3 ]; then
|
|
echo "Failed to install pnpm after 3 attempts"
|
|
exit 1
|
|
fi
|
|
sleep $((10 * attempt))
|
|
done
|
|
|
|
- name: Install `pnpm` dependencies
|
|
run: |
|
|
for attempt in 1 2 3; do
|
|
if timeout 5m pnpm install --frozen-lockfile; then
|
|
break
|
|
fi
|
|
if [ $attempt -eq 3 ]; then
|
|
echo "Failed to install pnpm dependencies after 3 attempts"
|
|
exit 1
|
|
fi
|
|
sleep $((10 * attempt))
|
|
done
|
|
|
|
- name: Setup Playwright
|
|
timeout-minutes: 20
|
|
run: |
|
|
for attempt in 1 2 3; do
|
|
# Wait for any background apt operation to finish before each attempt —
|
|
# `--with-deps` shells out to apt-get and otherwise races the dpkg lock.
|
|
./ci/wait-for-dpkg.sh 120
|
|
# Per-attempt timeout so a hung apt fetch is killed and the retry actually fires.
|
|
if timeout 5m pnpm --filter=tensorzero-ui exec playwright install --with-deps chromium; then
|
|
break
|
|
fi
|
|
if [ $attempt -eq 3 ]; then
|
|
echo "Failed to install Playwright after 3 attempts"
|
|
exit 1
|
|
fi
|
|
sleep $((10 * attempt))
|
|
done
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
|
|
with:
|
|
username: tensorzero
|
|
password: ${{ secrets.DOCKERHUB_LIMITED_TOKEN }}
|
|
|
|
- name: Pull container images
|
|
run: |
|
|
./ci/docker-pull-with-retry.sh \
|
|
tensorzero/gateway-dev:sha-$GITHUB_SHA \
|
|
tensorzero/gateway-e2e:sha-$GITHUB_SHA \
|
|
tensorzero/ui-dev:sha-$GITHUB_SHA \
|
|
tensorzero/mock-provider-api:sha-$GITHUB_SHA \
|
|
tensorzero/provider-proxy:sha-$GITHUB_SHA \
|
|
tensorzero/fixtures:sha-$GITHUB_SHA
|
|
docker tag tensorzero/gateway-dev:sha-$GITHUB_SHA tensorzero/gateway:sha-$GITHUB_SHA
|
|
docker tag tensorzero/ui-dev:sha-$GITHUB_SHA tensorzero/ui:sha-$GITHUB_SHA
|
|
|
|
- name: Download provider-proxy cache from R2
|
|
env:
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
|
PROVIDER_PROXY_CACHE_BUCKET: provider-proxy-cache-ui
|
|
PROVIDER_PROXY_CACHE_DIR: provider-proxy-cache-ui
|
|
run: ./ci/download-provider-proxy-cache.sh
|
|
continue-on-error: true
|
|
|
|
- name: Set common fixture environment variables
|
|
working-directory: ui
|
|
env:
|
|
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY || 'not_used' }}
|
|
FIREWORKS_ACCOUNT_ID: ${{ secrets.FIREWORKS_ACCOUNT_ID }}
|
|
FIREWORKS_API_KEY: ${{ secrets.FIREWORKS_API_KEY }}
|
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
|
S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
|
|
S3_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
|
|
TOGETHER_API_KEY: ${{ secrets.TOGETHER_API_KEY || 'not_used' }}
|
|
run: |
|
|
# Environment variables shared by the gateway and ui containers
|
|
echo "TENSORZERO_GATEWAY_URL=http://gateway:3000" >> fixtures/.env
|
|
echo "TENSORZERO_GATEWAY_TAG=sha-$GITHUB_SHA" >> fixtures/.env
|
|
echo "TENSORZERO_GATEWAY_E2E_TAG=sha-$GITHUB_SHA" >> fixtures/.env
|
|
echo "TENSORZERO_UI_TAG=sha-$GITHUB_SHA" >> fixtures/.env
|
|
echo "TENSORZERO_MOCK_PROVIDER_API_TAG=sha-$GITHUB_SHA" >> fixtures/.env
|
|
echo "TENSORZERO_PROVIDER_PROXY_TAG=sha-$GITHUB_SHA" >> fixtures/.env
|
|
echo "TENSORZERO_FIXTURES_TAG=sha-$GITHUB_SHA" >> fixtures/.env
|
|
echo "S3_ACCESS_KEY_ID=$S3_ACCESS_KEY_ID" >> fixtures/.env
|
|
echo "S3_SECRET_ACCESS_KEY=$S3_SECRET_ACCESS_KEY" >> fixtures/.env
|
|
# Real API keys for cache misses (forwarded through provider-proxy to real providers)
|
|
echo "FIREWORKS_ACCOUNT_ID=$FIREWORKS_ACCOUNT_ID" >> fixtures/.env-gateway
|
|
echo "FIREWORKS_API_KEY=$FIREWORKS_API_KEY" >> fixtures/.env-gateway
|
|
echo "OPENAI_API_KEY=$OPENAI_API_KEY" >> fixtures/.env-gateway
|
|
echo "ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY" >> fixtures/.env-gateway
|
|
echo "TOGETHER_API_KEY=$TOGETHER_API_KEY" >> fixtures/.env-gateway
|
|
|
|
- name: Enable gateway authentication in config
|
|
if: matrix.auth_mode != 'no_gateway_auth'
|
|
working-directory: ui
|
|
run: |
|
|
sed -i '3a\\n[gateway.auth]\nenabled = true' fixtures/config/tensorzero.toml
|
|
|
|
- name: Generate gateway API key and configure for auth mode
|
|
if: matrix.auth_mode != 'no_gateway_auth'
|
|
working-directory: ui
|
|
run: |
|
|
echo "Starting postgres..."
|
|
docker compose -f fixtures/docker-compose.e2e.yml up postgres -d
|
|
|
|
echo "Waiting for postgres to be healthy (timeout: 2 minutes)..."
|
|
timeout 120 bash -c '
|
|
while true; do
|
|
STATUS=$(docker compose -f fixtures/docker-compose.e2e.yml ps postgres --format json | jq -r "if type == \"array\" then .[0].Health else .Health end")
|
|
echo "Postgres health status: $STATUS"
|
|
if [ "$STATUS" = "healthy" ]; then
|
|
echo "Postgres is healthy!"
|
|
break
|
|
fi
|
|
sleep 2
|
|
done
|
|
' || {
|
|
echo "ERROR: Timeout waiting for postgres to become healthy"
|
|
docker compose -f fixtures/docker-compose.e2e.yml ps postgres
|
|
docker compose -f fixtures/docker-compose.e2e.yml logs postgres
|
|
exit 1
|
|
}
|
|
|
|
echo "Running gateway postgres migrations..."
|
|
docker run --rm \
|
|
--network fixtures_default \
|
|
-e TENSORZERO_POSTGRES_URL="postgres://postgres:postgres@postgres:5432/tensorzero_ui_fixtures" \
|
|
tensorzero/gateway-e2e:sha-$GITHUB_SHA \
|
|
--run-postgres-migrations
|
|
|
|
echo "Generating API key..."
|
|
API_KEY=$(docker run --rm \
|
|
--network fixtures_default \
|
|
-e TENSORZERO_POSTGRES_URL="postgres://postgres:postgres@postgres:5432/tensorzero_ui_fixtures" \
|
|
tensorzero/gateway-e2e:sha-$GITHUB_SHA \
|
|
--create-api-key)
|
|
|
|
if [ "${MATRIX_AUTH_MODE}" = "gateway_auth_with_ui_server_key" ]; then
|
|
# Server key mode: UI server uses this key to authenticate all requests to the gateway
|
|
echo "TENSORZERO_API_KEY=$API_KEY" >> fixtures/.env
|
|
# Also expose to Playwright for tests that make direct gateway API calls
|
|
echo "TENSORZERO_API_KEY=$API_KEY" >> "$GITHUB_ENV"
|
|
elif [ "${MATRIX_AUTH_MODE}" = "gateway_auth_with_browser_key" ]; then
|
|
# Browser key mode: pass to test runner so e2e tests can submit it via the browser auth endpoint
|
|
echo "TENSORZERO_API_KEY_FOR_BROWSER_AUTH=$API_KEY" >> "$GITHUB_ENV"
|
|
fi
|
|
env:
|
|
MATRIX_AUTH_MODE: ${{ matrix.auth_mode }}
|
|
|
|
# Free up disk space from multi-stage builder images
|
|
- name: Prune docker images to free up disk space
|
|
run: docker system prune -f
|
|
|
|
- name: Start docker containers and apply fixtures
|
|
working-directory: ui
|
|
env:
|
|
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
|
|
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
|
run: |
|
|
export TENSORZERO_SKIP_LARGE_FIXTURES=1
|
|
DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) docker compose -f fixtures/docker-compose.e2e.yml -f fixtures/docker-compose.ui.yml -f fixtures/docker-compose.proxy.yml up --no-build -d
|
|
docker compose -f fixtures/docker-compose.e2e.yml -f fixtures/docker-compose.ui.yml -f fixtures/docker-compose.proxy.yml wait fixtures
|
|
|
|
- name: Run UI E2E tests
|
|
id: e2e_tests
|
|
env:
|
|
TENSORZERO_CI: 1
|
|
TENSORZERO_POSTGRES_URL: "postgres://postgres:postgres@localhost:5432/tensorzero_ui_fixtures"
|
|
TENSORZERO_GATEWAY_URL: "http://gateway:3000"
|
|
MATRIX_AUTH_MODE: ${{ matrix.auth_mode }}
|
|
run: |
|
|
case "${MATRIX_AUTH_MODE}" in
|
|
no_gateway_auth)
|
|
# Skip all auth-specific tests - gateway has no authentication
|
|
pnpm ui:test:e2e --grep-invert "@mock|@gateway-auth-with-ui-server-key|@gateway-auth-with-browser-key|@config-editing" -j 4
|
|
;;
|
|
gateway_auth_with_ui_server_key)
|
|
# Run all tests except mock, browser-key, and config-editing - UI server has the API key,
|
|
# so @gateway-auth-with-ui-server-key tests (409 rejection) are included
|
|
pnpm ui:test:e2e --grep-invert "@mock|@gateway-auth-with-browser-key|@config-editing" -j 4
|
|
;;
|
|
gateway_auth_with_browser_key)
|
|
# Run ONLY browser key tests - gateway has auth but UI server has no API key,
|
|
# so tests submit the key via the browser auth endpoint
|
|
pnpm ui:test:e2e --grep "@gateway-auth-with-browser-key" -j 4
|
|
;;
|
|
esac
|
|
|
|
- name: Upload provider-proxy cache to R2
|
|
if: ${{ always() && (inputs.is_merge_group || github.event_name == 'schedule') }}
|
|
env:
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
|
PROVIDER_PROXY_CACHE_BUCKET: provider-proxy-cache-ui
|
|
PROVIDER_PROXY_CACHE_DIR: provider-proxy-cache-ui
|
|
run: ./ci/upload-provider-proxy-cache.sh
|
|
|
|
- name: Print Docker Compose logs
|
|
if: always()
|
|
working-directory: ui
|
|
run: docker compose -f fixtures/docker-compose.e2e.yml -f fixtures/docker-compose.ui.yml -f fixtures/docker-compose.proxy.yml logs -t
|
|
|
|
- name: Print container health checks
|
|
if: always()
|
|
working-directory: ui
|
|
run: docker inspect --format "{{json .State.Health }}" $(docker compose -f fixtures/docker-compose.e2e.yml -f fixtures/docker-compose.ui.yml -f fixtures/docker-compose.proxy.yml ps -q ui) | jq
|
|
|
|
- name: Print ClickHouse error logs
|
|
if: always()
|
|
run: docker exec fixtures-clickhouse-1 cat /var/log/clickhouse-server/clickhouse-server.err.log
|
|
|
|
- name: Print ClickHouse trace logs
|
|
if: always()
|
|
run: docker exec fixtures-clickhouse-1 cat /var/log/clickhouse-server/clickhouse-server.log
|
|
|
|
- name: Upload Playwright artifacts
|
|
if: failure()
|
|
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
|
with:
|
|
name: playwright-report-e2e-main-${{ matrix.auth_mode }}
|
|
path: |
|
|
ui/playwright-report/
|
|
ui/test-results/
|
|
retention-days: 7
|
|
|
|
# Runs @config-editing playwright tests against a gateway booted from the
|
|
# config-in-database path. These tests mutate gateway-wide config state via
|
|
# /internal/config_toml/apply, so they need TENSORZERO_INTERNAL_FLAG_ENABLE_CONFIG_IN_DATABASE
|
|
# and a pre-loaded config — they cannot run in the main e2e job.
|
|
ui-tests-e2e-config-editing:
|
|
name: ui-tests-e2e-config-editing
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 45
|
|
if: ${{ github.repository == 'tensorzero/tensorzero' && ((github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') || inputs.is_merge_group) }}
|
|
steps:
|
|
- name: Check out the repo
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
with:
|
|
node-version: "24.13.0"
|
|
|
|
- name: Setup `pnpm`
|
|
run: |
|
|
for attempt in 1 2 3; do
|
|
if timeout 5m npm install -g pnpm@10.15.0; then
|
|
break
|
|
fi
|
|
if [ $attempt -eq 3 ]; then
|
|
echo "Failed to install pnpm after 3 attempts"
|
|
exit 1
|
|
fi
|
|
sleep $((10 * attempt))
|
|
done
|
|
|
|
- name: Install `pnpm` dependencies
|
|
run: |
|
|
for attempt in 1 2 3; do
|
|
if timeout 5m pnpm install --frozen-lockfile; then
|
|
break
|
|
fi
|
|
if [ $attempt -eq 3 ]; then
|
|
echo "Failed to install pnpm dependencies after 3 attempts"
|
|
exit 1
|
|
fi
|
|
sleep $((10 * attempt))
|
|
done
|
|
|
|
- name: Setup Playwright
|
|
timeout-minutes: 20
|
|
run: |
|
|
for attempt in 1 2 3; do
|
|
# Wait for any background apt operation to finish before each attempt —
|
|
# `--with-deps` shells out to apt-get and otherwise races the dpkg lock.
|
|
./ci/wait-for-dpkg.sh 120
|
|
# Per-attempt timeout so a hung apt fetch is killed and the retry actually fires.
|
|
if timeout 5m pnpm --filter=tensorzero-ui exec playwright install --with-deps chromium; then
|
|
break
|
|
fi
|
|
if [ $attempt -eq 3 ]; then
|
|
echo "Failed to install Playwright after 3 attempts"
|
|
exit 1
|
|
fi
|
|
sleep $((10 * attempt))
|
|
done
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
|
|
with:
|
|
username: tensorzero
|
|
password: ${{ secrets.DOCKERHUB_LIMITED_TOKEN }}
|
|
|
|
- name: Pull container images
|
|
run: |
|
|
./ci/docker-pull-with-retry.sh \
|
|
tensorzero/gateway-dev:sha-$GITHUB_SHA \
|
|
tensorzero/gateway-e2e:sha-$GITHUB_SHA \
|
|
tensorzero/ui-dev:sha-$GITHUB_SHA \
|
|
tensorzero/mock-provider-api:sha-$GITHUB_SHA \
|
|
tensorzero/fixtures:sha-$GITHUB_SHA
|
|
docker tag tensorzero/gateway-dev:sha-$GITHUB_SHA tensorzero/gateway:sha-$GITHUB_SHA
|
|
docker tag tensorzero/ui-dev:sha-$GITHUB_SHA tensorzero/ui:sha-$GITHUB_SHA
|
|
|
|
- name: Set common fixture environment variables
|
|
working-directory: ui
|
|
env:
|
|
S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
|
|
S3_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
|
|
run: |
|
|
echo "TENSORZERO_GATEWAY_URL=http://gateway:3000" >> fixtures/.env
|
|
echo "TENSORZERO_GATEWAY_TAG=sha-$GITHUB_SHA" >> fixtures/.env
|
|
echo "TENSORZERO_GATEWAY_E2E_TAG=sha-$GITHUB_SHA" >> fixtures/.env
|
|
echo "TENSORZERO_UI_TAG=sha-$GITHUB_SHA" >> fixtures/.env
|
|
echo "TENSORZERO_MOCK_PROVIDER_API_TAG=sha-$GITHUB_SHA" >> fixtures/.env
|
|
echo "TENSORZERO_FIXTURES_TAG=sha-$GITHUB_SHA" >> fixtures/.env
|
|
echo "TENSORZERO_INTERNAL_MOCK_PROVIDER_API=http://mock-provider-api:3030" >> fixtures/.env
|
|
echo "S3_ACCESS_KEY_ID=$S3_ACCESS_KEY_ID" >> fixtures/.env
|
|
echo "S3_SECRET_ACCESS_KEY=$S3_SECRET_ACCESS_KEY" >> fixtures/.env
|
|
# Dummy values — config editing tests do not make real inference calls
|
|
echo "ANTHROPIC_API_KEY=not_used" >> fixtures/.env-gateway
|
|
echo "FIREWORKS_API_KEY=not_used" >> fixtures/.env-gateway
|
|
echo "OPENAI_API_KEY=not_used" >> fixtures/.env-gateway
|
|
echo "TOGETHER_API_KEY=not_used" >> fixtures/.env-gateway
|
|
|
|
- name: Start docker containers and apply fixtures
|
|
working-directory: ui
|
|
env:
|
|
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
|
|
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
|
run: |
|
|
export TENSORZERO_SKIP_LARGE_FIXTURES=1
|
|
docker compose \
|
|
-f fixtures/docker-compose.e2e.yml \
|
|
-f fixtures/docker-compose.ui.yml \
|
|
-f fixtures/docker-compose.config-in-db.yml \
|
|
up --no-build -d
|
|
docker compose \
|
|
-f fixtures/docker-compose.e2e.yml \
|
|
-f fixtures/docker-compose.ui.yml \
|
|
-f fixtures/docker-compose.config-in-db.yml \
|
|
wait fixtures
|
|
|
|
- name: Run config-editing E2E tests
|
|
id: e2e_tests_config_editing
|
|
env:
|
|
TENSORZERO_CI: 1
|
|
# Playwright runs on the host; gateway port 3000 is mapped to localhost.
|
|
# Using http://gateway:3000 here would fail with EAI_AGAIN because the
|
|
# `gateway` hostname is only resolvable within the Docker network.
|
|
TENSORZERO_GATEWAY_URL: "http://localhost:3000"
|
|
run: pnpm ui:test:e2e --grep "@config-editing" --workers=1
|
|
|
|
- name: Print docker compose logs
|
|
if: always()
|
|
working-directory: ui
|
|
run: |
|
|
docker compose \
|
|
-f fixtures/docker-compose.e2e.yml \
|
|
-f fixtures/docker-compose.ui.yml \
|
|
-f fixtures/docker-compose.config-in-db.yml \
|
|
logs -t
|
|
|
|
- name: Upload Playwright artifacts
|
|
if: failure()
|
|
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
|
with:
|
|
name: playwright-report-e2e-config-editing
|
|
path: |
|
|
ui/playwright-report/
|
|
ui/test-results/
|
|
retention-days: 7
|