Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,11 @@ jobs:
- name: Public reference gate
run: bun run ref-gate

- name: Fetch bundled sources
run: bun run fetch

- name: Build site
run: bun run build

- name: Reference gate over published output
run: bun run ref-gate:dist
13 changes: 12 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
push:
branches: [main]
pull_request: {}
workflow_dispatch:
schedule:
- cron: "17 5 * * *"

permissions: {}

Expand All @@ -14,7 +17,8 @@ concurrency:
jobs:
deploy:
# Fork PRs do not receive secrets, so skip their Pages deployment.
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
# Manual runs publish to production main only, so a branch dispatch is skipped.
if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && (github.event_name != 'workflow_dispatch' || github.ref == 'refs/heads/main')
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -34,12 +38,19 @@ jobs:
bun="$(nix build --no-link --print-out-paths --inputs-from . nixpkgs#bun)"
echo "$bun/bin" >> "$GITHUB_PATH"

- name: Fetch bundled sources
# Before install: fetch.ts imports only node: modules, so no package code runs here.
run: bun run fetch

- name: Install dependencies
run: bun install --frozen-lockfile

- name: Build site
run: bun run build

- name: Reference gate over published output
run: bun run ref-gate:dist

- name: Deploy to Cloudflare Pages
run: bun run deploy
env:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ dist/
.astro/
.devenv/
site/dist/
site/.bundle/
site/.astro/
site/node_modules/
.direnv/
Expand All @@ -12,3 +13,4 @@ site/src/sidebar.generated.ts
node_modules/.cache/
result
result-*
site/public/_bundle.json
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,16 @@ Check the returned ID before creating `docs/designs/<project>/decisions/<area>/D

## Checks and site

Run `bun install`, `bun test`, `bun run gate`, `bun run ref-gate`, `rumdl check .`, `biome ci .`, and `bun run build`. The gather step reads checked-in Markdown under `docs/`, renders decision pages and per-project decision indexes into generated content, and the Astro Starlight site publishes to the Cloudflare Pages project `docs`.
Run `bun install`, `bun test`, `bun run gate`, `bun run ref-gate`, `rumdl check .`, `biome ci .`, and `bun run fetch && bun run build`. The gather step reads checked-in Markdown under `docs/`, renders decision pages and per-project decision indexes into generated content, and the Astro Starlight site publishes to the Cloudflare Pages project `docs`.

The canonical source-repository dispatch workflow is `site/dispatch/docs-dispatch.yml`.

Cloudflare assigns the Pages hostname for project `docs`; the site does not configure a custom domain.

## Bundled sources

`site/sources.json` lists the code repos whose markdown the site bundles. `bun run fetch` clones each repo's `main` over anonymous HTTPS into `site/.bundle/`, and `bun run gather` turns their pages into site routes under `/<repo>/`. A source uses the `default` config (every gatherable markdown file) until it adds a `docs-bundle.toml`.

The deploy workflow runs the fetch before dependency install. After the build, `bun run ref-gate:dist` scans `site/dist` (minus `pagefind/`) and fails the deploy on a reference hit. The build writes `_bundle.json` with each source's SHA. Set `DOCS_BUNDLE_PINS="<repo>=<sha>"` to build a pinned SHA.

Each bundled source gets a sidebar group under its mount directory, and the landing page links each source.
4 changes: 3 additions & 1 deletion bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion hk.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ hooks {
}
["build"] = new Step {
depends = "ref-gate"
check = "bun run build"
check = "bun run fetch && bun run build && bun run ref-gate:dist"
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@
"type": "module",
"scripts": {
"gather": "bun site/scripts/gather.ts",
"fetch": "bun site/scripts/fetch.ts",
"test": "bun test",
"build": "bun run gather && astro build --root site",
"check": "astro check --root site",
"gate": "design-ledger-gate --config design-ledger.config.json",
"ref-gate": "ref-gate --config ref-gate.config.json",
"ref-gate:dist": "bun site/scripts/ref-gate-dist.ts",
"claim": "dl-claim --config design-ledger.claim.config.json",
"deploy": "bun site/scripts/deploy.ts"
},
"dependencies": {
"@astrojs/check": "0.9.10",
"@astrojs/starlight": "0.41.8",
"@rigelbuild/design-ledger-gate": "2.0.1",
"@rigelbuild/docs-bundle": "1.2.0",
"@rigelbuild/dl-claim": "1.1.1",
"@rigelbuild/ref-gate": "1.0.0",
"astro": "7.2.4",
"github-slugger": "2.0.0",
"pagefind": "1.5.2",
"sharp": "0.35.2",
"wrangler": "4.128.0"
Expand Down
15 changes: 15 additions & 0 deletions site/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { readFileSync } from "node:fs";
import starlight from "@astrojs/starlight";
import { defineConfig } from "astro/config";

const sources = JSON.parse(
readFileSync(new URL("./sources.json", import.meta.url), "utf8"),
);

export default defineConfig({
output: "static",
integrations: [
Expand All @@ -13,6 +18,16 @@ export default defineConfig({
label: "Designs",
items: [{ autogenerate: { directory: "designs" } }],
},
...sources.map((source) => ({
label: source.repo.slice(source.repo.indexOf("/") + 1),
items: [
{
autogenerate: {
directory: source.mount.replace(/^\/+|\/+$/g, ""),
},
},
],
})),
],
customCss: ["./src/styles/fonts.css", "./src/styles/custom.css"],
// A bundled light Shiki theme keeps code samples readable on the light surface.
Expand Down
48 changes: 48 additions & 0 deletions site/scripts/bundle-routes.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { describe, expect, test } from "bun:test";
import type { BundlePage, FetchedSource } from "@rigelbuild/docs-bundle";
import { remapSourceRoutes } from "./bundle-routes.ts";

const source: FetchedSource = {
repo: "RigelBuild/meissa",
mount: "/meissa/",
config: "default",
root: "/tmp/meissa",
sha: "a".repeat(40),
};

function page(sourcePath: string, route: string): BundlePage {
return {
repo: source.repo,
sourcePath,
route,
section: null,
pagefind: true,
};
}

describe("bundled route adaptation", () => {
test("remaps nested pages to their public repo mount", () => {
expect(
remapSourceRoutes(
[
page(
"docs/guides/Setup Guide.md",
"/RigelBuild/meissa/meissa/docs/guides/setup-guide",
),
],
source,
),
).toEqual([
page("docs/guides/Setup Guide.md", "/meissa/docs/guides/setup-guide"),
]);
});

test("keeps a README page at the mounted repository's index", () => {
expect(
remapSourceRoutes(
[page("README.md", "/RigelBuild/meissa/meissa/readme")],
source,
),
).toEqual([page("README.md", "/meissa")]);
});
});
24 changes: 24 additions & 0 deletions site/scripts/bundle-routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { BundlePage, FetchedSource } from "@rigelbuild/docs-bundle";

export function remapSourceRoutes(
pages: readonly BundlePage[],
source: FetchedSource,
): BundlePage[] {
const repoPrefix = `/${source.repo}`;
const mount = source.mount.replace(/^\/+|\/+$/g, "");
const mountPrefix = mount.length === 0 ? "" : `/${mount}`;
return pages.map((page) => {
if (page.repo !== source.repo || !page.route.startsWith(repoPrefix))
throw new Error(`unexpected route from docs bundle: ${page.route}`);
const mounted = page.route.slice(repoPrefix.length);
if (mountPrefix.length > 0 && !mounted.startsWith(mountPrefix))
throw new Error(`route does not match source mount: ${page.route}`);
const relativeRoute =
mountPrefix.length === 0 ? mounted : mounted.slice(mountPrefix.length);
const route =
page.sourcePath.toLowerCase() === "readme.md"
? mountPrefix || "/"
: `${mountPrefix}${relativeRoute}`.replace(/\/index$/, "") || "/";
return { ...page, route };
});
}
90 changes: 90 additions & 0 deletions site/scripts/fetch.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { describe, expect, test } from "bun:test";
import {
buildCloneArgs,
buildGitEnvironment,
isSource,
parsePins,
sparsePatterns,
} from "./fetch.ts";

describe("source fetch command construction", () => {
test("uses a shallow filtered main clone for unpinned sources", () => {
const args = buildCloneArgs("RigelBuild/meissa", "/tmp/source");
expect(args).toEqual([
"-c",
"credential.helper=",
"clone",
"--branch",
"main",
"--filter=blob:none",
"--sparse",
"--depth",
"1",
"https://github.com/RigelBuild/meissa.git",
"/tmp/source",
]);
});

test("keeps blob filtering and drops clone depth for a pinned source", () => {
const args = buildCloneArgs(
"RigelBuild/meissa",
"/tmp/source",
"a".repeat(40),
);
expect(args).toContain("--filter=blob:none");
expect(args).not.toContain("--depth");
expect(sparsePatterns()).toContain("/docs-bundle.toml");
expect(sparsePatterns()).toContain("/**/*.md");
expect(sparsePatterns()).toContain("/**/*.SVG");
});

test("constructs a prompt-free environment without inherited credentials", () => {
expect(
buildGitEnvironment({
PATH: "/usr/bin",
HOME: "/home/test",
GH_TOKEN: "not-forwarded",
GITHUB_TOKEN: "not-forwarded",
GIT_CONFIG_GLOBAL: "/tmp/hostile-config",
}),
).toEqual({
PATH: "/usr/bin",
HOME: "/home/test",
GIT_TERMINAL_PROMPT: "0",
GIT_CONFIG_NOSYSTEM: "1",
GIT_CONFIG_GLOBAL: "/dev/null",
});
});

test("parses source pins and rejects ambiguous entries", () => {
expect(parsePins(`RigelBuild/meissa=${"b".repeat(40)}`)).toEqual(
new Map([["RigelBuild/meissa", "b".repeat(40)]]),
);
expect(() => parsePins("RigelBuild/meissa=bad")).toThrow("invalid pin");
expect(() =>
parsePins(
`RigelBuild/meissa=${"b".repeat(40)},RigelBuild/meissa=${"c".repeat(40)}`,
),
).toThrow("duplicate pin");
});

test("rejects dot-named repositories in pins and source lists", () => {
for (const repo of [
"RigelBuild/.",
"RigelBuild/..",
"RigelBuild/.hidden",
]) {
expect(() => parsePins(`${repo}=${"b".repeat(40)}`)).toThrow(
"invalid pin",
);
expect(isSource({ repo, mount: "tool", config: "default" })).toBe(false);
}
expect(
isSource({
repo: "RigelBuild/jj-vine",
mount: "/jj-vine/",
config: "default",
}),
).toBe(true);
});
});
Loading
Loading