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