Files
Ali Waseem 99fd573d1a feat(kb): add unit test CI, search API tests, and Playwright smoke tests (#52151)
kb's unit tests weren't run in CI and there were no functional tests.
Adds a CI job for kb unit tests, unit tests for the search API, and a
bare-bones Playwright suite (`e2e/kb`) that runs against the kb Vercel
preview on PRs and against production daily.

Fixes DOCS-1506
2026-10-22 09:14:16 -06:00

129 lines
4.2 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: KB E2E Tests
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches: ['master']
paths:
- 'apps/kb/**'
- 'e2e/kb/**'
- '.github/workflows/kb-e2e.yml'
# Daily smoke test against production
schedule:
- cron: '0 4 * * *'
workflow_dispatch:
inputs:
base_url:
description: 'Base URL to test against'
required: false
default: 'https://supabase.com'
type: string
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
statuses: read
pull-requests: read
env:
CI: true
jobs:
e2e:
name: KB E2E
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
timeout-minutes: 30
runs-on: blacksmith-4vcpu-ubuntu-2404
steps:
- name: Detect changed paths
id: changes
if: github.event_name == 'pull_request'
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
with:
filters: |
kb_app:
- 'apps/kb/**'
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
sparse-checkout: |
e2e/kb
scripts
patches
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
name: Install pnpm
with:
run_install: false
- name: Use Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
# Vercel skips the kb preview when a PR only changes the harness, so wait
# for a preview only when apps/kb changed. See scripts/waitForVercelPreview.js.
- name: Wait for Vercel kb preview
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && steps.changes.outputs.kb_app == 'true'
id: deployment
continue-on-error: true
background: true
run: node scripts/waitForVercelPreview.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PR_NUMBER: ${{ github.event.pull_request.number }}
VERCEL_STATUS_CONTEXT: 'Vercel – kb'
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }}
- name: Install dependencies
run: pnpm install --frozen-lockfile --filter=e2e-kb...
- name: Install Playwright Chromium
run: pnpm -C e2e/kb exec playwright install chromium --with-deps --only-shell
- name: Wait for Vercel kb preview to finish
wait: [deployment]
# Harness-only PRs, scheduled and manual runs test production (or base_url). When
# apps/kb changed but no preview resolved, skip rather than test
# production, which doesn't have this PR's changes.
- name: Resolve base URL
id: base-url
env:
BASE_URL_INPUT: ${{ inputs.base_url }}
KB_APP_CHANGED: ${{ steps.changes.outputs.kb_app }}
DEPLOYMENT_URL: ${{ steps.deployment.outputs.deployment-url }}
run: |
if [ -n "$DEPLOYMENT_URL" ]; then
printf 'url=%s\n' "$DEPLOYMENT_URL" >> "$GITHUB_OUTPUT"
elif [ "$KB_APP_CHANGED" = "true" ]; then
echo "::warning::No Vercel kb preview URL for this pull request. Skipping Playwright."
else
printf 'url=%s\n' "${BASE_URL_INPUT:-https://supabase.com}" >> "$GITHUB_OUTPUT"
fi
- name: Run kb E2E
if: steps.base-url.outputs.url != ''
working-directory: e2e/kb
run: pnpm run e2e:kb
env:
PLAYWRIGHT_BASE_URL: ${{ steps.base-url.outputs.url }}
- name: Upload Playwright report
if: failure()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: kb-playwright-report
path: |
e2e/kb/playwright-report/
e2e/kb/test-results/
retention-days: 7