Skip to content

Commit 25967c1

Browse files
committed
feat(docs): publish rule docs with github pages
1 parent 3d17a40 commit 25967c1

21 files changed

Lines changed: 560 additions & 0 deletions

.github/workflows/docs.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "docs/**"
9+
- "mkdocs.yml"
10+
- ".github/workflows/docs.yml"
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
concurrency:
19+
group: "pages"
20+
cancel-in-progress: false
21+
22+
jobs:
23+
build:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
- name: Setup Python
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: "3.12"
33+
34+
- name: Install MkDocs
35+
run: python -m pip install --upgrade pip mkdocs
36+
37+
- name: Build docs site
38+
run: mkdocs build --strict
39+
40+
- name: Upload pages artifact
41+
uses: actions/upload-pages-artifact@v3
42+
with:
43+
path: site
44+
45+
deploy:
46+
environment:
47+
name: github-pages
48+
url: ${{ steps.deployment.outputs.page_url }}
49+
needs: build
50+
runs-on: ubuntu-latest
51+
steps:
52+
- name: Deploy to GitHub Pages
53+
id: deployment
54+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
site/

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@
2727
- 2026-02-26: Formalized stable JSON envelope contract with `schemaVersion` and always-present `errors` array.
2828
- 2026-02-26: Doctor UX now includes attempt trail, resolved backend details, paste-ready config snippet, and remediation guidance.
2929
- 2026-02-26: Minimum required Go version is Go 1.26 for local builds and CI/release workflows.
30+
- 2026-03-02: Documentation is published via MkDocs + GitHub Pages workflow (`.github/workflows/docs.yml`) with custom domain `docs.buildgraph.dev`.

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ All machine-readable command output uses a versioned envelope:
8686
}
8787
```
8888

89+
## Rule Documentation
90+
91+
Rule pages backing finding links are tracked in this repository:
92+
93+
- [Rules Index](./docs/rules/index.md)
94+
95+
Docs are published from `docs/` using the GitHub Actions workflow:
96+
97+
- [docs.yml](./.github/workflows/docs.yml)
98+
8999
## What Data Is Collected
90100

91101
`buildgraph` stores local state in a SQLite database to support diagnostics and history:

docs/CNAME

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docs.buildgraph.dev

docs/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Buildgraph Documentation
2+
3+
This directory contains the source content for the public documentation URLs used by `buildgraph` findings.
4+
5+
## Rules
6+
7+
- [Rules Index](./rules/index.md)
8+
9+
Each rule page is named after its rule ID, for example:
10+
- `docs/rules/BG_REPRO_FROM_MUTABLE.md`
11+
- `docs/rules/BG_SEC_ROOT_USER.md`
12+
13+
These pages are designed to map directly to public URLs under:
14+
- `https://docs.buildgraph.dev/rules/<RULE_ID>`

docs/index.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Buildgraph Documentation
2+
3+
Buildgraph publishes rule-level guidance for findings reported by `buildgraph analyze`.
4+
5+
## Primary Sections
6+
7+
- [Rules Overview](./rules/index.md)
8+
9+
## Public Rule URLs
10+
11+
Finding links are designed to resolve under:
12+
13+
- `https://docs.buildgraph.dev/rules/<RULE_ID>`
14+
15+
Examples:
16+
17+
- `https://docs.buildgraph.dev/rules/BG_REPRO_FROM_MUTABLE`
18+
- `https://docs.buildgraph.dev/rules/BG_SEC_ROOT_USER`

docs/rules/BG_CACHE_ARG_LATE.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# BG_CACHE_ARG_LATE
2+
3+
- Dimension: `cacheability`
4+
- Severity: `medium`
5+
6+
## Summary
7+
8+
`ARG` values are declared late, after expensive build steps.
9+
10+
## Why It Matters
11+
12+
Changing late `ARG` values can invalidate large portions of the build graph.
13+
14+
## Typical Trigger
15+
16+
```dockerfile
17+
RUN make deps
18+
ARG APP_VERSION
19+
RUN make build
20+
```
21+
22+
## Recommended Fix
23+
24+
Declare stable `ARG` values before expensive operations.
25+
26+
```dockerfile
27+
ARG APP_VERSION
28+
RUN make deps
29+
RUN make build
30+
```
31+
32+
## Remediation Checklist
33+
34+
- Move stable args earlier.
35+
- Keep volatile args scoped only where needed.
36+
- Re-check cache hit rate in CI.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# BG_CACHE_COPY_ALL_EARLY
2+
3+
- Dimension: `cacheability`
4+
- Severity: `high`
5+
6+
## Summary
7+
8+
A broad `COPY .` happens before dependency install steps.
9+
10+
## Why It Matters
11+
12+
Any source file change invalidates dependency cache and forces expensive reinstall/build steps.
13+
14+
## Typical Trigger
15+
16+
```dockerfile
17+
COPY . .
18+
RUN npm ci
19+
```
20+
21+
## Recommended Fix
22+
23+
Copy dependency manifests first, install dependencies, then copy the remaining source.
24+
25+
```dockerfile
26+
COPY package.json package-lock.json ./
27+
RUN npm ci
28+
COPY . .
29+
```
30+
31+
## Remediation Checklist
32+
33+
- Move lockfiles/manifests before install steps.
34+
- Keep app source copy after dependency restore.
35+
- Add `.dockerignore` to reduce noisy context changes.

docs/rules/BG_PERF_APT_SPLIT.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# BG_PERF_APT_SPLIT
2+
3+
- Dimension: `performance`
4+
- Severity: `medium`
5+
6+
## Summary
7+
8+
`apt-get update` is executed without an install in the same layer.
9+
10+
## Why It Matters
11+
12+
Splitting update and install into separate layers increases rebuild time and can use stale package indexes.
13+
14+
## Typical Trigger
15+
16+
```dockerfile
17+
RUN apt-get update
18+
RUN apt-get install -y curl
19+
```
20+
21+
## Recommended Fix
22+
23+
Combine update and install in one instruction and clear apt lists:
24+
25+
```dockerfile
26+
RUN apt-get update \
27+
&& apt-get install -y --no-install-recommends curl \
28+
&& rm -rf /var/lib/apt/lists/*
29+
```
30+
31+
## Remediation Checklist
32+
33+
- Merge `apt-get update` with related install commands.
34+
- Add `--no-install-recommends` where possible.
35+
- Remove apt cache in the same layer.

0 commit comments

Comments
 (0)