Files
supabase/.github/workflows/studio-e2e-test.yml
Alaister YoungandAlaister Young 0c97b9789b [FE-3107] chore(studio): remove remaining Next.js references (#54426)
Removes the remaining Next.js dependencies, compatibility shims, test
mocks, ESLint/TypeScript presets, and webpack/Next workarounds from
Studio following the TanStack Start migration.

Addresses FE-3107.

**Removed:**

- `next` and `next-router-mock` from `apps/studio/package.json` (and
updated `pnpm-lock.yaml`)
- Orphaned `apps/studio/compat/next/script.tsx` shim, `script.test.tsx`,
`compat/**` knip entry, and `nextCompat()` / `ssr.noExternal` `/^next/`
plumbing from `apps/studio/vite.config.ts`
- `apps/studio/tests/lib/route-mock.ts` and all `next-router-mock`
setup/imports across `tests/vitestSetup.ts`,
`tests/lib/custom-render.tsx`, and 12 test files
- `apps/studio/tests/pages/` directory (moved the 3 remaining tests to
`components/interfaces/Organization/Organization.utils.test.ts` and
`apps/studio/tests/routes/`)
- Unused `'use client'` directives across 23 Studio files
- Next.js/webpack workarounds: `graphiqlViteWorkers()` in
`vite.config.ts`, webpack `import.meta.glob` `try/catch` fallback in
`ConnectStepsSection.tsx`, shell `NODE_ENV=test` override in
`vite.config.ts` / root `package.json` / `studio-e2e-test.yml`, Next
`getPathMatch` and `_next` passthrough in `redirects.shared.*`,
`window.next?.router` check in `monaco-graphiql-coexistence.spec.ts`,
and unused `ANALYZE` env var in `apps/studio/turbo.jsonc`
- Next-only Sentry/chunk-load filters (`NEXT_NOT_FOUND`,
`NEXT_REDIRECT`, Next `/org/[slug]/` regex, `/app:\/\//`, dead
`includeThirdPartyErrorFilter` plumbing, webpack chunk error regex) and
stale Next/Pages Router comments, docs, and `#__next` CSS selector

**Changed:**

- `apps/studio/eslint.config.cjs`: switched from
`eslint-config-supabase/next` to the new `eslint-config-supabase/react`
preset (dropping `@next/next/no-img-element: off`, keeping `.next` /
`next-env.d.ts` ignored for local checkouts with stale pre-migration
build artifacts)
- `apps/studio/tsconfig.json`: extends `tsconfig/base.json` directly
instead of `tsconfig/nextjs.json` (identical resolved compiler options)
- `apps/studio/.github/eslint-rule-baselines.json`: pruned 33 stale
`pages/...` and `types/next.ts` entries without changing any rule
thresholds
- `apps/studio/tests/lib/custom-render.tsx`: backed
`TestFrameworkProvider` with TanStack Router instead of
`next-router-mock`
-
`apps/studio/components/interfaces/Integrations/GraphQL/GraphiQLTab.tsx`:
imports `graphiql/setup-workers/vite` directly
- `apps/studio/styles/globals.css`: replaced `@source
'../pages/**/*.{js,ts,jsx,tsx}'` with `@source
'../routes/**/*.{js,ts,jsx,tsx}'`
- `apps/studio/turbo.jsonc`: declared `"NEXT_PUBLIC_*"` in
`tasks.build.env` now that Turborepo infers `nitro` instead of `nextjs`
-
`apps/studio/components/interfaces/Organization/Organization.utils.ts`:
narrowed `buildOrgUrl`'s `slug` parameter to `string[] | undefined`

**Added:**

- `packages/eslint-config-supabase/shared.js` and
`packages/eslint-config-supabase/react.js` (plus `presets.test.ts`),
decoupling non-Next React apps from `eslint-config-next` with verified
zero non-`@next/*` rule drift while keeping
`eslint-config-supabase/next` unchanged for the Next.js apps

## To test

- Run `pnpm --filter eslint-config-supabase run test` and confirm preset
parity tests pass
- Run `pnpm --filter studio run lint`, `pnpm --filter studio run
lint:ratchet`, `pnpm --filter studio run typecheck`, `pnpm knip
--workspace apps/studio`, and `pnpm --filter studio run test`
- Run `pnpm --filter studio run build` and verify the production build,
prerendered routes, chunk-cycle check, and GraphiQL web workers succeed
- Smoke-test Studio locally (`pnpm dev:studio`): verify GraphiQL loads
cleanly, ConnectSheet framework steps render, and Tailwind styles on
route pages are intact

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-12-02 17:01:50 +08:00

227 lines
8.8 KiB
YAML

name: Selfhosted Studio E2E Tests
on:
push:
branches: [master]
pull_request:
# Cancel old builds on new commit for same workflow + branch/PR
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
test:
name: 'E2E tests'
timeout-minutes: 60
runs-on: blacksmith-8vcpu-ubuntu-2404
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2]
shardTotal: [2]
outputs:
tests_ran: ${{ steps.filter.outputs.studio == 'true' }}
permissions:
contents: read
id-token: write
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
# On push events paths-filter diffs against github.event.before with
# local git; without enough history it falls back to a git fetch that
# fails unauthenticated (persist-credentials is false).
fetch-depth: 50
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
with:
filters: |
studio:
- 'packages/pg-meta/**'
- 'packages/ui/**'
- 'packages/ui-patterns/**'
- 'apps/studio/**'
- 'apps/ui-library/**'
- 'apps/design-system/**'
- 'e2e/studio/**'
- 'pnpm-lock.yaml'
- '.github/workflows/studio-e2e-test.yml'
# NOTE: Ports in e2e/studio/supabase/config.toml overlap the ephemeral range.
# Reserve them before dependency installs and image pulls.
- name: Reserve Supabase local ports from the ephemeral range
if: steps.filter.outputs.studio == 'true'
run: current=$(cat /proc/sys/net/ipv4/ip_local_reserved_ports); sudo sysctl -w net.ipv4.ip_local_reserved_ports="${current:+$current,}54320-54329"
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
if: steps.filter.outputs.studio == 'true'
name: Install pnpm
with:
run_install: false
- name: Use Node.js
if: steps.filter.outputs.studio == 'true'
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
- name: Install dependencies
if: steps.filter.outputs.studio == 'true'
run: pnpm install --frozen-lockfile
# Chromium install, `supabase start` and the Studio build don't depend on
# each other, so run them side by side and wait before the tests.
- name: Install Playwright Browsers
if: steps.filter.outputs.studio == 'true'
id: playwright-install
background: true
run: pnpm -C e2e/studio exec playwright install chromium --with-deps --only-shell
# Authenticate with AWS ECR to avoid rate limiting
- name: configure aws credentials
if: steps.filter.outputs.studio == 'true' && !github.event.pull_request.head.repo.fork
uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355 # v2.2.0
with:
role-to-assume: ${{ secrets.PROD_AWS_ROLE }}
aws-region: us-east-1
- uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4.4.0
if: steps.filter.outputs.studio == 'true' && !github.event.pull_request.head.repo.fork
with:
registry: public.ecr.aws
- name: Pre-start diagnostics
run: |
docker ps -a
echo "ip_local_reserved_ports=$(cat /proc/sys/net/ipv4/ip_local_reserved_ports)"
echo "ip_local_port_range=$(cat /proc/sys/net/ipv4/ip_local_port_range)"
sudo ss -tanp '( sport >= :54320 and sport <= :54329 )' || true
- name: Start supabase
if: steps.filter.outputs.studio == 'true'
id: supabase
background: true
run: |
pnpm exec supabase stop --all --no-backup --workdir ./e2e/studio || true
if ! pnpm exec supabase start --exclude studio,mailpit --workdir ./e2e/studio; then
sudo ss -tanp '( sport >= :54320 and sport <= :54329 )' || true
exit 1
fi
- name: Build studio
if: steps.filter.outputs.studio == 'true'
# The build runs before `supabase status` can report keys. It only
# inlines NEXT_PUBLIC_* vars, and the only one derived from status is
# the API URL, fixed by e2e/studio/supabase/config.toml. So build
# against that URL and check it against the real value once supabase is up.
#
# `MODE=test` so the Vite build loads `.env.test` for env resolution
# while Vite keeps `NODE_ENV=production` for the bundle.
run: |
echo '{"API_URL":"http://127.0.0.1:54321"}' > keys.json
node scripts/generateLocalEnv.js
grep '^NEXT_PUBLIC_' apps/studio/.env.test | sort > "$RUNNER_TEMP/build-public-env"
SKIP_ASSET_UPLOAD=1 MODE=test NODE_OPTIONS="--max-old-space-size=4096" pnpm run build:studio
- name: Wait for supabase and Playwright browsers
wait: [supabase, playwright-install]
- name: Failure diagnostics
if: failure()
run: |
docker ps -a
sudo ss -tanp '( sport >= :54320 and sport <= :54329 )' || true
for id in $(docker ps -aq); do
echo "::group::$(docker inspect -f '{{.Name}}' "$id")"
docker logs --tail 300 "$id" 2>&1 || true
echo "::endgroup::"
done
- name: Write runtime env
if: steps.filter.outputs.studio == 'true'
run: |
pnpm exec supabase status --output json --workdir ./e2e/studio > keys.json
node scripts/generateLocalEnv.js
# Fail if the build inlined NEXT_PUBLIC_* values that differ from the real ones.
diff "$RUNNER_TEMP/build-public-env" <(grep '^NEXT_PUBLIC_' apps/studio/.env.test | sort)
- name: 🚀 Run Playwright tests against local studio build
if: steps.filter.outputs.studio == 'true'
id: playwright
run: PWTEST_SHARD_WEIGHTS=62:38 pnpm e2e --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- name: Upload blob report to GitHub Actions Artifacts
if: always() && steps.filter.outputs.studio == 'true'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: blob-report-${{ matrix.shardIndex }}
path: e2e/studio/blob-report
retention-days: 7
- name: Fail job if tests failed
if: steps.filter.outputs.studio == 'true' && steps.playwright.outcome != 'success'
run: |
echo "E2E tests failed" >&2
exit 1
merge-reports:
name: 'E2E reports'
# Merge reports after playwright-tests, even if some shards have failed
if: ${{ !cancelled() && needs.test.outputs.tests_ran == 'true' }}
needs: [test]
runs-on: blacksmith-4vcpu-ubuntu-2404
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Use Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version-file: '.nvmrc'
- name: Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v 5.0.0
with:
path: e2e/studio/blob-report
pattern: blob-report-*
merge-multiple: true
- name: Merge Playwright reports
run: npx playwright merge-reports --config=e2e/studio/playwright.merge.config.ts -- e2e/studio/blob-report
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: playwright-artifacts
path: |
e2e/studio/playwright-report/
e2e/studio/test-results/
retention-days: 7
- name: Comment Playwright test results on PR
if: always() && github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork
uses: daun/playwright-report-comment@be9e270edd5ad86038604d3caa84a819a6ff6fed # v3.10.0
with:
report-file: e2e/studio/test-results/test-results.json
comment-title: '🎭 Playwright Test Results'
merge-results:
name: 'E2E results'
runs-on: ubuntu-latest
permissions: {}
needs: [test]
if: ${{ !cancelled() && needs.test.outputs.tests_ran == 'true' }}
steps:
- name: All tests ok
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0
- name: Some tests failed
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1