codeflash-internal/.github/workflows/nextjs-build.yaml
Kevin Turcios d7a8b8f227
perf: fix CI build + lazy-load heavy libs + parallelize DB queries (#2601)
## Summary
- **Fix CI build failure**: Auth0Client crashes during Next.js
prerendering when env vars aren't set. Returns a no-op stub (`getSession
→ null`) when domain is missing — semantically correct for static
generation
- **Lazy-load markdown libs (~260kb)**: ReactMarkdown, remarkGfm, and
react-syntax-highlighter were eagerly imported in monaco-diff-viewer but
only rendered when user expands "Generated Tests". Extracted into a
dynamic component
- **Parallelize repo detail query**: `getRepositoryById` ran the
activity count sequentially after the repo lookup. Since `repoId` is
already available, all three queries now run in parallel

## Test plan
- [ ] CI `build` check passes (was failing since #2598)
- [ ] Trace page still renders generated tests correctly when expanded
- [ ] Repository detail page loads correctly with activity status
2026-04-13 11:03:05 -05:00

88 lines
2.4 KiB
YAML

name: Next.js Build Check
on:
pull_request:
paths:
- 'js/cf-webapp/**'
permissions:
contents: read
pull-requests: read
jobs:
# This job checks if the workflow should run based on file changes
check-changes:
runs-on: ubuntu-latest
outputs:
should-run: ${{ steps.filter.outputs.webapp }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: dorny/paths-filter@v4
id: filter
with:
filters: |
webapp:
- 'js/cf-webapp/**'
# This job always runs and succeeds, allowing PRs to be merged when paths don't match
skip-build:
needs: check-changes
if: needs.check-changes.outputs.should-run != 'true'
runs-on: ubuntu-latest
steps:
- name: Skip build
run: echo "Skipping Next.js build - no changes in js/cf-webapp/"
build:
needs: check-changes
if: needs.check-changes.outputs.should-run == 'true'
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
registry-url: https://npm.pkg.github.com
scope: '@codeflash-ai'
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Restore WASM artifacts cache
uses: actions/cache@v5
with:
path: |
js/cf-webapp/public/web-tree-sitter.wasm
js/cf-webapp/public/tree-sitter-python.wasm
js/cf-webapp/public/.tree-sitter-python-version
key: wasm-${{ runner.os }}-${{ hashFiles('js/pnpm-lock.yaml') }}
- name: Install dependencies
working-directory: js
run: pnpm install --frozen-lockfile
- name: Restore Next.js build cache
uses: actions/cache@v5
with:
path: js/cf-webapp/.next/cache
key: nextjs-${{ runner.os }}-${{ hashFiles('js/pnpm-lock.yaml') }}-${{ hashFiles('js/cf-webapp/src/**') }}
restore-keys: |
nextjs-${{ runner.os }}-${{ hashFiles('js/pnpm-lock.yaml') }}-
nextjs-${{ runner.os }}-
- name: Build Next.js app
working-directory: js
run: pnpm --filter cf-webapp build