mirror of
https://github.com/coder/coder.git
synced 2026-12-06 15:19:28 +08:00
4a60d186f890df0671e8cc93873da4ff0db0cb6d
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
d7612d5f1c |
refactor: move docs sidebar files next to the pages they order (#32637)
Closes DOCS-1155. Replaces `docs/manifest/` with one `sidebar.yml` in each docs folder, next to the pages it orders. `docs/manifest.json` is byte-identical before and after (checked after running biome on the compiled output). - Entries name pages and subfolders relative to their own folder, so moving a folder carries its sidebar with it. - `- folder: users` replaces `include` and `children_from`. A bare folder entry loads that folder's `sidebar.yml`. A folder entry with other keys takes its children from the `sidebar.yml` a generator writes there, and its children are metadata overlays. - `clidocgen` and `apidocgen` write `docs/reference/cli/sidebar.yml` and `docs/reference/api/sidebar.yml`, replacing `docs/manifest/generated/`. The `-manifest-only` flag is gone, since the CLI sidebar now comes out with the pages. - `make lint/docs-manifest` fails when a folder has pages but no `sidebar.yml`, when a `sidebar.yml` omits a page in its folder, and when a `sidebar.yml` is unreferenced. - The Makefile, `.gitattributes`, and the CI `docs-gen` filter follow the move. `docsgenfiltercheck` accepts `dir/**/file` patterns so the filter can say `docs/**/sidebar.yml`. - Contributor guidance, the style guides, and the doc skills describe the new layout. **File name.** `sidebar.yml` is not Markdown or `manifest.json`, so the `docs/**/*.md` selectors (coder.com, the `.md` proxy, `llms.txt`, markdownlint, docs-preview) do not pick it up. I checked this in the repository only. I did not check the coder.com or docs-engine repos. **Exempt pages.** The new page check skips `docs/AGENTS.md`, `admin/integrations/opentofu.md`, and `templates/extending-templates/external-auth.md`, which are in no sidebar today, and `install/validate/scale-coder.md`, which another folder's sidebar lists. The list is in `scripts/docsmanifestgen/pages.go`. Drafts (DOCS-1153) and DOCS-1154 should remove it. **Not verified.** I did not run `make gen` end to end, because the REST API step needs widdershins. I ran `clidocgen` into a temp directory and confirmed its sidebar matches the committed one. Unit tests cover the REST API path logic. CI runs `make gen` and will check the rest. <details> <summary>Implementation plan and decisions</summary> 1. Add `Route.Folder` and `SidebarFile` to `docgenenv`. The root `docs/sidebar.yml` holds `versions` and `routes`. 2. Resolve each file's paths against its own folder when loading, and keep each path's spelling (`./x.md` or `x.md`) so the compiled manifest stays byte-identical. 3. Generators write the sidebar inside the folder they generate. 4. Convert the 50 source files and two generated fragments mechanically with a script, then verify the compiled manifest against the old one. 5. Add the page-coverage lint. A parent page may sit beside its folder (`migrate.md` and `migrate/`). 6. Update the Makefile, CI filter, `.gitattributes`, and docs. `templates/startup-coordination` is the one folder that still sits outside its parent. `templates/extending-templates/sidebar.yml` lists it as `folder: ../startup-coordination`, and DOCS-1154 can move it. </details> Generated by Coder Agents on behalf of @nickvigilante. |
||
|
|
bcedc5d47e |
fix(scripts/docsgenfiltercheck): accept CRLF line endings in banner check (#30476)
`bodyOpensWithContentBanner` split pages on `\n` and compared lines exactly. On a Windows checkout with CRLF endings, the first line of `docs/reference/cli/index.md` is `---\r`, so the front matter was never recognized and `TestBodyOpensWithContentBanner` failed deterministically on `test-go-pg (windows-2022)`. Normalize CRLF to LF before parsing, and add CRLF table cases so the bug reproduces on Linux too. Fixes CLI-55. Failing run: https://github.com/coder/coder/actions/runs/37570448753 ## Testing - The new CRLF cases failed before the fix and pass after it. - `go test ./scripts/docsgenfiltercheck`, `GOOS=windows go vet`, `golangci-lint`, and the full pre-commit hook pass. <details> <summary>CI flake note</summary> The first `fmt` run failed while downloading Go modules (`proxy.golang.org` returned `stream error: ... INTERNAL_ERROR` for `testcontainers-go@v0.40.0`), which also failed `required`. This is a network error unrelated to the change. I re-ran the failed jobs. </details> --- _This PR was generated by Coder Agents on behalf of @nickvigilante._ |
||
|
|
b9c0853473 |
ci: skip the gen job for docs-only PRs that cannot change its output (#30164)
The CI `gen` job ran `make -j -B gen` on every PR, so a docs-only PR
spent about 160 seconds of an 8-core runner (12 recent runs: 154 to 170
seconds) confirming that nothing changed.
This PR skips the job for docs-only PRs that touch none of the docs
paths `make gen` reads or rewrites.
Replaying every commit on `main` since 2026-08-01 through the new
filter, 96 of 116 docs-only commits (83%) would skip.
- A new `docs-gen` paths filter lists `docs/manifest.json`,
`docs/reference/api/**`, `docs/reference/cli/**`, and the three
generated admin pages.
`gen` now needs `changes` and runs unless the PR is docs-only with no
`docs-gen` or workflow match.
Push, release-branch `create`, and `workflow_dispatch` runs always
regenerate. Non-release `create` events now skip `gen`, like every other
job that needs `changes`.
- `lint/docs-gen-filter` (`scripts/docsgenfiltercheck`, run by `make
lint`) treats as generated every file in `GEN_FILES`, plus every tracked
Markdown page whose body opens with the shared
`docgenenv.GeneratedContentBanner`. It fails when a generated file
matches the `docs` filter but not `docs-gen`, or when a `docs-gen`
pattern matches no tracked file.
This keeps the filter from drifting when someone adds a generator.
## Why skipping is safe
- No generator reads docs prose. Makefile rules and generators only
touch `docs/manifest.json` and the generated pages under `docs/`;
`examplegen` embeds only `examples/templates`, and no golden-file test
reads `docs/`.
- `dorny/paths-filter` matches a renamed file on both its old and new
paths (`src/main.ts` at the pinned SHA), so moving a generated page out
of `docs/reference/cli/` still runs `gen`.
- If `changes` fails, `gen` is skipped and `required` fails on the
`changes` result, so a failed classification never counts as an
exemption.
Docs-only PRs that edit `docs/manifest.json` (usually a new page) or a
generated page still run the full job, because the generators rewrite
those files.
DOCS-1142 tracks a lighter path for those PRs and for fresh-worktree
rebuilds: render the docs from the committed `swagger.json` and sidebar
fragments instead of running swag or building the CLI.
That work depends on DOCS-1131, which rewrites the same Makefile rules.
Refs DOCS-1141
<details>
<summary>Measurements, options considered, and validation</summary>
**Local profile (not changed by this PR).**
In a warm worktree, editing a docs page or `manifest.json` and running
`make -j gen` rebuilds nothing (0.9 seconds).
In a fresh worktree with a warm Go cache on 12 cores, `make -j
docs/manifest.json` took 40 seconds and `make -j gen` took 46 seconds.
The time went to `_gen/bin/clidocgen` (26 seconds), swag in
`coderd/apidoc/.gen` (18 seconds), and the database codegen chain, which
needs PostgreSQL.
Checkout mtimes are arbitrary and `coderd/apidoc/.gen` is untracked, so
all of that reruns once.
`clidocgen` runs twice per `make gen`, but each run takes about 1
second, so merging the runs isn't worth it.
**Options considered.**
1. Skip `gen` by path for docs-only PRs (this PR). Low risk, independent
of DOCS-1131.
2. A light CI job that runs only the docs generators, skipping heavy
prerequisites with `make -o`. Rejected: CI would keep a second
dependency list that can drift from the Makefile.
3. Content-hash stamps for swag. A committed stamp would conflict on
nearly every backend PR, and an untracked one doesn't help fresh
worktrees. Deferred to DOCS-1142.
4. Split swag from the API Markdown rendering now. It conflicts with
DOCS-1131. Deferred to DOCS-1142.
**Filter validation** (the workflow's own filters with `picomatch@2`,
`dot: true`, the matcher `paths-filter` uses):
| Change | `gen` |
| --- | --- |
| Prose page, image, root `README.md`, style guide, `.claude/docs` |
skips |
| New page plus `docs/manifest.json` | runs |
| Edit, delete, or rename out of `docs/reference/cli/**` or
`docs/reference/api/**` | runs |
| Audit log, Prometheus, or configuration reference page | runs |
| Mixed code and docs, `Makefile`, generator script, `offlinedocs` |
runs |
| Workflow change | runs |
| Docs-only `push`, release `create`, `workflow_dispatch` | runs |
Running `make lint/docs-gen-filter` against edited copies of the
workflow fails, as it should, in each of these cases:
`docs/reference/cli/**` narrowed to `docs/reference/cli/*.md` (137
nested pages), `docs/reference/api/**` narrowed to `*.json` (31 pages
plus the stale pattern), the configuration reference entry removed, a
mistyped admin page path, and the unsupported patterns
`docs/reference/**.md` and `docs/reference/*/**`.
</details>
<details>
<summary>CI flake unrelated to this PR</summary>
`test-js` failed once, on the second push, in
`src/pages/AISettingsPage/SpendPage/SpendPage.test.tsx` ("applies and
clears the 'provider_name' filter and resets pagination"). The same test
failed on `main` in run 36649227804. This PR changes nothing under
`site/`, and `test-js` passed on every later push.
</details>
---
_Generated by Coder Agents on behalf of @nickvigilante._
<details>
<summary>CI flake note</summary>
`test-go-pg (ubuntu-latest)` failed once on `ff25eba` because the runner
ran out of disk (`No space left on device`) before the tests reported
results.
This PR doesn't change Go code under test. The rerun passed.
</details>
|