Skip to content

Fail the build when documentation content fails to compile - #122

Merged
guanzhousongmicrosoft merged 1 commit into
documentdb:mainfrom
GuanzhouSong:guard-content-compile
Jul 30, 2026
Merged

Fail the build when documentation content fails to compile#122
guanzhousongmicrosoft merged 1 commit into
documentdb:mainfrom
GuanzhouSong:guard-content-compile

Conversation

@GuanzhouSong

Copy link
Copy Markdown
Contributor

Problem

scripts/compile-content.tsx runs git clone via spawnSync and never checks the exit status. If the documentdb/docs clone fails in CI (network blip, branch rename, repo move), copyFilesRecursive silently finds nothing to copy, the Next.js build succeeds, and the site deploys with empty /docs and /docs/reference sections — a total documentation outage with a green pipeline.

Fix

Three layers, from cause to artifact:

  1. Clone failures fail the build with git's stderr (both spawnSync error and non-zero exit paths). The throw flows into the script's existing error handling, which already exits 1.
  2. Mapping-level checks: a source folder missing from the cloned repo (upstream layout change) or a mapping that matches zero files fails with a pointed message instead of shipping an empty section.
  3. Independent artifact check in the deploy workflow before upload: key pages must exist in out/, and at least 100 reference pages must have been exported — the docs repo currently holds ~240 reference entries (counted via the GitHub tree API), so the floor triggers only on genuine content loss while tolerating growth and reasonable shrinkage.

Also anchors the api-reference/ and reference/ gitignore patterns to the repo root — the unanchored form also matched app/docs/reference/, which breaks pathspecs against tracked files there.

Validation

  • Workflow YAML parsed locally.
  • git check-ignore -v before/after: root reference/foo.md and api-reference/foo.md remain ignored; app/docs/reference/page.tsx is no longer matched by any ignore rule.
  • The happy path (clone succeeds, content copies) is exercised by CI's full build on this PR; the failure paths reuse the script's existing catch → render error → exit 1 plumbing.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XGMeNSmhAgmqzkdc7cQQgf

compile-content.tsx never checked the git clone exit status. A failed
clone of documentdb/docs left the copy loop with nothing to copy, and
the site would build and deploy successfully with empty /docs and
/docs/reference sections - a silent, total documentation outage.

- The clone now fails the build with the git stderr on a non-zero exit.
- A mapping whose source folder is missing from the cloned repository
  (layout change upstream) fails with a pointed message.
- A mapping that matches zero files fails instead of shipping an empty
  section.
- The deploy workflow gains an independent artifact check before
  upload: key pages must exist in out/ and at least 100 reference
  pages must have been exported (the docs repo currently holds ~240
  reference entries).

Also anchors the api-reference/ and reference/ gitignore patterns to
the repo root so they can no longer swallow tracked paths like
app/docs/reference/ (verified with git check-ignore before and after).
@guanzhousongmicrosoft
guanzhousongmicrosoft merged commit fbe24ed into documentdb:main Jul 30, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants