Add a CI job to emulate docs.rs builds
What changed, and why it matters
This commit only adds a new automated documentation-build check to the project's continuous integration (CI) pipeline. It does not change any production code, cryptographic logic, network handling, or user-facing behavior. There is no security vulnerability here.
No security action needed. This is a routine CI/infrastructure improvement. Reviewers may optionally verify the shell script parsing is robust, but it has no security impact.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch introduces a GitHub Actions job named check_docs that runs ci/check-docsrs.sh to emulate docs.rs builds for each workspace member. The script parses Cargo.toml for package.metadata.docs.rs settings, then runs cargo rustdoc with the appropriate features and rustdoc arguments. ci/ci-tests.sh is updated to derive workspace members dynamically from Cargo.toml instead of a hard-coded list. No application code is modified.
Changed components
.github/workflows/build.ymlci/check-docsrs.shci/ci-tests.shInspect captured patch +62 / −17
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 2190dd5..cbc50ba 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -233,6 +233,24 @@ jobs:
RUSTFLAGS: '--cfg=taproot'
RUSTDOCFLAGS: '--cfg=taproot'
+ check_docs:
+ runs-on: self-hosted
+ env:
+ # While docs.rs builds using a nightly compiler (and we use some nightly features),
+ # nightly ends up randomly breaking builds occasionally, so we instead use beta
+ # and set RUSTC_BOOTSTRAP in check-docsrs.sh
+ TOOLCHAIN: beta
+ steps:
+ - name: Checkout source code
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ - name: Install Rust ${{ env.TOOLCHAIN }} toolchain
+ run: |
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ env.TOOLCHAIN }}
+ - name: Simulate docs.rs build
+ run: ci/check-docsrs.sh
+
fuzz:
runs-on: self-hosted
env:
diff --git a/ci/check-docsrs.sh b/ci/check-docsrs.sh
new file mode 100755
index 0000000..b8776f8
--- /dev/null
+++ b/ci/check-docsrs.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+#shellcheck disable=SC2002,SC2086,SC2207
+
+set -ex
+
+# Attempt to simulate the docsrs builds. Sadly its not entirely trivial as
+# docs.rs reads metadata out of Cargo.toml which we don't want to have a whole
+# parser for.
+
+WORKSPACE_MEMBERS=( $(cat Cargo.toml | tr '\n' '\r' | sed 's/\r //g' | tr '\r' '\n' | grep '^members =' | sed 's/members.*=.*\[//' | tr -d '"' | tr ',' '\n') )
+echo "${WORKSPACE_MEMBERS[@]}"
+for CRATE in "${WORKSPACE_MEMBERS[@]}"; do
+ pushd "$CRATE"
+ CARGO_ARGS=""
+ RUSTDOC_ARGS=""
+ cat Cargo.toml | grep -A 100 '\[package.metadata.docs.rs\]' | tail -n +2 > /tmp/ldk-docsrs-rustdoc-config.txt
+ while read -r LINE; do
+ case "$LINE" in
+ "["*) break;;
+ "features"*)
+ OG_IFS="$IFS"
+ IFS=','
+ for FEATURE in $(echo "$LINE" | sed 's/features.*=.*\[//g' | tr -d '"] '); do
+ export CARGO_ARGS="$CARGO_ARGS --features $FEATURE"
+ done
+ IFS="$OG_IFS"
+ ;;
+ "all-features = true")
+ export CARGO_ARGS="$CARGO_ARGS --all-features"
+ ;;
+ "rustdoc-args"*)
+ RUSTDOC_ARGS="$(echo "$LINE" | sed 's/rustdoc-args.*=.*\[//g' | tr -d '"],')"
+ ;;
+ esac
+ done < /tmp/ldk-docsrs-rustdoc-config.txt
+ rm /tmp/ldk-docsrs-rustdoc-config.txt
+ echo "Building $CRATE with args $CARGO_ARGS and flags $RUSTDOC_ARGS"
+ # We rely on nightly features but want to use a stable release in CI to avoid
+ # spurous breakage, thus we set RUSTC_BOOTSTRAP=1 here.
+ RUSTC_BOOTSTRAP=1 cargo rustdoc $CARGO_ARGS -- $RUSTDOC_ARGS
+ popd
+done
diff --git a/ci/ci-tests.sh b/ci/ci-tests.sh
index f784140..c3637ab 100755
--- a/ci/ci-tests.sh
+++ b/ci/ci-tests.sh
@@ -1,4 +1,5 @@
#!/bin/bash
+#shellcheck disable=SC2002,SC2207
set -eox pipefail
RUSTC_MINOR_VERSION=$(rustc --version | awk '{ split($2,a,"."); print a[2] }')
@@ -41,23 +42,7 @@ export RUST_BACKTRACE=1
echo -e "\n\nChecking the workspace, except lightning-transaction-sync."
cargo check --verbose --color always
-# When the workspace members change, make sure to update the list here as well
-# as in `Cargo.toml`.
-WORKSPACE_MEMBERS=(
- lightning
- lightning-types
- lightning-block-sync
- lightning-invoice
- lightning-net-tokio
- lightning-persister
- lightning-background-processor
- lightning-rapid-gossip-sync
- lightning-custom-message
- lightning-macros
- lightning-dns-resolver
- lightning-liquidity
- possiblyrandom
-)
+WORKSPACE_MEMBERS=( $(cat Cargo.toml | tr '\n' '\r' | sed 's/\r //g' | tr '\r' '\n' | grep '^members =' | sed 's/members.*=.*\[//' | tr -d '"' | tr ',' ' ') )
echo -e "\n\nTesting the workspace, except lightning-transaction-sync."
cargo test --verbose --color always
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.