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