Update lightning-c-bindings Cargo.toml & CI to point to 0.0.116
[ldk-c-bindings] / .github / workflows / build.yml
1 name: Continuous Integration Checks
2
3 on: [push, pull_request]
4
5 jobs:
6   check_bindings:
7     runs-on: ubuntu-latest
8     # Ubuntu's version of rustc uses its own LLVM instead of being a real native package.
9     # This leaves us with an incompatible LLVM version when linking. Instead, use a real OS.
10     container: debian:bullseye
11     env:
12       TOOLCHAIN: stable
13     steps:
14       - name: Install native Rust toolchain, Valgrind, and build utilitis
15         run: |
16           apt-get update
17           apt-get -y dist-upgrade
18           apt-get -y install cargo libstd-rust-dev-wasm32 valgrind lld git g++ clang wget
19       - name: Checkout source code
20         uses: actions/checkout@v2
21         with:
22           fetch-depth: 0
23       - name: Sanity test bindings against Cargo.toml RL
24         working-directory: lightning-c-bindings
25         run: |
26           # Note that the version tags aren't checked into git
27           touch src/version.rs
28           RUSTFLAGS="--cfg=c_bindings" cargo check --features std
29       - name: Install cbindgen
30         run: |
31           git clone https://github.com/eqrion/cbindgen
32           cd cbindgen/
33           git checkout v0.20.0
34           cargo update -p indexmap --precise "1.6.2" --verbose
35           cargo install --locked --path .
36       - name: Checkout Rust-Lightning git
37         run: |
38           git clone https://github.com/rust-bitcoin/rust-lightning
39           cd rust-lightning
40           git checkout 0.0.116-bindings
41       - name: Fix Github Actions to not be broken
42         run: git config --global --add safe.directory /__w/ldk-c-bindings/ldk-c-bindings
43       - name: Pin proc-macro and quote to meet MSRV
44         run: |
45           cd c-bindings-gen
46           cargo update -p quote --precise "1.0.30" --verbose
47           cargo update -p proc-macro2 --precise "1.0.65" --verbose
48       - name: Rebuild bindings without std, and check the sample app builds + links
49         run: ./genbindings.sh ./rust-lightning false
50       - name: Rebuild bindings, and check the sample app builds + links
51         run: ./genbindings.sh ./rust-lightning true
52       - name: Check that the latest bindings are in git
53         run: |
54           git checkout lightning-c-bindings/Cargo.toml # genbindings edits this to update the path
55           if [ "$(git diff)" != "" ]; then
56             # cbindgen's bindings output order can be FS-dependant, so check that the lines are all the same:
57             mv lightning-c-bindings/include/lightning.h lightning-c-bindings/include/lightning.h.new
58             git checkout lightning-c-bindings/include/lightning.h
59             cat lightning-c-bindings/include/lightning.h | grep -v "Generated with cbindgen:[0-9\.]*" | sort > lightning-c-bindings/include/lightning.h.sorted
60             cat lightning-c-bindings/include/lightning.h.new | grep -v "Generated with cbindgen:[0-9\.]*" | sort > lightning-c-bindings/include/lightning.h.new.sorted
61             diff lightning-c-bindings/include/lightning.h.sorted lightning-c-bindings/include/lightning.h.new.sorted
62             [ "$(diff lightning-c-bindings/include/lightning.h.sorted lightning-c-bindings/include/lightning.h.new.sorted)" != "" ] && exit 2
63             git diff --exit-code
64           fi
65
66   check_macos:
67     runs-on: ubuntu-latest
68     # Ubuntu's version of rustc uses its own LLVM instead of being a real native package.
69     # This leaves us with an incompatible LLVM version when linking. Instead, use a real OS.
70     container: debian:bookworm
71     env:
72       TOOLCHAIN: stable
73     steps:
74       - name: Install native Rust toolchain, Valgrind, and build utilitis
75         run: |
76           apt-get update
77           apt-get -y dist-upgrade
78           apt-get -y install cargo libstd-rust-dev-wasm32 valgrind lld git g++ clang wget rust-src
79       - name: Checkout source code
80         uses: actions/checkout@v2
81         with:
82           fetch-depth: 0
83       - name: Sanity test bindings against Cargo.toml RL
84         working-directory: lightning-c-bindings
85         run: |
86           # Note that the version tags aren't checked into git
87           touch src/version.rs
88           RUSTFLAGS="--cfg=c_bindings" cargo check --features std
89       - name: Install cbindgen
90         run: |
91           git clone https://github.com/eqrion/cbindgen
92           cd cbindgen/
93           git checkout v0.20.0
94           cargo update -p indexmap --precise "1.6.2" --verbose
95           cargo install --locked --path .
96       - name: Checkout Rust-Lightning git
97         run: |
98           git clone https://github.com/rust-bitcoin/rust-lightning
99           cd rust-lightning
100           git checkout 0.0.116-bindings
101       - name: Fix Github Actions to not be broken
102         run: git config --global --add safe.directory /__w/ldk-c-bindings/ldk-c-bindings
103       - name: Fetch MacOS SDK
104         run: |
105           wget https://bitcoincore.org/depends-sources/sdks/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers.tar.gz
106           tar xvvf Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers.tar.gz
107       - name: Rebuild bindings, and check the sample app builds + links
108         run: |
109           # rust-src doesn't distribute the rustlib Cargo.lock, but an empty
110           # file seems to suffice to make `-Zbuild-std` happy.
111           touch /usr/lib/rustlib/src/rust/Cargo.lock
112           MACOS_SDK="$PWD/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers" ./genbindings.sh ./rust-lightning true
113
114   osx:
115     strategy:
116       matrix:
117         include:
118           - platform: macos-11
119           - platform: macos-12
120           - platform: macos-13
121     runs-on: ${{ matrix.platform }}
122     env:
123       TOOLCHAIN: stable
124     steps:
125       - name: Install other Rust platforms
126         run: rustup target install aarch64-apple-darwin
127       - name: Fetch upstream LLVM/clang snapshot
128         run: |
129           wget -O clang+llvm-15.0.3-x86_64-apple-darwin.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.3/clang+llvm-15.0.3-x86_64-apple-darwin.tar.xz
130           if [ "$(shasum -a 256 clang+llvm-15.0.3-x86_64-apple-darwin.tar.xz | awk '{ print $1 }')" != "ac668586b2b3d068f1e43520a3ef0b1592e5dc3eff1a4a4b772e29803b428a69" ]; then
131             echo "Bad hash"
132             exit 1
133           fi
134       - name: Unpack upstream LLVM+clang and use it by default
135         run: |
136           tar xvvf clang+llvm-15.0.3-x86_64-apple-darwin.tar.xz
137       - name: Checkout source code
138         uses: actions/checkout@v2
139         with:
140           fetch-depth: 0
141       - name: Install cbindgen
142         run: cargo install cbindgen
143       - name: Checkout Rust-Lightning git
144         run: |
145           git clone https://github.com/rust-bitcoin/rust-lightning
146           cd rust-lightning
147           git checkout 0.0.116-bindings
148       - name: Rebuild bindings using Apple clang, and check the sample app builds + links
149         run: ./genbindings.sh ./rust-lightning true
150       - name: Rebuild bindings using upstream clang, and check the sample app builds + links
151         run: |
152           export PATH=`pwd`/clang+llvm-15.0.3-x86_64-apple-darwin/bin:$PATH
153           CC=clang ./genbindings.sh ./rust-lightning true