name: Continuous Integration Checks on: [push, pull_request] jobs: wasm_bindings: runs-on: ubuntu-latest # Ubuntu's version of clang doesn't support....anything that should work. # Ubuntu is an utter trash OS and should generally never be used for anything. # We also require at least rustc 1.51 (ie https://github.com/rust-lang/rust/pull/79998), # so we use debian testing container: debian:bookworm strategy: fail-fast: false steps: - name: Install build utilities and test that clang can build for wasm run: | apt-get update apt-get -y dist-upgrade apt-get -y install cargo libstd-rust-dev-wasm32 lld git g++ clang curl node-typescript npm python3 echo "int main() {}" > genbindings_wasm_test_file.c clang -nostdlib -o /dev/null --target=wasm32-wasi -Wl,--no-entry genbindings_wasm_test_file.c rm genbindings_wasm_test_file.c - 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" # Note this is a different endpoint, as we need one non-upstream commit! git clone https://git.bitcoin.ninja/rust-lightning cd rust-lightning git checkout origin/2021-03-java-bindings-base cd .. git clone https://github.com/lightningdevkit/ldk-c-bindings cd ldk-c-bindings git checkout 0.0.104 - name: Rebuild C bindings without STD run: | cd ldk-c-bindings ./genbindings.sh ../rust-lightning false - name: Build and Test TS Bindings for Node run: | # We need FinalizationRegistry and top-level await support, which requires node 14.6/8, # however Debian ships with Node 12 # Thus, we install the binary nodejs from nodejs.org and test with that. curl https://nodejs.org/dist/v16.13.1/node-v16.13.1-linux-x64.tar.xz > nodejs.tar.xz tar xvvf nodejs.tar.xz export PATH=$(echo node-*/bin):$PATH ./genbindings.sh ./ldk-c-bindings/ wasm false false - name: Build and Test TS Bindings for Web run: | export PATH=$(echo node-*/bin):$PATH ./genbindings.sh ./ldk-c-bindings/ wasm false true export HOME=/root/ # Github actions is apparently broken npm i -D playwright # npx playwright install-deps is broken so we do it manually, see https://github.com/microsoft/playwright/issues/11165 apt-get install -y --no-install-recommends fonts-liberation libenchant-2-2 libicu67 libjpeg62-turbo libasound2 libatk-bridge2.0-0 libatk1.0-0 libatspi2.0-0 libcairo2 libcups2 libdbus-1-3 libdrm2 libegl1 libgbm1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxrandr2 libxshmfence1 xvfb fonts-noto-color-emoji fonts-unifont libfontconfig libfreetype6 xfonts-scalable fonts-ipafont-gothic fonts-wqy-zenhei fonts-tlwg-loma-otf ffmpeg libcairo-gobject2 libdbus-glib-1-2 libfontconfig1 libgdk-pixbuf2.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libxcb-shm0 libxcursor1 libxi6 libxrender1 libxt6 gstreamer1.0-libav gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-plugins-good libepoxy0 libevdev2 libgl1 libgles2 libgstreamer-gl1.0-0 libgstreamer1.0-0 libharfbuzz-icu0 libharfbuzz0b libhyphen0 libnotify4 libopenjp2-7 libopus0 libpng16-16 libsecret-1-0 libsoup2.4-1 libwayland-client0 libwayland-egl1 libwayland-server0 libwebp6 libwebpdemux2 libwoff1 libxkbcommon0 libxml2 libxslt1.1 mkdir -p $HOME/.cache/ms-playwright # `playwright install` is too dumb to create this for us chmod -R 777 $HOME/ npx playwright install export PATH=$(echo node-*/bin):$PATH python3 -m http.server & node ts/test/browser.mjs - name: Check latest TS files are in git run: | git diff --exit-code java_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 strategy: fail-fast: false steps: - name: Install native Rust toolchain, Valgrind, and build utilitis run: | apt-get update apt-get -y dist-upgrade apt-get -y install cargo valgrind lld git g++ clang openjdk-11-jdk maven faketime zip unzip llvm curl - 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" # Note this is a different endpoint, as we need one non-upstream commit! git clone https://git.bitcoin.ninja/rust-lightning cd rust-lightning git checkout origin/2021-03-java-bindings-base cd .. git clone https://github.com/lightningdevkit/ldk-c-bindings cd ldk-c-bindings git checkout 0.0.104 - 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 - name: Build Java 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: Checkout latest MacOS binaries run: | export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)" echo "Fetching deterministic binaries for LDK-GC ${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}" # Gitweb only allows snapshots of folders by providing the object hash, which we have to extract: SNAPSHOT_LINK="$(curl "https://git.bitcoin.ninja/index.cgi?p=ldk-java-bins;a=tree;f=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE};hb=refs/heads/main" | grep snapshot | grep -o 'href="[a-zA-Z0-9/?\.=;\-]*"' | sed 's/href="//' | tr -d '"' | grep snapshot)" curl -o bins-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}" mkdir -p ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}" cd ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}" tar xvvf ../../bins-snapshot.tgz mv ldk-java-bins-*/* ./ rm -r ldk-java-bins-* cd ../.. mkdir -p src/main/resources/ cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/liblightningjni_MacOSX-"* src/main/resources/ - name: Build Java Release Bindings run: | export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)" ./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: Build deterministic release jar run: ./build-release-jar.sh - name: Check latest headers are in git run: | git checkout pom.xml git diff --exit-code - name: Check latest library and jars are in bins repo run: | export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)" mkdir ldk-java-bins/new/ cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"liblightningjni_Mac*.nativelib ldk-java-bins/new/ cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"LDK-release.aar ldk-java-bins/new/ # ldk-java-leaktracking is only for debug purposes and we don't bother with determinism cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"ldk-java-leaktracking.jar ldk-java-bins/new/ cp src/main/resources/liblightningjni_Linux-amd64.nativelib ldk-java-bins/new/ cp ldk-java-sources.jar ldk-java-bins/new/ cp ldk-java.jar ldk-java-bins/new/ cp ldk-java-classes.jar ldk-java-bins/new/ cp ldk-java-javadoc.jar ldk-java-bins/new/ cd ldk-java-bins if ! diff -r "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/" new/; then apt-get -y install diffoscope diffoscope new/ldk-java-sources.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-sources.jar" || echo diffoscope new/ldk-java-javadoc.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-javadoc.jar" || echo diffoscope new/ldk-java-classes.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-classes.jar" || echo diffoscope new/ldk-java.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java.jar" || echo exit 1 fi - name: Run Java Tests against built release jar run: | mvn install:install-file -Dfile=ldk-java.jar -DgroupId=org.lightningdevkit -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 .. android: runs-on: ubuntu-latest # Frankly, I'm not really sure why debian and ubuntu differ in the results here, they really shouldn't container: debian:bullseye strategy: fail-fast: false steps: - name: Install rust targets run: | apt-get update apt-get -y dist-upgrade apt-get -y install git g++ clang faketime zip unzip curl openjdk-11-jdk curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup.sh chmod +x ./rustup.sh ./rustup.sh -y . $HOME/.cargo/env rustup target add armv7-linux-androideabi rustup target add aarch64-linux-android rustup target add i686-linux-android rustup target add x86_64-linux-android - name: Checkout source code uses: actions/checkout@v2 with: fetch-depth: 0 - name: Install android NDK compilers run: | curl https://dl.google.com/android/repository/android-ndk-r22b-linux-x86_64.zip > android-ndk-r22b-linux-x86_64.zip if [ "$(sha256sum android-ndk-r22b-linux-x86_64.zip | awk '{ print $1 }')" != "ac3a0421e76f71dd330d0cd55f9d99b9ac864c4c034fc67e0d671d022d4e806b" ]; then echo "Bad hash" exit 1 fi unzip android-ndk-r22b-linux-x86_64.zip - name: Install cbindgen run: | . $HOME/.cargo/env 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" # Note this is a different endpoint, as we need one non-upstream commit! git clone https://git.bitcoin.ninja/rust-lightning cd rust-lightning git checkout origin/2021-03-java-bindings-base cd .. git clone https://github.com/lightningdevkit/ldk-c-bindings cd ldk-c-bindings git checkout 0.0.104 - name: Checkout Android AAR binaries and artifacts run: | # Gitweb only allows snapshots of folders by providing the object hash, which we have to extract: export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)" echo "Fetching deterministic binaries for LDK-GC ${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}" RELEASE_PAGE="https://git.bitcoin.ninja/index.cgi?p=ldk-java-bins;a=tree;f=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE};hb=refs/heads/main" SNAPSHOT_LINK="$(curl "$RELEASE_PAGE" | grep snapshot | grep -o 'href="[a-zA-Z0-9/?\.=;\-]*"' | sed 's/href="//' | tr -d '"' | grep snapshot)" curl -o bins-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}" ANDROID_PAGE="https://git.bitcoin.ninja/index.cgi?p=ldk-java-bins;a=tree;f=android-artifacts;hb=refs/heads/main" SNAPSHOT_LINK="$(curl "$ANDROID_PAGE" | grep snapshot | grep -o 'href="[a-zA-Z0-9/?\.=;\-]*"' | sed 's/href="//' | tr -d '"' | grep snapshot)" curl -o android-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}" mkdir -p ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}" cd ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}" tar xvvf ../../bins-snapshot.tgz mv ldk-java-bins-*/* ./ rm -r ldk-java-bins-* mkdir -p ../android-artifacts cd ../android-artifacts tar xvvf ../../android-snapshot.tgz mv ldk-java-bins-*/* ./ rm -r ldk-java-bins-* - name: Build Android aar run: | . $HOME/.cargo/env export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)" cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-classes.jar" ./ export ANDROID_TOOLCHAIN="$(pwd)/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64" export PATH="$PATH:$ANDROID_TOOLCHAIN/bin" ./android-build.sh ./rust-lightning ./ldk-c-bindings/ ./ldk-java-bins/android-artifacts - name: Check latest library and jars are in bins repo run: | export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)" if ! diff LDK-release.aar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"LDK-release.aar; then apt-get -y install diffoscope diffoscope LDK-release.aar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/LDK-release.aar" exit 1 fi osx: strategy: matrix: include: - platform: macos-10.15 - platform: macos-11 fail-fast: false runs-on: ${{ matrix.platform }} steps: - name: Install other Rust platforms run: rustup target install aarch64-apple-darwin - name: Fetch upstream LLVM/clang snapshot run: | wget -O clang+llvm-13.0.0-x86_64-apple-darwin.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-apple-darwin.tar.xz if [ "$(shasum -a 256 clang+llvm-13.0.0-x86_64-apple-darwin.tar.xz | awk '{ print $1 }')" != "d051234eca1db1f5e4bc08c64937c879c7098900f7a0370f3ceb7544816a8b09" ]; then echo "Bad hash" exit 1 fi - name: Unpack upstream LLVM+clang and use it by default run: | tar xvvf clang+llvm-13.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" # Note this is a different endpoint, as we need one non-upstream commit! git clone https://git.bitcoin.ninja/rust-lightning cd rust-lightning git checkout origin/2021-03-java-bindings-base cd .. git clone https://github.com/lightningdevkit/ldk-c-bindings cd ldk-c-bindings git checkout 0.0.104 - name: Rebuild C bindings with upstream clang, and check the sample app builds + links run: | cd ldk-c-bindings export PATH=`pwd`/clang+llvm-13.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 - name: Checkout latest Linux binaries run: | export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)" echo "Fetching deterministic binaries for LDK-GC ${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}" # Gitweb only allows snapshots of folders by providing the object hash, which we have to extract: SNAPSHOT_LINK="$(wget -O /dev/stdout "https://git.bitcoin.ninja/index.cgi?p=ldk-java-bins;a=tree;f=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE};hb=refs/heads/main" | grep snapshot | grep -o 'href="[a-zA-Z0-9/?\.=;\-]*"' | sed 's/href="//' | tr -d '"' | grep snapshot)" wget -O bins-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}" mkdir -p ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}" cd ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}" tar xvvf ../../bins-snapshot.tgz mv ldk-java-bins-*/* ./ cd ../.. mkdir -p src/main/resources/ cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/liblightningjni_Linux-"* src/main/resources/ - name: Build Java Release Bindings run: | export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)" export JAVA_HOME=`pwd`/jdk-16.0.1.jdk/Contents/Home export PATH=$JAVA_HOME/bin:$PATH export PATH=`pwd`/clang+llvm-13.0.0-x86_64-apple-darwin/bin:$PATH ./genbindings.sh ./ldk-c-bindings/ "-I$JAVA_HOME/include/ -I$JAVA_HOME/include/darwin -isysroot$(xcrun --show-sdk-path)" false false if [ "${{ matrix.platform }}" = "macos-11" ]; then export CC="clang --target=aarch64-apple-darwin" export LDK_TARGET=aarch64-apple-darwin export LDK_TARGET_CPU=apple-a14 ./genbindings.sh ./ldk-c-bindings/ "-I$JAVA_HOME/include/ -I$JAVA_HOME/include/darwin -isysroot$(xcrun --show-sdk-path)" false false cat src/main/resources/liblightningjni_MacOSX-aarch64.nativelib > /dev/null fi - name: Fetch Maven 3.8.4 run: | # We don't bother using the upstream mirrors as they remove prior # releases aggressively, causing spurious CI failures when we don't # care about the version used. wget -O apache-maven-3.8.4-bin.tar.gz https://bitcoin.ninja/apache-maven-3.8.4-bin.tar.gz if [ "$(shasum -a 256 apache-maven-3.8.4-bin.tar.gz | awk '{ print $1 }')" != "2cdc9c519427bb20fdc25bef5a9063b790e4abd930e7b14b4e9f4863d6f9f13c" ]; then echo "Bad hash" exit 1 fi tar xvvf apache-maven-3.8.4-bin.tar.gz export PATH=apache-maven-3.8.4/bin:$PATH - name: Run Java Tests against built jar run: | export JAVA_HOME=`pwd`/jdk-16.0.1.jdk/Contents/Home export PATH=$JAVA_HOME/bin:$PATH mvn -DskipTests=true package export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)" JAR_VERSION=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE:1:100} mvn install:install-file -Dfile=target/ldk-java-${JAR_VERSION}.jar -DgroupId=org.lightningdevkit -DartifactId=ldk-java -Dversion=1.0-SNAPSHOT -Dpackaging=jar cd javatester mvn -q -B package java -ea -jar target/ldk-java-tests-1.0-SNAPSHOT-jar-with-dependencies.jar cd .. - name: Check latest release libs are in git run: | if [ "${{ matrix.platform }}" = "macos-11" ]; then export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)" # Sadly, OSX binaries are not currently deterministic, more debugging is needed. diff "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"liblightningjni_MacOSX-x86_64.nativelib src/main/resources/liblightningjni_MacOSX-x86_64.nativelib || echo diff "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"liblightningjni_MacOSX-aarch64.nativelib src/main/resources/liblightningjni_MacOSX-aarch64.nativelib || echo fi - name: Run Java Tests against release bins run: | if [ "${{ matrix.platform }}" != "macos-11" ]; then export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)" export JAVA_HOME=`pwd`/jdk-16.0.1.jdk/Contents/Home export PATH=$JAVA_HOME/bin:$PATH cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"liblightningjni_MacOSX-{x86_64,aarch64}.nativelib src/main/resources/ mvn clean mvn -q -B -DskipTests=true package JAR_VERSION=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE:1:100} mvn install:install-file -Dfile=target/ldk-java-${JAR_VERSION}.jar -DgroupId=org.lightningdevkit -DartifactId=ldk-java -Dversion=1.0-SNAPSHOT -Dpackaging=jar cd javatester mvn -q -B package java -ea -jar target/ldk-java-tests-1.0-SNAPSHOT-jar-with-dependencies.jar cd .. fi