From 56eadd57a35d2a3486260cb85832f00c8152b6ff Mon Sep 17 00:00:00 2001 From: Rhuan Barreto Date: Thu, 12 Nov 2026 14:36:13 +0100 Subject: [PATCH 1/2] ci: build the docs in the Validate Code gate when docs change The Cloudflare Pages check is not required, so a docs lockfile refresh merged with a failing build and broke cli.archgate.dev for two days. The Validate workflow now runs the Cloudflare build command whenever a change touches docs/ or the workflow, and the Validate Code gate requires it. CLI-only changes skip the job. GEN-001 records the gate. Signed-off-by: Rhuan Barreto --- .archgate/adrs/GEN-001-documentation-site.md | 10 +-- .github/workflows/code-pull-request.yml | 66 +++++++++++++++++++- 2 files changed, 71 insertions(+), 5 deletions(-) diff --git a/.archgate/adrs/GEN-001-documentation-site.md b/.archgate/adrs/GEN-001-documentation-site.md index 4bd4459a..d7565bbc 100644 --- a/.archgate/adrs/GEN-001-documentation-site.md +++ b/.archgate/adrs/GEN-001-documentation-site.md @@ -25,7 +25,9 @@ Starlight is the natural choice for Archgate: it aligns with the Bun-first toolc ## Decision -The documentation site MUST be an Astro 5 / Starlight project in the `docs/` directory. The docs site is a **separate concern** from the CLI codebase — it has its own `package.json`, `tsconfig.json`, `bun.lock`, and build pipeline. It does NOT participate in the CLI's `bun run validate` pipeline. Deployment is handled externally via Cloudflare Pages and is not managed by this repository. +The documentation site MUST be an Astro 5 / Starlight project in the `docs/` directory. The docs site is a **separate concern** from the CLI codebase — it has its own `package.json`, `tsconfig.json`, `bun.lock`, and build pipeline. It does NOT participate in the CLI's `bun run validate` script. Deployment is handled externally via Cloudflare Pages and is not managed by this repository. + +**CI gate:** the `Docs Build` job in the Validate workflow runs the Cloudflare Pages build (`bun run build` in `docs/`) whenever a change touches `docs/` or that workflow, and `Validate Code` requires it. CLI-only changes skip it. **Scope:** the site's structure, tooling, and content organization. NOT the content itself (what to document) — that is editorial, not architectural. @@ -65,9 +67,9 @@ Every content page MUST appear both in the file system (`docs/src/content/docs/< ### Don't -- **DON'T** add the docs build to the CLI `validate` pipeline — docs build failures MUST NOT block CLI development or CI +- **DON'T** add the docs build to `bun run validate` — docs failures MUST NOT block CLI-only changes or the offline pre-push hook +- **DON'T** drop `Docs Build` from the `Validate Code` gate, narrow its trigger below `docs/`, or let its commands drift from the Cloudflare Pages build - **DON'T** share `tsconfig.json` with the CLI project — docs use `astro/tsconfigs/strict`, the CLI its own -- **DON'T** use bare `{}` in MDX content — always escape as `\{\}` for literal curly braces in prose or code fence labels - **DON'T** add CLI source dependencies (`@commander-js/extra-typings`, `zod`, `@modelcontextprotocol/sdk`, `inquirer`) to `docs/package.json` - **DON'T** create content files outside `docs/src/content/docs/` — `docsLoader()` expects exactly this directory structure - **DON'T** use auto-generated content collections — Astro 5 requires an explicit `docs/src/content.config.ts` with `docsLoader()` and `docsSchema()` @@ -167,7 +169,7 @@ Code reviewers MUST verify during docs PRs: 3. Curly braces in prose are escaped (`\{\}`) when showing template syntax 4. Reference pages are updated when the corresponding CLI API changes 5. No CLI source dependencies are added to `docs/package.json` -6. The docs build succeeds locally (`bun run docs:build`) before merging +6. The `Docs Build` job in the Validate workflow passed on the pull request ## References diff --git a/.github/workflows/code-pull-request.yml b/.github/workflows/code-pull-request.yml index 8142f03e..2a267a9e 100644 --- a/.github/workflows/code-pull-request.yml +++ b/.github/workflows/code-pull-request.yml @@ -224,6 +224,63 @@ jobs: echo "Generated winget artifacts:" ls -la dist/winget + docs-changes: + name: Detect Docs Changes + runs-on: ubuntu-latest + if: github.event_name != 'pull_request' || github.event.pull_request.draft == false + outputs: + docs_changed: ${{ steps.changes.outputs.docs_changed }} + steps: + - name: Checkout code + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + persist-credentials: false + - name: Check for docs changes + id: changes + env: + # Passed via env, not inlined into the script, to avoid template-injection + # (zizmor: code injection via template expansion). + BASE_REF: ${{ github.base_ref }} + EVENT_NAME: ${{ github.event_name }} + run: | + # This workflow file is included so a change to the docs-build job + # runs the job it changes (GEN-001). + PATHS=(docs/ .github/workflows/code-pull-request.yml) + if [ "$EVENT_NAME" = "pull_request" ]; then + CHANGED=$(git diff --name-only "origin/$BASE_REF...HEAD" -- "${PATHS[@]}" || true) + elif [ "$EVENT_NAME" = "push" ]; then + CHANGED=$(git diff --name-only HEAD~1 -- "${PATHS[@]}" || true) + else + CHANGED=all + fi + if [ -n "$CHANGED" ]; then + echo "docs_changed=true" >> "$GITHUB_OUTPUT" + else + echo "docs_changed=false" >> "$GITHUB_OUTPUT" + fi + + # Builds the docs with the same commands Cloudflare Pages runs, so a change + # that would break the cli.archgate.dev deploy cannot merge (GEN-001). + docs-build: + name: Docs Build + runs-on: ubuntu-latest + timeout-minutes: 10 + needs: docs-changes + if: needs.docs-changes.outputs.docs_changed == 'true' + steps: + - name: Checkout code + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: $/.github/actions/setup-bun-project + - name: Install docs dependencies + working-directory: docs + run: bun install --frozen-lockfile + - name: Build docs + working-directory: docs + run: bun run build + smoke-windows: name: Smoke Test (Windows) if: github.event_name != 'pull_request' || github.event.pull_request.draft == false @@ -405,6 +462,8 @@ jobs: validate, shim-changes, shim-tests, + docs-changes, + docs-build, smoke-windows, smoke-linux, zizmor, @@ -418,9 +477,13 @@ jobs: # shim-tests is skipped when no shim files changed — treat skipped as success. SHIM_OK="${{ needs.shim-tests.result }}" if [[ "$SHIM_OK" == "skipped" ]]; then SHIM_OK="success"; fi + # docs-build is skipped when nothing under docs/ changed. A skip is only + # a pass when docs-changes itself succeeded and found no change. + DOCS_OK="${{ needs.docs-build.result }}" + if [[ "$DOCS_OK" == "skipped" && "${{ needs.docs-changes.result }}" == "success" && "${{ needs.docs-changes.outputs.docs_changed }}" == "false" ]]; then DOCS_OK="success"; fi if [[ "${{ needs.validate.result }}" != "success" ]] || \ - [[ "$SHIM_OK" != "success" ]] || \ + [[ "$SHIM_OK" != "success" ]] || [[ "$DOCS_OK" != "success" ]] || \ [[ "${{ needs.smoke-windows.result }}" != "success" ]] || \ [[ "${{ needs.smoke-linux.result }}" != "success" ]] || \ [[ "${{ needs.zizmor.result }}" != "success" ]] || \ @@ -430,6 +493,7 @@ jobs: echo "::error::One or more jobs failed:" echo " validate: ${{ needs.validate.result }}" echo " shim-tests: ${{ needs.shim-tests.result }}" + echo " docs-build: ${{ needs.docs-build.result }}" echo " smoke-windows: ${{ needs.smoke-windows.result }}" echo " smoke-linux: ${{ needs.smoke-linux.result }}" echo " zizmor: ${{ needs.zizmor.result }}" From 7f07cf94730aa4d455c6d5fa3e369754fb501da2 Mon Sep 17 00:00:00 2001 From: Rhuan Barreto Date: Thu, 12 Nov 2026 16:14:17 +0100 Subject: [PATCH 2/2] ci: build the docs whenever the change detection cannot rule them out A push is compared from its before SHA, so every commit in it counts, and a missing base or a failed diff builds the docs instead of skipping them. The gate reads the docs job results through env. Signed-off-by: Rhuan Barreto --- .github/workflows/code-pull-request.yml | 30 ++++++++++++++++--------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/.github/workflows/code-pull-request.yml b/.github/workflows/code-pull-request.yml index 2a267a9e..33da1b40 100644 --- a/.github/workflows/code-pull-request.yml +++ b/.github/workflows/code-pull-request.yml @@ -242,23 +242,25 @@ jobs: # Passed via env, not inlined into the script, to avoid template-injection # (zizmor: code injection via template expansion). BASE_REF: ${{ github.base_ref }} + BEFORE: ${{ github.event.before }} EVENT_NAME: ${{ github.event_name }} run: | # This workflow file is included so a change to the docs-build job # runs the job it changes (GEN-001). PATHS=(docs/ .github/workflows/code-pull-request.yml) + RANGE="" if [ "$EVENT_NAME" = "pull_request" ]; then - CHANGED=$(git diff --name-only "origin/$BASE_REF...HEAD" -- "${PATHS[@]}" || true) - elif [ "$EVENT_NAME" = "push" ]; then - CHANGED=$(git diff --name-only HEAD~1 -- "${PATHS[@]}" || true) - else - CHANGED=all + RANGE="origin/$BASE_REF...HEAD" + elif [ "$EVENT_NAME" = "push" ] && [ -n "$BEFORE" ] && [ "$BEFORE" != "0000000000000000000000000000000000000000" ]; then + RANGE="$BEFORE..HEAD" fi - if [ -n "$CHANGED" ]; then - echo "docs_changed=true" >> "$GITHUB_OUTPUT" - else - echo "docs_changed=false" >> "$GITHUB_OUTPUT" + # Without a range, or when the diff fails, the docs are built: only a + # successful comparison can establish that no docs changed. + DOCS_CHANGED=true + if [ -n "$RANGE" ] && CHANGED=$(git diff --name-only "$RANGE" -- "${PATHS[@]}"); then + if [ -z "$CHANGED" ]; then DOCS_CHANGED=false; fi fi + echo "docs_changed=$DOCS_CHANGED" >> "$GITHUB_OUTPUT" # Builds the docs with the same commands Cloudflare Pages runs, so a change # that would break the cli.archgate.dev deploy cannot merge (GEN-001). @@ -473,14 +475,20 @@ jobs: ] steps: - name: Check job results + env: + # Passed via env, not inlined into the script, to avoid template-injection + # (zizmor: code injection via template expansion). + DOCS_BUILD_RESULT: ${{ needs.docs-build.result }} + DOCS_CHANGES_RESULT: ${{ needs.docs-changes.result }} + DOCS_CHANGED: ${{ needs.docs-changes.outputs.docs_changed }} run: | # shim-tests is skipped when no shim files changed — treat skipped as success. SHIM_OK="${{ needs.shim-tests.result }}" if [[ "$SHIM_OK" == "skipped" ]]; then SHIM_OK="success"; fi # docs-build is skipped when nothing under docs/ changed. A skip is only # a pass when docs-changes itself succeeded and found no change. - DOCS_OK="${{ needs.docs-build.result }}" - if [[ "$DOCS_OK" == "skipped" && "${{ needs.docs-changes.result }}" == "success" && "${{ needs.docs-changes.outputs.docs_changed }}" == "false" ]]; then DOCS_OK="success"; fi + DOCS_OK="$DOCS_BUILD_RESULT" + if [[ "$DOCS_OK" == "skipped" && "$DOCS_CHANGES_RESULT" == "success" && "$DOCS_CHANGED" == "false" ]]; then DOCS_OK="success"; fi if [[ "${{ needs.validate.result }}" != "success" ]] || \ [[ "$SHIM_OK" != "success" ]] || [[ "$DOCS_OK" != "success" ]] || \