Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

ci(perf): cache web test compilation across modes (#15899)

Tobias Wochingeraa0c263159cd
diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml
index 978bdf3897..bc69d53b81 100644
--- a/.github/workflows/pipeline.yml
+++ b/.github/workflows/pipeline.yml
@@ -545,30 +545,33 @@ jobs:
pnpm install
- name: Load default env
run: |
- cp .env.dev${{ matrix.deploy-mode }}.example .env
- grep -v -e '^LANGFUSE_S3_BATCH_EXPORT_ENABLED=' -e '^NEXT_PUBLIC_LANGFUSE_RUN_NEXT_INIT=' .env.dev${{ matrix.deploy-mode }}.example > .env
- echo "LANGFUSE_INGESTION_QUEUE_DELAY_MS=1" >> .env
- echo "LANGFUSE_CACHE_PROMPT_ENABLED=false" >> .env
- echo "LANGFUSE_INGESTION_CLICKHOUSE_WRITE_INTERVAL_MS=1" >> .env
- echo "LANGFUSE_TRACE_DELETE_DELAY_MS=1" >> .env
- echo "LANGFUSE_TRACE_DELETE_CONCURRENCY=100" >> .env
- echo "ADMIN_API_KEY=admin-api-key" >> .env
- echo "LANGFUSE_EE_LICENSE_KEY=langfuse_ee_test" >> .env
- echo "LANGFUSE_SKIP_EVALUATOR_MODEL_CALL_VALIDATION=true" >> .env
- echo "LANGFUSE_ENABLE_SCORES_V3_API=true" >> .env
+ write_test_env() {
+ {
+ grep -v -e '^LANGFUSE_S3_BATCH_EXPORT_ENABLED=' -e '^NEXT_PUBLIC_LANGFUSE_RUN_NEXT_INIT=' "$1"
+ echo "LANGFUSE_INGESTION_QUEUE_DELAY_MS=1"
+ echo "LANGFUSE_CACHE_PROMPT_ENABLED=false"
+ echo "LANGFUSE_INGESTION_CLICKHOUSE_WRITE_INTERVAL_MS=1"
+ echo "LANGFUSE_TRACE_DELETE_DELAY_MS=1"
+ echo "LANGFUSE_TRACE_DELETE_CONCURRENCY=100"
+ echo "ADMIN_API_KEY=admin-api-key"
+ echo "LANGFUSE_EE_LICENSE_KEY=langfuse_ee_test"
+ echo "LANGFUSE_SKIP_EVALUATOR_MODEL_CALL_VALIDATION=true"
+ echo "LANGFUSE_ENABLE_SCORES_V3_API=true"
+ } > "$2"
+ }
+
+ # Compile once under the default test environment. Next's generate
+ # phase below reapplies the mode-specific config and prerendering.
+ write_test_env .env.dev.example .env
+ write_test_env .env.dev${{ matrix.deploy-mode }}.example .env.runtime
- name: Setup Turbo cache
if: env.CI_CACHE_ALLOWED == 'true'
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # zizmor: ignore[cache-poisoning] test job cache only; publish jobs rebuild artifacts and do not restore this cache
with:
path: .turbo
- # Turbo hashes the whole .env (turbo.json globalDependencies) and
- # each deploy-mode writes a different .env, so keys must be
- # mode-scoped for every matrix job to replay its own builds. The
- # default mode gets an explicit "-default" segment so its restore
- # prefix cannot match the other modes' keys.
- key: ${{ runner.os }}-turbo-mode${{ matrix.deploy-mode == '' && '-default' || matrix.deploy-mode }}-${{ github.sha }}
+ key: ${{ runner.os }}-turbo-tests-web-compile-${{ github.sha }}
restore-keys: |
- ${{ runner.os }}-turbo-mode${{ matrix.deploy-mode == '' && '-default' || matrix.deploy-mode }}-
+ ${{ runner.os }}-turbo-tests-web-compile-
# No Next.js build cache here on purpose: its ~30s/job restore+save cost
# roughly cancels the build speedup, and the Turbo cache above already
# replays unchanged builds.
@@ -576,22 +579,29 @@ jobs:
# Independent of the build, so let the build overlap the ~15-20s
# container startup. "Wait for dev containers" collects the result.
run: |
- (set +e; docker compose -f docker-compose.dev${{ matrix.deploy-mode }}.yml up -d --wait --wait-timeout 180 > /tmp/compose-up.log 2>&1; echo $? > /tmp/compose-up.exit) &
+ (set +e; docker compose --env-file .env.runtime -f docker-compose.dev${{ matrix.deploy-mode }}.yml up -d --wait --wait-timeout 180 > /tmp/compose-up.log 2>&1; echo $? > /tmp/compose-up.exit) &
env:
POSTGRES_VERSION: ${{ matrix.postgres-version }}
- name: Build
- run: pnpm run build
+ run: pnpm turbo run build:test
env:
NODE_OPTIONS: --max_old_space_size=8192
# TypeScript is checked explicitly in the lint job; skip duplicate
# Next.js type checks in test builds to reduce CI runtime.
NEXT_IGNORE_BUILD_ERRORS: "true"
+ - name: Finalize build for runtime environment
+ run: |
+ cp .env.runtime .env
+ pnpm --filter web exec dotenv -e ../.env -- next build --experimental-build-mode generate
+ env:
+ NODE_OPTIONS: --max_old_space_size=8192
+ NEXT_IGNORE_BUILD_ERRORS: "true"
- name: Wait for dev containers
run: |
timeout 300 bash -c 'until [ -f /tmp/compose-up.exit ]; do sleep 1; done' \
|| { echo "Timed out waiting for background docker compose up"; cat /tmp/compose-up.log; exit 1; }
cat /tmp/compose-up.log
- docker compose ps
+ docker compose --env-file .env.runtime -f docker-compose.dev${{ matrix.deploy-mode }}.yml ps
exit "$(cat /tmp/compose-up.exit)"
- name: Migrate DB
run: |
diff --git a/.github/workflows/warm-caches.yml b/.github/workflows/warm-caches.yml
index 7ca3ab1320..02694b12e9 100644
--- a/.github/workflows/warm-caches.yml
+++ b/.github/workflows/warm-caches.yml
@@ -10,7 +10,7 @@ name: Warm CI caches
# (contradicting their documented 7-day LRU eviction), so most branch runs
# find nothing and pay a cold pnpm install plus a cold turbo build (~+2min on
# the tests-web critical path). This workflow re-saves the pnpm store and the
-# mode-scoped turbo caches from main every few hours so branch runs keep
+# task-scoped Turbo caches from main every few hours so branch runs keep
# hitting them. Once Blacksmith retention is back to days, drop the schedule
# to daily or delete the workflow — it is purely compensatory.
on:
@@ -44,20 +44,14 @@ jobs:
# Mirror the consuming test jobs so Turbo task hashes match.
NODE_ENV: test
strategy:
- # One mode failing must not cancel the other warmers — a partially
+ # One profile failing must not cancel the other warmer — a partially
# warmed pool still helps.
fail-fast: false
matrix:
include:
- - cache_scope: mode-default
+ - cache_scope: tests-web-compile
deploy-mode: ""
env_profile: tests-web
- - cache_scope: mode-azure
- deploy-mode: -azure
- env_profile: tests-web
- - cache_scope: mode-redis-cluster
- deploy-mode: -redis-cluster
- env_profile: tests-web
- cache_scope: server-e2e
deploy-mode: ""
env_profile: e2e-server
@@ -111,7 +105,12 @@ jobs:
- name: Build
# dev containers / Postgres are not needed: the build task only
# depends on db:generate, which is offline.
- run: pnpm run build
+ run: |
+ if [ "${{ matrix.env_profile }}" = "tests-web" ]; then
+ pnpm turbo run build:test
+ else
+ pnpm run build
+ fi
env:
NODE_OPTIONS: --max_old_space_size=8192
# TypeScript is checked explicitly in the lint job; skip duplicate
diff --git a/packages/in-app-agent-sandbox-runtime/package.json b/packages/in-app-agent-sandbox-runtime/package.json
index 9e6dc61dc4..2a89767d5b 100644
--- a/packages/in-app-agent-sandbox-runtime/package.json
+++ b/packages/in-app-agent-sandbox-runtime/package.json
@@ -8,6 +8,7 @@
},
"scripts": {
"build": "tsc",
+ "build:test": "tsc",
"build:docker-image": "docker build . -t langfuse-in-app-agent-sandbox:latest && touch .local-image-built",
"start": "node ./dist/server.js",
"format": "prettier --write .",
diff --git a/turbo.json b/turbo.json
index 67af06e22f..d99f08608d 100644
--- a/turbo.json
+++ b/turbo.json
@@ -18,6 +18,13 @@
"cache": true,
"outputLogs": "errors-only"
},
+ "build:test": {
+ "dependsOn": ["db:generate", "^build"],
+ "env": ["NEXT_IGNORE_BUILD_ERRORS"],
+ "outputs": ["dist/**", ".next/**", "!.next/cache/**"],
+ "cache": true,
+ "outputLogs": "errors-only"
+ },
"start": {
"dependsOn": ["^start"]
},
diff --git a/web/package.json b/web/package.json
index 630f155c97..0bbc5b0a22 100644
--- a/web/package.json
+++ b/web/package.json
@@ -8,6 +8,7 @@
},
"scripts": {
"build": "INLINE_RUNTIME_CHUNK=false dotenv -e ../.env -- next build",
+ "build:test": "INLINE_RUNTIME_CHUNK=false dotenv -e ../.env -- next build --experimental-build-mode compile",
"build:check": "NEXT_DIST_DIR=.next-check INLINE_RUNTIME_CHUNK=false dotenv -e ../.env -- next build",
"typecheck": "dotenv -e ../.env -- tsc -p tsconfig.json --noEmit --skipLibCheck --incremental --tsBuildInfoFile .tsbuildinfo",
"dev": "dotenv -e ../.env -- next dev",
diff --git a/worker/package.json b/worker/package.json
index 8f86e1eecb..24cfa6ace3 100644
--- a/worker/package.json
+++ b/worker/package.json
@@ -18,6 +18,7 @@
"coverage": "vitest run --coverage",
"start": "dotenv -e ../.env -- node dist/index.js",
"build": "tsc",
+ "build:test": "tsc",
"build:check": "tsc",
"typecheck": "dotenv -e ../.env -- tsc --noEmit --skipLibCheck --incremental --tsBuildInfoFile .tsbuildinfo",
"dev": "dotenv -e ../.env -- tsx watch --clear-screen=false --include '../packages/shared/dist/*' src/index.ts",