Skip to content

Commit ba4000e

Browse files
committed
build: reduce build time and improve CI quality
- Remove agent-markdown-audit from default build (no-op in prod) - Replace pre-push full build with astro check (saves ~3 min per push) - Add GitHub Actions CI: type check, format check, audit on every push/PR - Enable starlightLinksValidator on deploy previews (skip production only) - Raise maxParallelFileOps from 2 to 8 to reduce Rollup serialization - Parallelize generate-llms-index.js file reads with async fs/promises - Add /_astro/* immutable cache headers for content-hashed assets - Fix incorrect node_bundler comment and remove redundant included_files - Fix stale output: server comment in astro.config.mjs - Add build audit report to project-docs/
1 parent e19b4c7 commit ba4000e

7 files changed

Lines changed: 732 additions & 28 deletions

File tree

.github/workflows/ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ['**']
6+
pull_request:
7+
8+
jobs:
9+
check:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- uses: pnpm/action-setup@v4
15+
# Reads packageManager field from package.json automatically
16+
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version: 20
20+
cache: 'pnpm'
21+
22+
- name: Install dependencies
23+
run: pnpm install --frozen-lockfile
24+
25+
- name: Type check
26+
run: pnpm astro check
27+
28+
- name: Format check
29+
run: pnpm run format:check
30+
31+
- name: Agent markdown audit
32+
run: node scripts/agent-markdown-audit.js --strict

.simple-git-hooks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"pre-commit": "pnpm pretty-quick --staged",
3-
"pre-push": "if [ -n \"$(git status --porcelain)\" ]; then echo \"❌ Error: You have uncommitted changes. Please commit or stash them before pushing.\"; git status --short; exit 1; fi && echo \"Running build before push...\" && pnpm run generate-search-index && pnpm run build && node scripts/log-preview-url.js"
3+
"pre-push": "if [ -n \"$(git status --porcelain)\" ]; then echo \"❌ Error: You have uncommitted changes. Please commit or stash them before pushing.\"; git status --short; exit 1; fi && pnpm astro check && node scripts/log-preview-url.js"
44
}

astro.config.mjs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ import { injectAgentHeader } from './src/integrations/inject-agent-header.ts'
3131

3232
// https://astro.build/config
3333
export default defineConfig({
34-
// Switched from 'server' to default (static) to drastically reduce build memory.
35-
// Astro 6's Vite Environments API creates separate build contexts per output mode;
36-
// 'server' mode processes all 300+ pages through a heavy SSR pipeline.
37-
// The few SSR pages (auth, health, admin) already have `prerender = false`.
34+
// SSR mode: the Netlify adapter prerendering per-page via `prerender` exports.
35+
// Pages without `prerender = false` are statically generated at build time.
36+
// Memory-intensive builds: see vite.build settings below.
3837
output: 'server',
3938
site: 'https://docs.scalekit.com',
4039
server: {
@@ -106,9 +105,10 @@ export default defineConfig({
106105
askAi: '8jKZkVuXS0hG',
107106
}),
108107
starlightVideos(),
109-
// Links validator disabled in CI to reduce build memory usage.
110-
// Run locally with: pnpm astro build (without NETLIFY env var)
111-
...(!process.env.NETLIFY
108+
// Links validator: enabled locally and on deploy previews; skipped on production
109+
// Netlify builds to reduce peak memory usage.
110+
// CONTEXT is set by Netlify: 'production' | 'deploy-preview' | 'branch-deploy'
111+
...(!process.env.NETLIFY || process.env.CONTEXT !== 'production'
112112
? [
113113
starlightLinksValidator({
114114
exclude: ['/apis/**'],
@@ -411,8 +411,9 @@ export default defineConfig({
411411
// Disable gzip size reporting to save memory on large builds
412412
reportCompressedSize: false,
413413
rollupOptions: {
414-
// Limit parallel file I/O to reduce memory spikes during bundling
415-
maxParallelFileOps: 2,
414+
// Limit parallel file I/O to reduce memory spikes during bundling.
415+
// 8 caps concurrency well below unlimited while reducing serialization vs. the prior value of 2.
416+
maxParallelFileOps: 8,
416417
output: {
417418
manualChunks(id) {
418419
if (id.includes('@scalar')) return 'scalar'

netlify.toml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
[functions]
99
directory = "netlify/functions"
10+
# Bundles Functions 1.x with esbuild. The SSR function (Functions 2.0) is
11+
# bundled separately by the Netlify adapter and is not affected by this setting.
1012
node_bundler = "esbuild"
11-
# Ensure Functions 2.0 format is used
12-
included_files = ["netlify/functions/**"]
1313

1414
# Local dev: same as `pnpm run start` — `NETLIFY_DEV=1 astro dev` on port 4321.
1515
# Declare `command` + `targetPort` so Netlify Dev matches astro.config server settings.
@@ -21,7 +21,15 @@
2121
path = "/*"
2222
function = "track-agents"
2323

24-
# LLM-friendly files: fresh but cacheable (1 hour)
24+
# Astro emits content-hashed filenames for all JS/CSS bundles — safe to cache permanently.
25+
# The hash changes whenever content changes, so immutable is correct here.
26+
[[headers]]
27+
for = "/_astro/*"
28+
[headers.values]
29+
Cache-Control = "public, max-age=31536000, immutable"
30+
31+
# LLM index files — 1h fresh, 24h stale. All four rules below are intentionally identical;
32+
# Netlify TOML requires a separate [[headers]] block per path pattern.
2533
[[headers]]
2634
for = "/llms.txt"
2735
[headers.values]

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
"scripts": {
77
"dev": "netlify dev:exec pnpm run start",
88
"start": "cross-env NETLIFY_DEV=1 astro dev",
9-
"build": "astro build && node scripts/generate-llms-index.js && node scripts/agent-markdown-audit.js",
9+
"build": "astro build && node scripts/generate-llms-index.js",
1010
"agent-markdown:audit": "node scripts/agent-markdown-audit.js",
11+
"agent-markdown:audit:strict": "node scripts/agent-markdown-audit.js --strict",
1112
"preview": "astro preview",
1213
"astro": "astro",
1314
"upgrade": "pnpm dlx @astrojs/upgrade",

0 commit comments

Comments
 (0)