@devries-cameron20 / composio Mirror · read-only / commits / 2ebbef759
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 08:30 UTC

fix(docs): fetch source history before Vercel builds

Brendan O'Leary committed Oct 16, 2026 at 13:58 UTC 2ebbef759ca2d77e1705be5b9570c5e5e1c60598
4 files changed +49 -4
docs/CONTRIBUTING.md
+1 -1
@@ -82,7 +82,7 @@ The prebuild, predev, and type-check steps generate `.generated/content-freshnes
82
83 You can declare `last_updated: YYYY-MM-DD` or a timezone-qualified ISO timestamp in authored front matter. A date-only value means midnight UTC; an invalid value fails generation. Otherwise, freshness uses the source file's last Git commit. Dated changelog pages use the latest known update across entries for that date. A source commit records an edit, not a review or a guarantee that the guidance is current.
84
85 -Docs CI fetches full history. For other CI/CD builds, provide full history (`fetch-depth: 0` with `actions/checkout`) for complete freshness coverage. A shallow checkout retains dates for changes proven within its history but omits unknown shallow-boundary dates. Source archives without history also omit unknown dates. Neither case substitutes the checkout or build time.
85 +Docs CI fetches full history. The Vercel build command fetches missing history before running `bun run build`. If that fetch fails, the deployment fails instead of silently publishing incomplete freshness. For other CI/CD builds, provide full history (`fetch-depth: 0` with `actions/checkout`) for complete freshness coverage. A shallow checkout retains dates for changes proven within its history but omits unknown shallow-boundary dates. Source archives without history also omit unknown dates. Neither case substitutes the checkout or build time.
86
87 ## Request review and verify publication
88
docs/scripts/vercel-build.sh new
+9
@@ -0,0 +1,9 @@
1 +#!/bin/sh
2 +set -eu
3 +
4 +# Vercel clones limited history; freshness needs each source's actual last edit.
5 +if [ "$(git rev-parse --is-shallow-repository 2>/dev/null)" = true ]; then
6 + git fetch --unshallow --no-tags origin
7 +fi
8 +
9 +bun run build
docs/tests/static/content-freshness.test.ts
+38 -2
@@ -1,9 +1,9 @@
1 import { afterEach, describe, expect, test } from 'bun:test';
2 import { execFileSync } from 'node:child_process';
3 -import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
3 +import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
4 import { tmpdir } from 'node:os';
5 import { dirname, join } from 'node:path';
6 -import { pathToFileURL } from 'node:url';
6 +import { fileURLToPath, pathToFileURL } from 'node:url';
7 import {
8 buildContentFreshness, getExplicitLastUpdated, normalizeLastUpdated,
9 } from '../../lib/content-freshness-build';
@@ -141,6 +141,42 @@ describe('source-backed page freshness', () => {
141 expect(deeper.pages['/page']).toBe('2025-02-02T12:00:00.000Z');
142 });
143
144 + test('Vercel fetches shallow history before building and stops if the fetch fails', () => {
145 + const original = repository();
146 + put(original, 'docs/page.mdx', 'original');
147 + commit(original, initial);
148 + put(original, 'unrelated.txt', 'updated');
149 + commit(original, unrelated);
150 + const shallow = temporaryDirectory();
151 + git(shallow, 'clone', '--depth=1', pathToFileURL(original).href, '.');
152 + const docs = join(shallow, 'docs');
153 + const definitions = [{ pathname: '/page', sources: ['page.mdx'] }];
154 + expect(buildContentFreshness(docs, definitions).pages['/page']).toBeUndefined();
155 +
156 + // Replace only the expensive app build; exercise the real Git commands.
157 + const bin = temporaryDirectory();
158 + put(bin, 'bun', '#!/bin/sh\nset -eu\ntest "$1" = run\ntest "$2" = build\ngit rev-parse --is-shallow-repository > build-history-state\n');
159 + chmodSync(join(bin, 'bun'), 0o755);
160 + const script = fileURLToPath(new URL('../../scripts/vercel-build.sh', import.meta.url));
161 + const run = () => execFileSync('sh', [script], {
162 + cwd: docs, stdio: ['ignore', 'pipe', 'pipe'],
163 + env: { ...process.env, PATH: `${bin}:${process.env.PATH}` },
164 + });
165 + run();
166 + expect(readFileSync(join(docs, 'build-history-state'), 'utf8').trim()).toBe('false');
167 + expect(buildContentFreshness(docs, definitions).pages['/page']).toBe('2025-01-01T12:00:00.000Z');
168 +
169 + // Complete clones do not need a reachable remote.
170 + git(shallow, 'remote', 'set-url', 'origin', join(original, 'missing'));
171 + run();
172 +
173 + // A failed fetch must stop before the build can publish unknown dates.
174 + git(shallow, 'fetch', '--depth=1', pathToFileURL(original).href);
175 + rmSync(join(docs, 'build-history-state'));
176 + expect(() => run()).toThrow();
177 + expect(existsSync(join(docs, 'build-history-state'))).toBe(false);
178 + });
179 +
180 test('persists the artifact and serves it after source and Git removal', async () => {
181 const root = repository();
182 put(root, 'page.mdx', 'original');
docs/vercel.json
+1 -1
@@ -1,5 +1,5 @@
1 {
2 "installCommand": "bun install",
3 - "buildCommand": "bun run build",
3 + "buildCommand": "sh scripts/vercel-build.sh",
4 "framework": "nextjs"
5 }