DROP: use matt/main
[ldk-java] / .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 openjdk-11-jdk maven
19       - name: Checkout source code
20         uses: actions/checkout@v2
21         with:
22           fetch-depth: 0
23       - name: Install cbindgen
24         run: cargo install --force cbindgen
25       - name: Checkout Rust-Lightning and LDK-C-Bindings git
26         run: |
27           git config --global user.email "ldk-ci@example.com"
28           git config --global user.name "LDK CI"
29           git clone https://github.com/rust-bitcoin/rust-lightning
30           cd rust-lightning
31           git remote add matt https://git.bitcoin.ninja/rust-lightning
32           git fetch matt
33           git merge matt/2021-03-java-bindings-base
34           cd ..
35           git clone https://github.com/lightningdevkit/ldk-c-bindings
36           cd ldk-c-bindings
37           git remote add matt https://git.bitcoin.ninja/ldk-c-bindings
38           git fetch matt
39           git merge matt/main
40           cd ..
41       - name: Rebuild C bindings without STD for WASM
42         run: |
43           cd ldk-c-bindings
44           ./genbindings.sh ../rust-lightning false
45           mv lightning-c-bindings/target/wasm32-wasi ./
46           cd ..
47       - name: Rebuild C bindings, and check the sample app builds + links
48         run: cd ldk-c-bindings && ./genbindings.sh ../rust-lightning true && mv wasm32-wasi lightning-c-bindings/target/ && cd ..
49       - name: Build Java/TS Debug Bindings
50         run: ./genbindings.sh ./ldk-c-bindings/ "-I/usr/lib/jvm/java-11-openjdk-amd64/include/ -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux/" true false
51       - name: Run Java Tests against Debug Bindings
52         run: |
53           rm liblightningjni.so
54           ln -s liblightningjni_debug.so liblightningjni.so
55           export LD_LIBRARY_PATH=.
56           export LD_PRELOAD=/usr/lib/llvm-11/lib/clang/11.0.1/lib/linux/libclang_rt.asan-x86_64.so
57           export ASAN_OPTIONS=detect_leaks=0
58           mvn test
59           git checkout liblightningjni.so
60       - name: Build Java/TS Release Bindings
61         run: |
62           # We assume the top commit is just a bindings update commit, so we
63           # check out the previous commit to use as the commit we git describe.
64           # If the top commit is a merge commit, we need to get the last merge
65           # head and assume the latest bindings are built against its parent.
66           COMMIT_PARENTS=$(git show -s --pretty=format:%P HEAD)
67           if [ "${#COMMIT_PARENTS}" = 40 ]; then
68             export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD^1)"
69           else
70             MERGE_HEAD=$(git show --pretty=format:%P HEAD | ( for last in $(cat /dev/stdin); do true; done; echo $last ))
71             export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag $MERGE_HEAD^1)"
72           fi
73           echo "Using $LDK_GARBAGECOLLECTED_GIT_OVERRIDE as git version"
74           ./genbindings.sh ./ldk-c-bindings/ "-I/usr/lib/jvm/java-11-openjdk-amd64/include/ -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux/" false false
75       - name: Check latest headers are in git
76         run: |
77           # For some reason the debug library is not deterministic, this may be fixed in a future rustc
78           git checkout liblightningjni_debug.so
79           git diff --exit-code