-
Notifications
You must be signed in to change notification settings - Fork 555
Feat/1759 doc codeblocks ci #1884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bogwi
wants to merge
11
commits into
dimensionalOS:dev
Choose a base branch
from
bogwi:feat/1759-doc-codeblocks-ci
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
083666e
Add doc codeblocks CI workflow and bin runner
bogwi 0e04985
Fix documentation code blocks for md-babel-py CI and update doc-codeb…
bogwi e380bbc
Align doc-codeblocks workflow pins with repo and fix docs for pre-com…
bogwi 4fd987f
Doc codeblocks CI uses ros-dev image; skip CUDA or flaky md-babel blocks
bogwi fbd9c97
Skip LFS and replay-heavy doc codeblocks for md-babel CI
bogwi 5b3d926
Doc codeblocks workflow: checkout PR head for git-auto-commit
bogwi addb6c9
Skip heavy get_data replay and pointcloud doc blocks for CI timeouts
bogwi 0707499
bump md-babel-py==1.1.4 to support new --execution-timeout cli flag; …
bogwi 30a12a3
allign with what
bogwi 7731590
supress push for now; fail if block fails
bogwi d4bb976
add --no-cache, CI now always re-executes covered blocks
bogwi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # Issue #1759 - execute documentation code blocks in CI (md-babel-py). | ||
| # | ||
| # Policy (matches issue author): | ||
| # - Behavior and fence flags (`skip`, `expected-error`, sessions, etc.) follow | ||
| # docs/agents/docs/codeblocks.md. | ||
| # - If a block is broken and the fix is not obvious, contributors may mark the | ||
| # fence with `skip` (or `expected-error` where appropriate) and fix later; | ||
| # until then, this job fails on execution errors so drift is visible. | ||
| # - For now this job only verifies that covered code blocks execute in CI. | ||
| # A follow-up can re-enable auto-committing refreshed <!--Result:--> / | ||
| # generated assets back onto the PR branch. | ||
| name: doc-codeblocks | ||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened, ready_for_review] | ||
| paths: | ||
| - 'docs/**' | ||
| - 'README.md' | ||
| - 'bin/run-doc-codeblocks' | ||
| - '.github/workflows/doc-codeblocks.yml' | ||
| - 'pyproject.toml' | ||
| - 'uv.lock' | ||
|
|
||
| permissions: | ||
| contents: read | ||
| packages: read | ||
| pull-requests: read | ||
|
|
||
| jobs: | ||
| md-babel: | ||
| if: github.event_name != 'pull_request' || github.event.pull_request.draft == false | ||
| timeout-minutes: 60 | ||
| runs-on: [self-hosted, Linux] | ||
| container: | ||
| image: ghcr.io/dimensionalos/ros-dev:dev | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| fetch-depth: 0 | ||
| clean: false | ||
| ref: ${{ github.event.pull_request.head.sha }} | ||
| repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
| token: ${{ github.token }} | ||
|
|
||
| - name: Fix permissions | ||
| run: | | ||
| git config --global --add safe.directory '*' | ||
| git clean -ffdx -e .venv | ||
|
|
||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '22' | ||
|
|
||
| - name: Install Python dependencies | ||
| run: | | ||
| uv sync --all-extras --no-extra dds --frozen | ||
| uv pip install matplotlib httpx | ||
|
|
||
| - name: Remove pydrake stubs | ||
| run: | | ||
| find .venv/lib/*/site-packages/pydrake -name '*.pyi' -delete 2>/dev/null || true | ||
|
|
||
| - name: Execute documentation code blocks | ||
| run: ./bin/run-doc-codeblocks --ci --no-cache | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| #!/usr/bin/env bash | ||
| # Execute md-babel-py on Markdown documentation (see docs/agents/docs/codeblocks.md). | ||
| # CI uses --ci (python, shell, Node only) so native diagram toolchains are not required on runners. | ||
| set -euo pipefail | ||
|
|
||
| REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" | ||
| cd "$REPO_ROOT" | ||
|
|
||
| LANG_FILTER="python,sh,node" | ||
| # md-babel-py 1.1.4+: isolated block subprocess limit (default upstream is 60). | ||
| USE_CACHE=1 | ||
| declare -a USER_PATHS=() | ||
|
|
||
| usage() { | ||
| cat >&2 <<'EOF' | ||
| Usage: bin/run-doc-codeblocks [options] [path ...] | ||
|
|
||
| --ci Same as --lang python,sh,node (default; for CI runners). | ||
|
bogwi marked this conversation as resolved.
|
||
| --lang LIST Comma-separated languages for md-babel-py (default: python,sh,node). | ||
| --all-langs Run all block languages (requires local native tools; see codeblocks.md). | ||
| --no-cache Re-execute all blocks instead of reusing md-babel cache. | ||
|
|
||
| With no paths: runs on ./docs (recursive) and ./README.md when present. | ||
|
|
||
| Examples: | ||
| bin/run-doc-codeblocks --ci | ||
| bin/run-doc-codeblocks --all-langs docs/agents/docs/index.md | ||
| EOF | ||
| } | ||
|
|
||
| while [[ $# -gt 0 ]]; do | ||
| case "$1" in | ||
| -h | --help) | ||
| usage | ||
| exit 0 | ||
| ;; | ||
| --ci) | ||
| LANG_FILTER="python,sh,node" | ||
| shift | ||
| ;; | ||
| --lang) | ||
| LANG_FILTER="${2:?--lang requires a value}" | ||
| shift 2 | ||
| ;; | ||
| --all-langs) | ||
| LANG_FILTER="" | ||
| shift | ||
| ;; | ||
| --no-cache) | ||
| USE_CACHE=0 | ||
| shift | ||
| ;; | ||
| -*) | ||
| echo "Unknown option: $1" >&2 | ||
| usage | ||
| exit 2 | ||
| ;; | ||
| *) | ||
| USER_PATHS+=("$1") | ||
| shift | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| resolve_md_babel() { | ||
| # Prefer project env so md-babel-py version matches pyproject (needs >= 1.1.4 for --execution-timeout). | ||
| if command -v uv &>/dev/null && [[ -f pyproject.toml ]]; then | ||
| MB=(uv run md-babel-py) | ||
| elif [[ -x .venv/bin/md-babel-py ]]; then | ||
| MB=(.venv/bin/md-babel-py) | ||
| elif [[ -x .venv/bin/python ]]; then | ||
| MB=(.venv/bin/python -m md_babel_py.cli) | ||
| elif command -v md-babel-py &>/dev/null; then | ||
| MB=(md-babel-py) | ||
| else | ||
| echo "Error: md-babel-py not found. Install project deps (e.g. uv sync --extra dev or uv sync --all-extras)." >&2 | ||
| exit 1 | ||
| fi | ||
| } | ||
|
|
||
| resolve_md_babel | ||
|
|
||
| run_one_target() { | ||
| local target=$1 | ||
| local -a cmd=("${MB[@]}" run --execution-timeout 120) | ||
| if [[ "$USE_CACHE" -eq 0 ]]; then | ||
| cmd+=(--no-cache) | ||
| fi | ||
| if [[ -n "$LANG_FILTER" ]]; then | ||
| cmd+=(--lang "$LANG_FILTER") | ||
| fi | ||
| if [[ -d "$target" ]]; then | ||
| cmd+=("$target" --recursive) | ||
| else | ||
| cmd+=("$target") | ||
| fi | ||
| "${cmd[@]}" | ||
| } | ||
|
|
||
| if [[ ${#USER_PATHS[@]} -gt 0 ]]; then | ||
| for p in "${USER_PATHS[@]}"; do | ||
| if [[ -d "$p" ]] || [[ -f "$p" ]]; then | ||
| run_one_target "$p" | ||
| else | ||
| echo "Error: not a file or directory: $p" >&2 | ||
| exit 1 | ||
| fi | ||
| done | ||
| else | ||
| run_one_target ./docs | ||
| run_one_target README.md | ||
| fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.