Skip to content

Commit 94ff357

Browse files
committed
Add a CI job to emulate docs.rs builds
Sadly, our docs.rs build failed for 0.1.6 due to the unstable `doc_auto_cfg` feature being removed. Here, we try to emulate docs.rs builds as best we can in CI to head that off in the future.
1 parent 6aea586 commit 94ff357

File tree

3 files changed

+57
-17
lines changed

3 files changed

+57
-17
lines changed

.github/workflows/build.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,21 @@ jobs:
233233
RUSTFLAGS: '--cfg=taproot'
234234
RUSTDOCFLAGS: '--cfg=taproot'
235235

236+
check_docs:
237+
runs-on: self-hosted
238+
env:
239+
TOOLCHAIN: nightly
240+
steps:
241+
- name: Checkout source code
242+
uses: actions/checkout@v4
243+
with:
244+
fetch-depth: 0
245+
- name: Install Rust ${{ env.TOOLCHAIN }} toolchain
246+
run: |
247+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ env.TOOLCHAIN }}
248+
- name: Simulate docs.rs build
249+
run: ci/check-docsrs.sh
250+
236251
fuzz:
237252
runs-on: self-hosted
238253
env:

ci/check-docsrs.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
#shellcheck disable=SC2002,SC2086,SC2207
3+
4+
set -ex
5+
6+
# Attempt to simulate the docsrs builds. Sadly its not entirely trivial as
7+
# docs.rs reads metadata out of Cargo.toml which we don't want to have a whole
8+
# parser for.
9+
10+
WORKSPACE_MEMBERS=( $(cat Cargo.toml | tr '\n' '\r' | sed 's/\r //g' | tr '\r' '\n' | grep '^members =' | sed 's/members.*=.*\[//' | tr -d '"' | tr ',' '\n') )
11+
echo "${WORKSPACE_MEMBERS[@]}"
12+
for CRATE in "${WORKSPACE_MEMBERS[@]}"; do
13+
pushd "$CRATE"
14+
CARGO_ARGS=""
15+
RUSTFLAGS=""
16+
cat Cargo.toml | grep -A 100 '\[package.metadata.docs.rs\]' | tail -n +2 > /tmp/ldk-docsrs-rustdoc-config.txt
17+
while read -r LINE; do
18+
case "$LINE" in
19+
"["*) break;;
20+
"features"*)
21+
OG_IFS="$IFS"
22+
IFS=','
23+
for FEATURE in $(echo "$LINE" | sed 's/features.*=.*\[//g' | tr -d '"] '); do
24+
export CARGO_ARGS="$CARGO_ARGS --features $FEATURE"
25+
done
26+
IFS="$OG_IFS"
27+
;;
28+
"all-features = true")
29+
export CARGO_ARGS="$CARGO_ARGS --all-features"
30+
;;
31+
"rustdoc-args"*)
32+
RUSTFLAGS="$(echo "$LINE" | sed 's/rustdoc-args.*=.*\[//g' | tr -d '"],')"
33+
;;
34+
esac
35+
done < /tmp/ldk-docsrs-rustdoc-config.txt
36+
rm /tmp/ldk-docsrs-rustdoc-config.txt
37+
echo "Building $CRATE with args $CARGO_ARGS and flags $RUSTFLAGS"
38+
cargo doc $CARGO_ARGS
39+
popd
40+
done

ci/ci-tests.sh

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
#shellcheck disable=SC2002,SC2207
23
set -eox pipefail
34

45
RUSTC_MINOR_VERSION=$(rustc --version | awk '{ split($2,a,"."); print a[2] }')
@@ -41,23 +42,7 @@ export RUST_BACKTRACE=1
4142
echo -e "\n\nChecking the workspace, except lightning-transaction-sync."
4243
cargo check --verbose --color always
4344

44-
# When the workspace members change, make sure to update the list here as well
45-
# as in `Cargo.toml`.
46-
WORKSPACE_MEMBERS=(
47-
lightning
48-
lightning-types
49-
lightning-block-sync
50-
lightning-invoice
51-
lightning-net-tokio
52-
lightning-persister
53-
lightning-background-processor
54-
lightning-rapid-gossip-sync
55-
lightning-custom-message
56-
lightning-macros
57-
lightning-dns-resolver
58-
lightning-liquidity
59-
possiblyrandom
60-
)
45+
WORKSPACE_MEMBERS=( $(cat Cargo.toml | tr '\n' '\r' | sed 's/\r //g' | tr '\r' '\n' | grep '^members =' | sed 's/members.*=.*\[//' | tr -d '"' | tr ',' ' ') )
6146

6247
echo -e "\n\nTesting the workspace, except lightning-transaction-sync."
6348
cargo test --verbose --color always

0 commit comments

Comments
 (0)