name: Continuous Integration Checks on: [push, pull_request] jobs: check_bindings: runs-on: ubuntu-latest # Ubuntu's version of rustc uses its own LLVM instead of being a real native package. # This leaves us with an incompatible LLVM version when linking. Instead, use a real OS. container: debian:bullseye env: TOOLCHAIN: stable steps: - name: Install native Rust toolchain, Valgrind, and build utilitis run: | apt-get update apt-get -y dist-upgrade apt-get -y install cargo libstd-rust-dev-wasm32 valgrind lld git g++ clang openjdk-11-jdk maven - name: Checkout source code uses: actions/checkout@v2 with: fetch-depth: 0 - name: Install cbindgen run: cargo install --force cbindgen - name: Checkout Rust-Lightning and LDK-C-Bindings git run: | git config --global user.email "ldk-ci@example.com" git config --global user.name "LDK CI" git clone https://github.com/rust-bitcoin/rust-lightning cd rust-lightning git remote add matt https://git.bitcoin.ninja/rust-lightning git fetch matt git merge matt/2021-03-java-bindings-base cd .. git clone https://github.com/lightningdevkit/ldk-c-bindings - name: Rebuild C bindings without STD for WASM run: | cd ldk-c-bindings ./genbindings.sh ../rust-lightning false mv lightning-c-bindings/target/wasm32-wasi ./ cd .. - name: Rebuild C bindings, and check the sample app builds + links run: | cd ldk-c-bindings # Reset the Cargo.toml file so that git describe doesn't think we're "-dirty" git checkout lightning-c-bindings/Cargo.toml ./genbindings.sh ../rust-lightning true mv wasm32-wasi lightning-c-bindings/target/ cd .. - name: Build Java/TS Debug Bindings 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 - name: Run Java Tests against Debug Bindings run: | mv liblightningjni_debug_Linux-amd64.so liblightningjni.so export ASAN_OPTIONS=detect_leaks=0 LD_PRELOAD=/usr/lib/llvm-11/lib/clang/11.0.1/lib/linux/libclang_rt.asan-x86_64.so LD_LIBRARY_PATH=. mvn test - name: Build Java/TS Release Bindings run: | # We assume the top commit is just a bindings update commit, so we # check out the previous commit to use as the commit we git describe. # If the top commit is a merge commit, we need to get the last merge # head and assume the latest bindings are built against its parent. COMMIT_PARENTS=$(git show -s --pretty=format:%P HEAD) if [ "${#COMMIT_PARENTS}" = 40 ]; then export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD^1)" else MERGE_HEAD=$(git show --pretty=format:%P HEAD | ( for last in $(cat /dev/stdin); do true; done; echo $last )) export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag $MERGE_HEAD^1)" fi echo "Using $LDK_GARBAGECOLLECTED_GIT_OVERRIDE as git version" ./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 - name: Check latest headers and release lib are in git run: | git diff --exit-code - name: Run Java Tests against built release jar run: | mvn -DskipTests=true package mvn install:install-file -Dfile=target/ldk-java-1.0-SNAPSHOT.jar -DgroupId=org.ldk -DartifactId=ldk-java -Dversion=1.0-SNAPSHOT -Dpackaging=jar cd javatester mvn package java -ea -jar target/ldk-java-tests-1.0-SNAPSHOT-jar-with-dependencies.jar cd .. osx: strategy: matrix: include: - platform: macos-10.15 # MacOS 11 is currently in private preview, we've applied for access # - platform: macos-11 runs-on: ${{ matrix.platform }} env: TOOLCHAIN: stable steps: - name: Install other Rust platforms run: rustup target install aarch64-apple-darwin - name: Fetch upstream LLVM/clang snapshot run: | 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 if [ "$(shasum -a 256 clang+llvm-12.0.0-x86_64-apple-darwin.tar.xz | awk '{ print $1 }')" != "7bc2259bf75c003f644882460fc8e844ddb23b27236fe43a2787870a4cd8ab50" ]; then echo "Bad hash" exit 1 fi - name: Unpack upstream LLVM+clang and use it by default run: | tar xvvf clang+llvm-12.0.0-x86_64-apple-darwin.tar.xz - name: Checkout source code uses: actions/checkout@v2 with: fetch-depth: 0 - name: Install cbindgen run: cargo install --force cbindgen - name: Checkout Rust-Lightning and LDK-C-Bindings git run: | git config --global user.email "ldk-ci@example.com" git config --global user.name "LDK CI" git clone https://github.com/rust-bitcoin/rust-lightning cd rust-lightning git remote add matt https://git.bitcoin.ninja/rust-lightning git fetch matt git merge matt/2021-03-java-bindings-base cd .. git clone https://github.com/lightningdevkit/ldk-c-bindings - name: Rebuild C bindings with upstream clang, and check the sample app builds + links run: | cd ldk-c-bindings export PATH=`pwd`/clang+llvm-12.0.0-x86_64-apple-darwin/bin:$PATH CC=clang ./genbindings.sh ../rust-lightning true cd .. - name: Fetch OpenJDK 16 run: | wget -O openjdk-16.0.1_osx-x64_bin.tar.gz https://download.java.net/java/GA/jdk16.0.1/7147401fd7354114ac51ef3e1328291f/9/GPL/openjdk-16.0.1_osx-x64_bin.tar.gz if [ "$(shasum -a 256 openjdk-16.0.1_osx-x64_bin.tar.gz | awk '{ print $1 }')" != "6098f839954439d4916444757c542c1b8778a32461706812d41cc8bbefce7f2f" ]; then echo "Bad hash" exit 1 fi tar xvvf openjdk-16.0.1_osx-x64_bin.tar.gz export JAVA_HOME=`pwd`/jdk-16.0.1.jdk/Contents/Home export PATH=$JAVA_HOME/bin:$PATH - name: Build Java/TS Release Bindings run: | # We assume the top commit is just a bindings update commit, so we # check out the previous commit to use as the commit we git describe. # If the top commit is a merge commit, we need to get the last merge # head and assume the latest bindings are built against its parent. COMMIT_PARENTS=$(git show -s --pretty=format:%P HEAD) if [ "${#COMMIT_PARENTS}" = 40 ]; then export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD^1)" else MERGE_HEAD=$(git show --pretty=format:%P HEAD | ( for last in $(cat /dev/stdin); do true; done; echo $last )) export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag $MERGE_HEAD^1)" fi echo "Using $LDK_GARBAGECOLLECTED_GIT_OVERRIDE as git version" # genbindings.sh always fails as there is no wasm32-wasi library # available, so instead we delete the expected JNI library and check # that it was created. rm src/main/resources/liblightningjni_MacOSX-x86_64.nativelib ./genbindings.sh ./ldk-c-bindings/ "-I$JAVA_HOME/include/ -I$JAVA_HOME/include/darwin -isysroot$(xcrun --show-sdk-path)" false false || echo cat src/main/resources/liblightningjni_MacOSX-x86_64.nativelib > /dev/null - name: Fetch Maven 3.8.1 run: | wget -O apache-maven-3.8.1-bin.tar.gz https://apache.osuosl.org/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz if [ "$(shasum -a 256 apache-maven-3.8.1-bin.tar.gz | awk '{ print $1 }')" != "b98a1905eb554d07427b2e5509ff09bd53e2f1dd7a0afa38384968b113abef02" ]; then echo "Bad hash" exit 1 fi tar xvvf apache-maven-3.8.1-bin.tar.gz export PATH=apache-maven-3.8.1/bin:$PATH - name: Run Java Tests against built jar run: | mvn -DskipTests=true package mvn install:install-file -Dfile=target/ldk-java-1.0-SNAPSHOT.jar -DgroupId=org.ldk -DartifactId=ldk-java -Dversion=1.0-SNAPSHOT -Dpackaging=jar cd javatester mvn package java -ea -jar target/ldk-java-tests-1.0-SNAPSHOT-jar-with-dependencies.jar cd .. - name: Check latest headers and release lib are in git run: | if [ "${{ matrix.platform }}" = "macos-11" ]; then git diff --exit-code fi