From 3189e774a57f0d2cfd179ca7704328bb6c906274 Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Mon, 16 Nov 2026 02:42:07 +0000 Subject: [PATCH 1/2] ci(docs): build the docs with CARGO_TARGET_DIR outside the checkout sidecar-demo.sh runs the binaries from target/debug under the checkout and build-docs.sh copies the API docs from target/doc, where cargo puts neither when CARGO_TARGET_DIR or a configured target-dir points elsewhere. The demo then runs stale binaries or none: with the target directory outside the checkout, build-docs.sh stops with status 127 at demo_key, the sidecar transcript is emptied and no API docs reach the book. The docs job now builds that way, which fails until the scripts ask cargo where its target directory is. --- .github/workflows/docs.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 6b55ce6..c5c52e9 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -18,6 +18,10 @@ jobs: timeout-minutes: 30 steps: - uses: actions/checkout@v4 + - name: Build outside the checkout + # The doc scripts are to find what cargo built where cargo put it, + # which CARGO_TARGET_DIR or a configured target-dir moves out of target/. + run: echo "CARGO_TARGET_DIR=$RUNNER_TEMP/target" >> "$GITHUB_ENV" - uses: dtolnay/rust-toolchain@master with: toolchain: 1.97.1 From cccf26524cc47805d8bc0ad0d22d7297fca84ad8 Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Mon, 16 Nov 2026 02:42:57 +0000 Subject: [PATCH 2/2] fix(docs): find cargo's target directory through cargo metadata sidecar-demo.sh and build-docs.sh take the target directory from cargo metadata, which resolves CARGO_TARGET_DIR, CARGO_BUILD_TARGET_DIR and a configured build.target-dir the way the builds before them did, as the workflows already read Cargo.toml with python3. The demo runs the binaries regen-doc-output.sh just built and the book gets the API docs cargo doc just wrote. With the target directory outside the checkout the docs job's steps pass and docs/src/output is unchanged, as it is with the default target/. --- changelog.d/+docs-target-dir.misc.md | 2 ++ docs/examples/sidecar-demo.sh | 10 +++++++--- scripts/build-docs.sh | 9 +++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 changelog.d/+docs-target-dir.misc.md diff --git a/changelog.d/+docs-target-dir.misc.md b/changelog.d/+docs-target-dir.misc.md new file mode 100644 index 0000000..1274171 --- /dev/null +++ b/changelog.d/+docs-target-dir.misc.md @@ -0,0 +1,2 @@ +`scripts/build-docs.sh` and `docs/examples/sidecar-demo.sh` ask `cargo metadata` for the target directory, so the book's transcripts and API docs come from the builds cargo just made when `CARGO_TARGET_DIR` or a configured target-dir moves them out of `target/`. +They read `target/` under the checkout, and ran stale binaries or none; the docs workflow now builds outside the checkout. diff --git a/docs/examples/sidecar-demo.sh b/docs/examples/sidecar-demo.sh index b3adbcf..dd3255f 100755 --- a/docs/examples/sidecar-demo.sh +++ b/docs/examples/sidecar-demo.sh @@ -3,9 +3,13 @@ set -euo pipefail root=$(cd "$(dirname "$0")/../.." && pwd) -sidecar="$root/target/debug/rfc9162-sidecar" -demo_key="$root/target/debug/demo_key" -show="$root/target/debug/show_checkpoint" +# Wherever cargo puts its builds: CARGO_TARGET_DIR or a configured +# target-dir moves them out of target/. +target=$(cd "$root" && cargo metadata --locked --format-version 1 --no-deps | + python3 -c 'import json, sys; print(json.load(sys.stdin)["target_directory"])') +sidecar="$target/debug/rfc9162-sidecar" +demo_key="$target/debug/demo_key" +show="$target/debug/show_checkpoint" work=$(mktemp -d) trap 'rm -rf "$work"' EXIT cd "$work" diff --git a/scripts/build-docs.sh b/scripts/build-docs.sh index 0ae68cb..a823449 100755 --- a/scripts/build-docs.sh +++ b/scripts/build-docs.sh @@ -10,8 +10,13 @@ if ! command -v mdbook >/dev/null 2>&1; then exit 1 fi +# Wherever cargo puts its builds: CARGO_TARGET_DIR or a configured +# target-dir moves them out of target/. +target=$(cargo metadata --locked --format-version 1 --no-deps | + python3 -c 'import json, sys; print(json.load(sys.stdin)["target_directory"])') + export RUSTDOCFLAGS="-D warnings" -rm -rf "$root/target/doc" +rm -rf "$target/doc" cargo doc --locked --no-deps -p rfc9162 -p rfc9162-tiles -p rfc9162-log bash "$root/scripts/regen-doc-output.sh" @@ -28,4 +33,4 @@ rm -f "$err" rm -rf "$root/docs/book/api" mkdir -p "$root/docs/book/api" -cp -a "$root/target/doc/." "$root/docs/book/api/" +cp -a "$target/doc/." "$root/docs/book/api/"