Update lightning-c-bindings Cargo and CI to reference 0.0.110
[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
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.110-bindings
41       - name: Rebuild bindings without std, and check the sample app builds + links
42         run: ./genbindings.sh ./rust-lightning false
43       - name: Rebuild bindings, and check the sample app builds + links
44         run: ./genbindings.sh ./rust-lightning true
45       - name: Check that the latest bindings are in git
46         run: |
47           git checkout lightning-c-bindings/Cargo.toml # genbindings edits this to update the path
48           if [ "$(git diff)" != "" ]; then
49             # cbindgen's bindings output order can be FS-dependant, so check that the lines are all the same:
50             mv lightning-c-bindings/include/lightning.h lightning-c-bindings/include/lightning.h.new
51             git checkout lightning-c-bindings/include/lightning.h
52             cat lightning-c-bindings/include/lightning.h | grep -v "Generated with cbindgen:[0-9\.]*" | sort > lightning-c-bindings/include/lightning.h.sorted
53             cat lightning-c-bindings/include/lightning.h.new | grep -v "Generated with cbindgen:[0-9\.]*" | sort > lightning-c-bindings/include/lightning.h.new.sorted
54             diff lightning-c-bindings/include/lightning.h.sorted lightning-c-bindings/include/lightning.h.new.sorted
55             [ "$(diff lightning-c-bindings/include/lightning.h.sorted lightning-c-bindings/include/lightning.h.new.sorted)" != "" ] && exit 2
56             git diff --exit-code
57           fi
58
59   osx:
60     strategy:
61       matrix:
62         include:
63           - platform: macos-10.15
64           - platform: macos-11
65     runs-on: ${{ matrix.platform }}
66     env:
67       TOOLCHAIN: stable
68     steps:
69       - name: Install other Rust platforms
70         run: rustup target install aarch64-apple-darwin
71       - name: Fetch upstream LLVM/clang snapshot
72         run: |
73           wget -O clang+llvm-12.0.0-x86_64-apple-darwin.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.0/clang+llvm-12.0.0-x86_64-apple-darwin.tar.xz
74           if [ "$(shasum -a 256 clang+llvm-12.0.0-x86_64-apple-darwin.tar.xz | awk '{ print $1 }')" != "7bc2259bf75c003f644882460fc8e844ddb23b27236fe43a2787870a4cd8ab50" ]; then
75             echo "Bad hash"
76             exit 1
77           fi
78       - name: Unpack upstream LLVM+clang and use it by default
79         run: |
80           tar xvvf clang+llvm-12.0.0-x86_64-apple-darwin.tar.xz
81       - name: Checkout source code
82         uses: actions/checkout@v2
83         with:
84           fetch-depth: 0
85       - name: Install cbindgen
86         run: cargo install cbindgen
87       - name: Checkout Rust-Lightning git
88         run: |
89           git clone https://github.com/rust-bitcoin/rust-lightning
90           cd rust-lightning
91           git checkout 0.0.110-bindings
92       - name: Rebuild bindings using Apple clang, and check the sample app builds + links
93         run: ./genbindings.sh ./rust-lightning true
94       - name: Rebuild bindings using upstream clang, and check the sample app builds + links
95         run: |
96           export PATH=`pwd`/clang+llvm-12.0.0-x86_64-apple-darwin/bin:$PATH
97           CC=clang ./genbindings.sh ./rust-lightning true