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