From 224ccd654bd1ad77b413c87d903e58bd6582c06a Mon Sep 17 00:00:00 2001 From: simoleo89 Date: Sat, 18 Jul 2026 21:15:52 +0200 Subject: [PATCH] perf(deploy): keep .next/cache while clearing stale generated types Nuclear src replace already guarantees clean sources; restoring the build cache speeds deploys without reintroducing sticky typecheck ghosts. Co-authored-by: Cursor --- .gitea/workflows/deploy.yaml | 5 +++-- src/lib/deploy-workflow-contract.test.ts | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index 2e5be183..4ed40cb6 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -88,8 +88,9 @@ jobs: rm -f tsconfig.tsbuildinfo .tsbuildinfo find . -maxdepth 3 -name '*.tsbuildinfo' -delete 2>/dev/null || true - # Wipe .next entirely — partial cache has disagreed with clean sources. - rm -rf .output dist .next + # Clear generated Next types/dev dirs, but keep .next/cache for faster rebuilds. + # Full src/ nuclear replace above already guarantees sources match HEAD. + rm -rf .output dist .next/types .next/dev # Release tag for Sentry / logs (short git sha) export APP_VERSION="$(git rev-parse --short HEAD)" diff --git a/src/lib/deploy-workflow-contract.test.ts b/src/lib/deploy-workflow-contract.test.ts index c5d8d4fb..1993691e 100644 --- a/src/lib/deploy-workflow-contract.test.ts +++ b/src/lib/deploy-workflow-contract.test.ts @@ -8,8 +8,10 @@ describe("production deploy workflow", () => { "utf8", ); - it("wipes .next before build to avoid stale Next typecheck caches", () => { - expect(workflow).toContain("rm -rf .output dist .next"); + it("preserves the Next.js incremental build cache", () => { + // May clear .next/types or .next/dev, but must not wipe the whole .next tree. + expect(workflow).not.toMatch(/rm\s+-rf\s+\.next(?:\s|$)/); + expect(workflow).toContain("rm -rf .output dist .next/types .next/dev"); expect(workflow).toContain("pnpm install --frozen-lockfile"); expect(workflow).toContain("SKIP_ENV_VALIDATION=1"); });