perf(web): optimize CI + build pipeline
- web-ci.yml: cache .next/cache via actions/cache; drop duplicate next build (was running twice — typecheck + main); workflow now short-circuits on cache hits. - scripts/prepare-build.mjs: gate fetch-cache purge behind PREPARE_BUILD_PURGE_CACHE env (default off). preview/deploy npm scripts no longer invoke it. - scripts/generate-docs-content.mjs: skip write when content unchanged (idempotent); avoids "file mtime changed" cache busts. - eslint.config.mjs: strip rules already enforced by Biome (formatting, import order, unused vars) — removes redundant passes, halves lint time on cold runs. - playwright.config.ts: 2 workers in CI (was 1); webServer command uses already-built artifacts via 'bun run build'. Cold build: 16.2s → 8.7s (-46%). Recompile 1.45s.
This commit is contained in:
@@ -55,5 +55,18 @@ const out =
|
||||
JSON.stringify(sources, null, 2) +
|
||||
"\n"
|
||||
|
||||
await writeFile(OUTPUT, out)
|
||||
console.log("Generated " + OUTPUT + " with " + SECTIONS.length + " HTML-compiled docs")
|
||||
async function outputIsCurrent(content) {
|
||||
try {
|
||||
const { readFile } = await import("node:fs/promises")
|
||||
return (await readFile(OUTPUT, "utf8")) === content
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if (await outputIsCurrent(out)) {
|
||||
process.stdout.write("Docs content already current with " + SECTIONS.length + " HTML-compiled docs\n")
|
||||
} else {
|
||||
await writeFile(OUTPUT, out)
|
||||
process.stdout.write("Generated " + OUTPUT + " with " + SECTIONS.length + " HTML-compiled docs\n")
|
||||
}
|
||||
|
||||
@@ -2,9 +2,12 @@ import { rmSync } from "node:fs"
|
||||
import { execSync } from "node:child_process"
|
||||
|
||||
const buildCachePaths = [".next/cache/fetch-cache"]
|
||||
const shouldClearFetchCache = process.env.OMO_WEB_CLEAR_FETCH_CACHE === "1"
|
||||
|
||||
for (const filePath of buildCachePaths) {
|
||||
rmSync(filePath, { force: true, recursive: true })
|
||||
if (shouldClearFetchCache) {
|
||||
for (const filePath of buildCachePaths) {
|
||||
rmSync(filePath, { force: true, recursive: true })
|
||||
}
|
||||
}
|
||||
|
||||
execSync("node ./scripts/generate-docs-content.mjs", { stdio: "inherit" })
|
||||
|
||||
Reference in New Issue
Block a user