[TS/CI] Update dependent package list
[ldk-java] / .github / workflows / build.yml
1 name: Continuous Integration Checks
2
3 on: [push, pull_request]
4
5 jobs:
6   wasm_bindings:
7     runs-on: ubuntu-latest
8     # Ubuntu's version of clang doesn't support....anything that should work.
9     # Ubuntu is an utter trash OS and should generally never be used for anything.
10     # We also require at least rustc 1.51 (ie https://github.com/rust-lang/rust/pull/79998),
11     # so we use debian testing
12     container: debian:bookworm
13     strategy:
14       fail-fast: false
15     steps:
16       - name: Install build utilities and test that clang can build for wasm
17         run: |
18           apt-get update
19           apt-get -y dist-upgrade
20           apt-get -y install cargo libstd-rust-dev-wasm32 lld git g++ clang curl node-typescript npm python3
21           echo "int main() {}" > genbindings_wasm_test_file.c
22           clang -nostdlib -o /dev/null --target=wasm32-wasi -Wl,--no-entry genbindings_wasm_test_file.c
23           rm genbindings_wasm_test_file.c
24       - name: Checkout source code
25         uses: actions/checkout@v2
26         with:
27           fetch-depth: 0
28       - name: Install cbindgen
29         run: cargo install --force cbindgen
30       - name: Checkout Rust-Lightning and LDK-C-Bindings git
31         run: |
32           git config --global user.email "ldk-ci@example.com"
33           git config --global user.name "LDK CI"
34           # Note this is a different endpoint, as we need one non-upstream commit!
35           git clone https://git.bitcoin.ninja/rust-lightning
36           cd rust-lightning
37           git checkout origin/2021-03-java-bindings-base
38           cd ..
39           git clone https://github.com/lightningdevkit/ldk-c-bindings
40           cd ldk-c-bindings
41           git checkout 0.0.105
42       - name: Rebuild C bindings without STD
43         run: |
44           cd ldk-c-bindings
45           ./genbindings.sh ../rust-lightning false
46       - name: Build and Test TS Debug Bindings for Node
47         run: |
48           # We need FinalizationRegistry and top-level await support, which requires node 14.6/8,
49           # however Debian ships with Node 12
50           # Thus, we install the binary nodejs from nodejs.org and test with that.
51           curl https://nodejs.org/dist/v16.13.1/node-v16.13.1-linux-x64.tar.xz > nodejs.tar.xz
52           tar xvvf nodejs.tar.xz
53           export PATH=$(pwd)/$(echo node-*/bin):$PATH
54           ./genbindings.sh ./ldk-c-bindings/ wasm true false
55       - name: Build and Test TS Release Bindings for Node
56         run: |
57           export PATH=$(pwd)/$(echo node-*/bin):$PATH
58           ./genbindings.sh ./ldk-c-bindings/ wasm false false
59       - name: Install Playwright for Web Tests
60         run: |
61           export HOME=/root/ # Github actions is apparently broken
62           export PATH=$(pwd)/$(echo node-*/bin):$PATH
63           # npx playwright install-deps is broken so we do it manually, see https://github.com/microsoft/playwright/issues/11165
64           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 libwebp7 libwebpdemux2 libwoff1 libxkbcommon0 libxml2 libxslt1.1
65           mkdir -p $HOME/.cache/ms-playwright # `playwright install` is too dumb to create this for us
66           chmod -R 777 $HOME/
67           npm i -D playwright
68           npx playwright install
69       - name: Build and Test TS Debug Bindings for Web
70         run: |
71           export HOME=/root/ # Github actions is apparently broken
72           export PATH=$(pwd)/$(echo node-*/bin):$PATH
73           ./genbindings.sh ./ldk-c-bindings/ wasm true true
74           cd ts
75           rm liblightningjs.wasm && ln -s $(pwd)/../liblightningjs_debug.wasm ./liblightningjs.wasm
76           python3 -m http.server &
77           SERVER_PID=$!
78           node test/browser.mjs
79           kill $SERVER_PID
80       - name: Build and Test TS Release Bindings for Web
81         run: |
82           export HOME=/root/ # Github actions is apparently broken
83           export PATH=$(pwd)/$(echo node-*/bin):$PATH
84           ./genbindings.sh ./ldk-c-bindings/ wasm false true
85           cd ts
86           rm liblightningjs.wasm && ln -s $(pwd)/../liblightningjs_release.wasm ./liblightningjs.wasm
87           python3 -m http.server &
88           SERVER_PID=$!
89           node test/browser.mjs
90           kill $SERVER_PID
91       - name: Check latest TS files are in git
92         run: |
93           git diff --exit-code
94
95   java_bindings:
96     runs-on: ubuntu-latest
97     # Ubuntu's version of rustc uses its own LLVM instead of being a real native package.
98     # This leaves us with an incompatible LLVM version when linking. Instead, use a real OS.
99     container: debian:bullseye
100     strategy:
101       fail-fast: false
102     steps:
103       - name: Install native Rust toolchain, Valgrind, and build utilitis
104         run: |
105           apt-get update
106           apt-get -y dist-upgrade
107           apt-get -y install cargo valgrind lld git g++ clang openjdk-11-jdk maven faketime zip unzip llvm curl
108       - name: Checkout source code
109         uses: actions/checkout@v2
110         with:
111           fetch-depth: 0
112       - name: Install cbindgen
113         run: cargo install --force cbindgen
114       - name: Checkout Rust-Lightning and LDK-C-Bindings git
115         run: |
116           git config --global user.email "ldk-ci@example.com"
117           git config --global user.name "LDK CI"
118           # Note this is a different endpoint, as we need one non-upstream commit!
119           git clone https://git.bitcoin.ninja/rust-lightning
120           cd rust-lightning
121           git checkout origin/2021-03-java-bindings-base
122           cd ..
123           git clone https://github.com/lightningdevkit/ldk-c-bindings
124           cd ldk-c-bindings
125           git checkout 0.0.105
126       - name: Rebuild C bindings, and check the sample app builds + links
127         run: |
128           cd ldk-c-bindings
129           ./genbindings.sh ../rust-lightning true
130       - name: Build Java Debug Bindings
131         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
132       - name: Run Java Tests against Debug Bindings
133         run: |
134           mv liblightningjni_debug_Linux-amd64.so liblightningjni.so
135           export ASAN_OPTIONS=detect_leaks=0
136           LD_PRELOAD=/usr/lib/llvm-11/lib/clang/11.0.1/lib/linux/libclang_rt.asan-x86_64.so LD_LIBRARY_PATH=. mvn test
137       - name: Build Java Release Bindings
138         run: |
139           ./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
140       - name: Check latest headers are in git
141         run: |
142           git checkout pom.xml
143           git diff --exit-code
144
145   java_determinism:
146     runs-on: ubuntu-latest
147     # Ubuntu's version of rustc uses its own LLVM instead of being a real native package.
148     # This leaves us with an incompatible LLVM version when linking. Instead, use a real OS.
149     container: debian:bullseye
150     strategy:
151       fail-fast: false
152     steps:
153       - name: Install native Rust toolchain, Valgrind, and build utilitis
154         run: |
155           apt-get update
156           apt-get -y dist-upgrade
157           apt-get -y install cargo valgrind lld git g++ clang openjdk-11-jdk maven faketime zip unzip llvm curl
158       - name: Checkout source code
159         uses: actions/checkout@v2
160         with:
161           fetch-depth: 0
162       - name: Install cbindgen
163         run: cargo install --force cbindgen
164       - name: Checkout Rust-Lightning and LDK-C-Bindings git
165         run: |
166           git config --global user.email "ldk-ci@example.com"
167           git config --global user.name "LDK CI"
168           # Note this is a different endpoint, as we need one non-upstream commit!
169           git clone https://git.bitcoin.ninja/rust-lightning
170           cd rust-lightning
171           git checkout origin/2021-03-java-bindings-base
172           cd ..
173           git clone https://github.com/lightningdevkit/ldk-c-bindings
174           cd ldk-c-bindings
175           git checkout 0.0.105
176       - name: Rebuild C bindings, and check the sample app builds + links
177         run: |
178           cd ldk-c-bindings
179           ./genbindings.sh ../rust-lightning true
180       - name: Checkout latest MacOS binaries
181         run: |
182           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
183           echo "Fetching deterministic binaries for LDK-GC ${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
184           # Gitweb only allows snapshots of folders by providing the object hash, which we have to extract:
185           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)"
186           curl -o bins-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}"
187           mkdir -p ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
188           cd ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
189           tar xvvf ../../bins-snapshot.tgz
190           mv ldk-java-bins-*/* ./
191           rm -r ldk-java-bins-*
192           cd ../..
193           mkdir -p src/main/resources/
194           cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/liblightningjni_MacOSX-"* src/main/resources/
195       - name: Build Java Release Bindings
196         run: |
197           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
198           ./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
199       - name: Build deterministic release jar
200         run: ./build-release-jar.sh
201       - name: Check latest library and jars are in bins repo
202         run: |
203           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
204           mkdir ldk-java-bins/new/
205           cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"liblightningjni_Mac*.nativelib ldk-java-bins/new/
206           cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"LDK-release.aar ldk-java-bins/new/
207           # ldk-java-leaktracking is only for debug purposes and we don't bother with determinism
208           cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"ldk-java-leaktracking.jar ldk-java-bins/new/
209           cp src/main/resources/liblightningjni_Linux-amd64.nativelib ldk-java-bins/new/
210           cp ldk-java-sources.jar ldk-java-bins/new/
211           cp ldk-java.jar ldk-java-bins/new/
212           cp ldk-java-classes.jar ldk-java-bins/new/
213           cp ldk-java-javadoc.jar ldk-java-bins/new/
214           cd ldk-java-bins
215           if ! diff -r "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/" new/; then
216             apt-get -y install diffoscope
217             diffoscope new/ldk-java-sources.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-sources.jar" || echo
218             diffoscope new/ldk-java-javadoc.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-javadoc.jar" || echo
219             diffoscope new/ldk-java-classes.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-classes.jar" || echo
220             diffoscope new/ldk-java.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java.jar" || echo
221             exit 1
222           fi
223       - name: Run Java Tests against built release jar
224         run: |
225           mvn install:install-file -Dfile=ldk-java.jar -DgroupId=org.lightningdevkit -DartifactId=ldk-java -Dversion=1.0-SNAPSHOT -Dpackaging=jar
226           cd javatester
227           mvn package
228           java -ea -jar target/ldk-java-tests-1.0-SNAPSHOT-jar-with-dependencies.jar
229           cd ..
230
231   android:
232     runs-on: ubuntu-latest
233     # Frankly, I'm not really sure why debian and ubuntu differ in the results here, they really shouldn't
234     container: debian:bullseye
235     strategy:
236       fail-fast: false
237     steps:
238       - name: Install rust targets
239         run: |
240           apt-get update
241           apt-get -y dist-upgrade
242           apt-get -y install git g++ clang faketime zip unzip curl openjdk-11-jdk
243           curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup.sh
244           chmod +x ./rustup.sh
245           ./rustup.sh -y
246           . $HOME/.cargo/env
247           rustup target add armv7-linux-androideabi
248           rustup target add aarch64-linux-android
249           rustup target add i686-linux-android
250           rustup target add x86_64-linux-android
251       - name: Checkout source code
252         uses: actions/checkout@v2
253         with:
254           fetch-depth: 0
255       - name: Install android NDK compilers
256         run: |
257           curl https://dl.google.com/android/repository/android-ndk-r22b-linux-x86_64.zip > android-ndk-r22b-linux-x86_64.zip
258           if [ "$(sha256sum android-ndk-r22b-linux-x86_64.zip | awk '{ print $1 }')" != "ac3a0421e76f71dd330d0cd55f9d99b9ac864c4c034fc67e0d671d022d4e806b" ]; then
259             echo "Bad hash"
260             exit 1
261           fi
262           unzip android-ndk-r22b-linux-x86_64.zip
263       - name: Install cbindgen
264         run: |
265           . $HOME/.cargo/env
266           cargo install --force cbindgen
267       - name: Checkout Rust-Lightning and LDK-C-Bindings git
268         run: |
269           git config --global user.email "ldk-ci@example.com"
270           git config --global user.name "LDK CI"
271           # Note this is a different endpoint, as we need one non-upstream commit!
272           git clone https://git.bitcoin.ninja/rust-lightning
273           cd rust-lightning
274           git checkout origin/2021-03-java-bindings-base
275           cd ..
276           git clone https://github.com/lightningdevkit/ldk-c-bindings
277           cd ldk-c-bindings
278           git checkout 0.0.105
279       - name: Checkout Android AAR binaries and artifacts
280         run: |
281           # Gitweb only allows snapshots of folders by providing the object hash, which we have to extract:
282           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
283           echo "Fetching deterministic binaries for LDK-GC ${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
284           RELEASE_PAGE="https://git.bitcoin.ninja/index.cgi?p=ldk-java-bins;a=tree;f=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE};hb=refs/heads/main"
285           SNAPSHOT_LINK="$(curl "$RELEASE_PAGE" | grep snapshot | grep -o 'href="[a-zA-Z0-9/?\.=;\-]*"' | sed 's/href="//' | tr -d '"' | grep snapshot)"
286           curl -o bins-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}"
287
288           ANDROID_PAGE="https://git.bitcoin.ninja/index.cgi?p=ldk-java-bins;a=tree;f=android-artifacts;hb=refs/heads/main"
289           SNAPSHOT_LINK="$(curl "$ANDROID_PAGE" | grep snapshot | grep -o 'href="[a-zA-Z0-9/?\.=;\-]*"' | sed 's/href="//' | tr -d '"' | grep snapshot)"
290           curl -o android-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}"
291
292           mkdir -p ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
293           cd ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
294           tar xvvf ../../bins-snapshot.tgz
295           mv ldk-java-bins-*/* ./
296           rm -r ldk-java-bins-*
297
298           mkdir -p ../android-artifacts
299           cd ../android-artifacts
300           tar xvvf ../../android-snapshot.tgz
301           mv ldk-java-bins-*/* ./
302           rm -r ldk-java-bins-*
303       - name: Build Android aar
304         run: |
305           . $HOME/.cargo/env
306           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
307           cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-classes.jar" ./
308           export ANDROID_TOOLCHAIN="$(pwd)/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64"
309           export PATH="$PATH:$ANDROID_TOOLCHAIN/bin"
310           ./android-build.sh ./rust-lightning ./ldk-c-bindings/ ./ldk-java-bins/android-artifacts
311       - name: Check latest library and jars are in bins repo
312         run: |
313           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
314           if ! diff LDK-release.aar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"LDK-release.aar; then
315             apt-get -y install diffoscope
316             diffoscope LDK-release.aar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/LDK-release.aar"
317             exit 1
318           fi
319
320   osx:
321     strategy:
322       matrix:
323         include:
324           - platform: macos-10.15
325           - platform: macos-11
326       fail-fast: false
327     runs-on: ${{ matrix.platform }}
328     steps:
329       - name: Install other Rust platforms
330         run: rustup target install aarch64-apple-darwin
331       - name: Fetch upstream LLVM/clang snapshot
332         run: |
333           wget -O clang+llvm-13.0.1-x86_64-apple-darwin.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.1/clang+llvm-13.0.1-x86_64-apple-darwin.tar.xz
334           if [ "$(shasum -a 256 clang+llvm-13.0.1-x86_64-apple-darwin.tar.xz | awk '{ print $1 }')" != "dec02d17698514d0fc7ace8869c38937851c542b02adf102c4e898f027145a4d" ]; then
335             echo "Bad hash"
336             exit 1
337           fi
338       - name: Unpack upstream LLVM+clang and use it by default
339         run: |
340           tar xvvf clang+llvm-13.0.1-x86_64-apple-darwin.tar.xz
341       - name: Checkout source code
342         uses: actions/checkout@v2
343         with:
344           fetch-depth: 0
345       - name: Install cbindgen
346         run: cargo install --force cbindgen
347       - name: Checkout Rust-Lightning and LDK-C-Bindings git
348         run: |
349           git config --global user.email "ldk-ci@example.com"
350           git config --global user.name "LDK CI"
351           # Note this is a different endpoint, as we need one non-upstream commit!
352           git clone https://git.bitcoin.ninja/rust-lightning
353           cd rust-lightning
354           git checkout origin/2021-03-java-bindings-base
355           cd ..
356           git clone https://github.com/lightningdevkit/ldk-c-bindings
357           cd ldk-c-bindings
358           git checkout 0.0.105
359       - name: Rebuild C bindings with upstream clang, and check the sample app builds + links
360         run: |
361           cd ldk-c-bindings
362           export PATH=`pwd`/clang+llvm-13.0.1-x86_64-apple-darwin/bin:$PATH
363           CC=clang ./genbindings.sh ../rust-lightning true
364           cd ..
365       - name: Fetch OpenJDK 16
366         run: |
367           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
368           if [ "$(shasum -a 256 openjdk-16.0.1_osx-x64_bin.tar.gz | awk '{ print $1 }')" != "6098f839954439d4916444757c542c1b8778a32461706812d41cc8bbefce7f2f" ]; then
369             echo "Bad hash"
370             exit 1
371           fi
372           tar xvvf openjdk-16.0.1_osx-x64_bin.tar.gz
373       - name: Checkout latest Linux binaries
374         run: |
375           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
376           echo "Fetching deterministic binaries for LDK-GC ${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
377           # Gitweb only allows snapshots of folders by providing the object hash, which we have to extract:
378           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)"
379           wget -O bins-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}"
380           mkdir -p ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
381           cd ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
382           tar xvvf ../../bins-snapshot.tgz
383           mv ldk-java-bins-*/* ./
384           cd ../..
385           mkdir -p src/main/resources/
386           cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/liblightningjni_Linux-"* src/main/resources/
387       - name: Build Java Release Bindings
388         run: |
389           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
390           export JAVA_HOME=`pwd`/jdk-16.0.1.jdk/Contents/Home
391           export PATH=$JAVA_HOME/bin:$PATH
392           export PATH=`pwd`/clang+llvm-13.0.1-x86_64-apple-darwin/bin:$PATH
393           ./genbindings.sh ./ldk-c-bindings/ "-I$JAVA_HOME/include/ -I$JAVA_HOME/include/darwin -isysroot$(xcrun --show-sdk-path)" false false
394           if [ "${{ matrix.platform }}" = "macos-11" ]; then
395             export CC="clang --target=aarch64-apple-darwin"
396             export LDK_TARGET=aarch64-apple-darwin
397             export LDK_TARGET_CPU=apple-a14
398             ./genbindings.sh ./ldk-c-bindings/ "-I$JAVA_HOME/include/ -I$JAVA_HOME/include/darwin -isysroot$(xcrun --show-sdk-path)" false false
399             cat src/main/resources/liblightningjni_MacOSX-aarch64.nativelib > /dev/null
400           fi
401       - name: Fetch Maven 3.8.4
402         run: |
403           # We don't bother using the upstream mirrors as they remove prior
404           # releases aggressively, causing spurious CI failures when we don't
405           # care about the version used.
406           wget -O apache-maven-3.8.4-bin.tar.gz https://bitcoin.ninja/apache-maven-3.8.4-bin.tar.gz
407           if [ "$(shasum -a 256 apache-maven-3.8.4-bin.tar.gz | awk '{ print $1 }')" != "2cdc9c519427bb20fdc25bef5a9063b790e4abd930e7b14b4e9f4863d6f9f13c" ]; then
408             echo "Bad hash"
409             exit 1
410           fi
411           tar xvvf apache-maven-3.8.4-bin.tar.gz
412           export PATH=apache-maven-3.8.4/bin:$PATH
413       - name: Run Java Tests against built jar
414         run: |
415           export JAVA_HOME=`pwd`/jdk-16.0.1.jdk/Contents/Home
416           export PATH=$JAVA_HOME/bin:$PATH
417           mvn -DskipTests=true package
418           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
419           JAR_VERSION=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE:1:100}
420           mvn install:install-file -Dfile=target/ldk-java-${JAR_VERSION}.jar -DgroupId=org.lightningdevkit -DartifactId=ldk-java -Dversion=1.0-SNAPSHOT -Dpackaging=jar
421           cd javatester
422           mvn -q -B package
423           java -ea -jar target/ldk-java-tests-1.0-SNAPSHOT-jar-with-dependencies.jar
424           cd ..
425       - name: Check latest release libs are in git
426         run: |
427           if [ "${{ matrix.platform }}" = "macos-11" ]; then
428             export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
429             # Sadly, OSX binaries are not currently deterministic, more debugging is needed.
430             diff "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"liblightningjni_MacOSX-x86_64.nativelib src/main/resources/liblightningjni_MacOSX-x86_64.nativelib || echo
431             diff "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"liblightningjni_MacOSX-aarch64.nativelib src/main/resources/liblightningjni_MacOSX-aarch64.nativelib || echo
432           fi
433       - name: Run Java Tests against release bins
434         run: |
435           if [ "${{ matrix.platform }}" != "macos-11" ]; then
436             export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
437             export JAVA_HOME=`pwd`/jdk-16.0.1.jdk/Contents/Home
438             export PATH=$JAVA_HOME/bin:$PATH
439             cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"liblightningjni_MacOSX-{x86_64,aarch64}.nativelib src/main/resources/
440             mvn clean
441             mvn -q -B -DskipTests=true package
442             JAR_VERSION=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE:1:100}
443             mvn install:install-file -Dfile=target/ldk-java-${JAR_VERSION}.jar -DgroupId=org.lightningdevkit -DartifactId=ldk-java -Dversion=1.0-SNAPSHOT -Dpackaging=jar
444             cd javatester
445             mvn -q -B package
446             java -ea -jar target/ldk-java-tests-1.0-SNAPSHOT-jar-with-dependencies.jar
447             cd ..
448           fi