Skip to content

Commit 2296e0b

Browse files
bloxsterGianniCopilot
authored
ci: skip Go jobs and add docs-site build for docs-only PRs (#21045)
## Summary Sibling of #21028 (which lands the same path-filter on `main`'s `ci-gate.yml`). When a PR only touches `docs/`, root `llms*.txt`, or root `*.md`, skip the `linux` and `win` Go test runs (~20-30 min saved per PR) and instead run a docs-site typecheck/build with the llms.txt drift + unittest guard. ### How it works A new fast `changes` job calls `gh api .../pulls/{n}/files` and emits two outputs: - `code` — `false` if every changed file is under `docs/`, root `llms*.txt`, or root `*.md`; otherwise `true`. Defaults to `true` for `push` / `workflow_dispatch` so nothing is skipped on merge. - `docs_site` — `true` when any `docs/site/**` file is touched. `linux` and `win` are gated on `code != 'false'`. A new `docs-site` job (calling the new reusable `docs-site-build.yml`) runs when `docs_site == 'true'`. If the `gh api` call fails, the step exits with code 1 — the gate fails rather than silently defaulting to skipping jobs. ### What runs when | PR scope | linux/win | docs-site | |----------|-----------|-----------| | Pure code (`*.go`, etc.) | ✅ runs | ⏭️ skipped | | Mixed code + docs | ✅ runs | ✅ runs | | Pure docs (`docs/site/**`) | ⏭️ skipped | ✅ runs | | Pure root-level docs (`llms.txt`, `README.md`) | ⏭️ skipped | ⏭️ skipped | | `push` to `main` / `release/**` | ✅ runs | ✅ runs | ### File-pattern logic A PR is **docs-only** (skips Go CI) when every changed file matches: ``` ^(docs/|llms[^/]*\.txt$|[^/]*\.md$) ``` i.e. files under `docs/`, root-level `llms*.txt`, or root-level `*.md`. Nested `.md` files (e.g. `execution/README.md`) still count as code changes. ### `docs-site-build.yml` Reusable `workflow_call` leaf that: 1. Sets up Python 3.11 + runs `python3 docs/site/scripts/generate-llms.py --check` and `python3 -m unittest discover docs/site/scripts -v` (the llms drift guard from #21000) 2. Sets up Node 20 + runs `npm ci`, `npm run typecheck`, `npm run build` against `docs/site/` Has a defensive guard that skips silently if `docs/site/package.json` **or** `docs/site/scripts/generate-llms.py` is absent — covering both fully absent `docs/site/` and partial migration states. ### Files | File | Change | |------|--------| | `.github/workflows/ci.yml` | Add `permissions: pull-requests: read`, `changes` job, gate `linux`/`win` with `code != 'false'`, add `docs-site` job | | `.github/workflows/docs-site-build.yml` | New reusable workflow (Python llms guard + Node typecheck/build) | ## Test plan - [ ] Open a docs-only PR (touch `docs/site/docs/...`) — confirm `linux`/`win` are skipped and `docs-site` runs - [ ] Open a mixed PR (one `.go` file + one `.md` file) — confirm both `linux`/`win` and `docs-site` run - [ ] Open a pure code PR — confirm `docs-site` is skipped, `linux`/`win` run - [ ] Push to `release/3.4` — confirm everything runs (no skipping) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Bloxster <bloxster@proton.me> Co-authored-by: Gianni <gianni@erigon.dev> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 6fdfdb7 commit 2296e0b

2 files changed

Lines changed: 104 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,60 @@ on:
1212
- reopened
1313
- synchronize
1414
- ready_for_review
15-
15+
1616
workflow_dispatch:
1717

18+
permissions:
19+
contents: read
20+
pull-requests: read
21+
1822
jobs:
23+
# Fast path: detect whether any non-docs files changed.
24+
# For push and workflow_dispatch always returns code=true/docs_site=true.
25+
# Jobs guarded by `needs.changes.outputs.code != 'false'` are skipped
26+
# for docs-only PRs, saving 20-30 min of unnecessary Go CI.
27+
changes:
28+
runs-on: ubuntu-latest
29+
outputs:
30+
code: ${{ steps.check.outputs.code }}
31+
docs_site: ${{ steps.check.outputs.docs_site }}
32+
steps:
33+
- id: check
34+
env:
35+
GH_TOKEN: ${{ github.token }}
36+
run: |
37+
if [ "${{ github.event_name }}" != "pull_request" ]; then
38+
echo "code=true" >> "$GITHUB_OUTPUT"
39+
echo "docs_site=true" >> "$GITHUB_OUTPUT"
40+
exit 0
41+
fi
42+
files=$(gh api "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" \
43+
--paginate --jq '.[].filename') \
44+
|| { echo "Failed to fetch PR files from GitHub API"; exit 1; }
45+
# "code" = any file outside: docs/*, root-level llms*.txt, root-level *.md
46+
# (nested *.md like execution/README.md still counts as a code change)
47+
if echo "$files" | grep -qvE '^(docs/|llms[^/]*\.txt$|[^/]*\.md$)'; then
48+
echo "code=true" >> "$GITHUB_OUTPUT"
49+
else
50+
echo "code=false" >> "$GITHUB_OUTPUT"
51+
fi
52+
if echo "$files" | grep -qE '^docs/site/'; then
53+
echo "docs_site=true" >> "$GITHUB_OUTPUT"
54+
else
55+
echo "docs_site=false" >> "$GITHUB_OUTPUT"
56+
fi
57+
1958
linux:
59+
needs: [changes]
2060
concurrency:
2161
group: >-
2262
${{
23-
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')) &&
63+
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')) &&
2464
format('{0}-{1}-{2}', github.workflow, matrix.os, github.run_id) ||
2565
format('{0}-{1}-{2}', github.workflow, matrix.os, github.ref)
2666
}}
2767
cancel-in-progress: true
28-
if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }}
68+
if: ${{ needs.changes.outputs.code != 'false' && (github.event_name == 'push' || !github.event.pull_request.draft) }}
2969
strategy:
3070
matrix:
3171
# list of os: https://github.com/actions/virtual-environments
@@ -84,15 +124,16 @@ jobs:
84124
run: make test-short
85125

86126
win:
127+
needs: [changes]
87128
concurrency:
88129
group: >-
89130
${{
90-
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')) &&
131+
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')) &&
91132
format('{0}-{1}-{2}', github.workflow, matrix.os, github.run_id) ||
92133
format('{0}-{1}-{2}', github.workflow, matrix.os, github.ref)
93134
}}
94135
cancel-in-progress: true
95-
if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }}
136+
if: ${{ needs.changes.outputs.code != 'false' && (github.event_name == 'push' || !github.event.pull_request.draft) }}
96137
strategy:
97138
matrix:
98139
os: [ windows-2025 ]
@@ -124,3 +165,8 @@ jobs:
124165
- name: Execute test-short
125166
shell: bash
126167
run: make test-short
168+
169+
docs-site:
170+
needs: [changes]
171+
if: ${{ needs.changes.outputs.docs_site == 'true' && (github.event_name == 'push' || !github.event.pull_request.draft) }}
172+
uses: ./.github/workflows/docs-site-build.yml
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Docs Site Build
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v6
11+
12+
# Defensive guard — skip silently if docs/site/ is absent (e.g. branches
13+
# that predate the Docusaurus migration) or if the Python scripts aren't
14+
# present yet (partial migration state).
15+
- name: Check docs/site prerequisites are present
16+
id: guard
17+
run: |
18+
if [ -f docs/site/package.json ] && [ -f docs/site/package-lock.json ] && [ -d docs/site/scripts ] && [ -f docs/site/scripts/generate-llms.py ]; then
19+
echo "present=true" >> "$GITHUB_OUTPUT"
20+
else
21+
echo "present=false" >> "$GITHUB_OUTPUT"
22+
echo "docs/site prerequisites not found — skipping build"
23+
fi
24+
25+
- uses: actions/setup-python@v5
26+
if: steps.guard.outputs.present == 'true'
27+
with:
28+
python-version: '3.11'
29+
30+
- name: Verify llms.txt artifacts are up to date
31+
if: steps.guard.outputs.present == 'true'
32+
run: |
33+
python3 docs/site/scripts/generate-llms.py --check
34+
python3 -m unittest discover docs/site/scripts -v
35+
36+
- uses: actions/setup-node@v4
37+
if: steps.guard.outputs.present == 'true'
38+
with:
39+
node-version: '20.x'
40+
cache: npm
41+
cache-dependency-path: docs/site/package-lock.json
42+
43+
- run: npm ci
44+
if: steps.guard.outputs.present == 'true'
45+
working-directory: docs/site
46+
47+
- run: npm run typecheck
48+
if: steps.guard.outputs.present == 'true'
49+
working-directory: docs/site
50+
51+
- run: npm run build
52+
if: steps.guard.outputs.present == 'true'
53+
working-directory: docs/site

0 commit comments

Comments
 (0)