ac30e8453320bc5dea50c1aef3bdf8495cf35129
[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 --version 0.20.0 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.106
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 --version 0.20.0 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.106
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 --version 0.20.0 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.106
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           rm src/main/resources/liblightningjni_MacOSX-*-leaktracking.nativelib
196       - name: Build Java Release Bindings
197         run: |
198           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
199           ./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
200       - name: Build deterministic release jar
201         run: ./build-release-jar.sh
202       - name: Check latest library and jars are in bins repo
203         run: |
204           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
205           mkdir ldk-java-bins/new/
206           cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"liblightningjni_Mac*.nativelib ldk-java-bins/new/
207           cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"LDK-release.aar ldk-java-bins/new/
208           # ldk-java-leaktracking is only for debug purposes and we don't bother with determinism
209           cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"ldk-java-leaktracking.jar ldk-java-bins/new/
210           cp src/main/resources/liblightningjni_Linux-amd64.nativelib ldk-java-bins/new/
211           cp ldk-java-sources.jar ldk-java-bins/new/
212           cp ldk-java.jar ldk-java-bins/new/
213           cp ldk-java-classes.jar ldk-java-bins/new/
214           cp ldk-java-javadoc.jar ldk-java-bins/new/
215           cd ldk-java-bins
216           if ! diff -r "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/" new/; then
217             apt-get -y install diffoscope
218             diffoscope new/ldk-java-sources.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-sources.jar" || echo
219             diffoscope new/ldk-java-javadoc.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-javadoc.jar" || echo
220             diffoscope new/ldk-java-classes.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-classes.jar" || echo
221             diffoscope new/ldk-java.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java.jar" || echo
222             exit 1
223           fi
224       - name: Run Java Tests against built release jar
225         run: |
226           mvn install:install-file -Dfile=ldk-java.jar -DgroupId=org.lightningdevkit -DartifactId=ldk-java -Dversion=1.0-SNAPSHOT -Dpackaging=jar
227           cd javatester
228           mvn package
229           java -ea -jar target/ldk-java-tests-1.0-SNAPSHOT-jar-with-dependencies.jar
230           cd ..
231
232   android:
233     runs-on: ubuntu-latest
234     # Frankly, I'm not really sure why debian and ubuntu differ in the results here, they really shouldn't
235     container: debian:bullseye
236     strategy:
237       fail-fast: false
238     steps:
239       - name: Install rust targets
240         run: |
241           apt-get update
242           apt-get -y dist-upgrade
243           apt-get -y install git g++ clang faketime zip unzip curl openjdk-11-jdk
244           curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup.sh
245           chmod +x ./rustup.sh
246           ./rustup.sh -y
247           . $HOME/.cargo/env
248           rustup target add armv7-linux-androideabi
249           rustup target add aarch64-linux-android
250           rustup target add i686-linux-android
251           rustup target add x86_64-linux-android
252       - name: Checkout source code
253         uses: actions/checkout@v2
254         with:
255           fetch-depth: 0
256       - name: Install android NDK compilers
257         run: |
258           curl https://dl.google.com/android/repository/android-ndk-r22b-linux-x86_64.zip > android-ndk-r22b-linux-x86_64.zip
259           if [ "$(sha256sum android-ndk-r22b-linux-x86_64.zip | awk '{ print $1 }')" != "ac3a0421e76f71dd330d0cd55f9d99b9ac864c4c034fc67e0d671d022d4e806b" ]; then
260             echo "Bad hash"
261             exit 1
262           fi
263           unzip android-ndk-r22b-linux-x86_64.zip
264       - name: Install cbindgen
265         run: |
266           . $HOME/.cargo/env
267           cargo install --version 0.20.0 cbindgen
268       - name: Checkout Rust-Lightning and LDK-C-Bindings git
269         run: |
270           git config --global user.email "ldk-ci@example.com"
271           git config --global user.name "LDK CI"
272           # Note this is a different endpoint, as we need one non-upstream commit!
273           git clone https://git.bitcoin.ninja/rust-lightning
274           cd rust-lightning
275           git checkout origin/2021-03-java-bindings-base
276           cd ..
277           git clone https://github.com/lightningdevkit/ldk-c-bindings
278           cd ldk-c-bindings
279           git checkout 0.0.106
280       - name: Checkout Android AAR binaries and artifacts
281         run: |
282           # Gitweb only allows snapshots of folders by providing the object hash, which we have to extract:
283           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
284           echo "Fetching deterministic binaries for LDK-GC ${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
285           RELEASE_PAGE="https://git.bitcoin.ninja/index.cgi?p=ldk-java-bins;a=tree;f=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE};hb=refs/heads/main"
286           SNAPSHOT_LINK="$(curl "$RELEASE_PAGE" | grep snapshot | grep -o 'href="[a-zA-Z0-9/?\.=;\-]*"' | sed 's/href="//' | tr -d '"' | grep snapshot)"
287           curl -o bins-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}"
288
289           ANDROID_PAGE="https://git.bitcoin.ninja/index.cgi?p=ldk-java-bins;a=tree;f=android-artifacts;hb=refs/heads/main"
290           SNAPSHOT_LINK="$(curl "$ANDROID_PAGE" | grep snapshot | grep -o 'href="[a-zA-Z0-9/?\.=;\-]*"' | sed 's/href="//' | tr -d '"' | grep snapshot)"
291           curl -o android-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}"
292
293           mkdir -p ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
294           cd ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
295           tar xvvf ../../bins-snapshot.tgz
296           mv ldk-java-bins-*/* ./
297           rm -r ldk-java-bins-*
298
299           mkdir -p ../android-artifacts
300           cd ../android-artifacts
301           tar xvvf ../../android-snapshot.tgz
302           mv ldk-java-bins-*/* ./
303           rm -r ldk-java-bins-*
304       - name: Build Android aar
305         run: |
306           . $HOME/.cargo/env
307           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
308           cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-classes.jar" ./
309           export ANDROID_TOOLCHAIN="$(pwd)/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64"
310           export PATH="$PATH:$ANDROID_TOOLCHAIN/bin"
311           ./android-build.sh ./rust-lightning ./ldk-c-bindings/ ./ldk-java-bins/android-artifacts
312       - name: Check latest library and jars are in bins repo
313         run: |
314           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
315           if ! diff LDK-release.aar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"LDK-release.aar; then
316             apt-get -y install diffoscope
317             diffoscope LDK-release.aar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/LDK-release.aar"
318             exit 1
319           fi
320
321   osx:
322     strategy:
323       matrix:
324         include:
325           - platform: macos-10.15
326           - platform: macos-11
327       fail-fast: false
328     runs-on: ${{ matrix.platform }}
329     steps:
330       - name: Install other Rust platforms
331         run: rustup target install aarch64-apple-darwin
332       - name: Fetch upstream LLVM/clang snapshot
333         run: |
334           wget -O clang+llvm-14.0.1-x86_64-apple-darwin.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.1/clang+llvm-14.0.1-x86_64-apple-darwin.tar.xz
335           if [ "$(shasum -a 256 clang+llvm-14.0.1-x86_64-apple-darwin.tar.xz | awk '{ print $1 }')" != "43149390e95b1cdbf1d4ef2e9d214bbb6d35858ceb2df27245868e06bc4fc44c" ]; then
336             echo "Bad hash"
337             exit 1
338           fi
339       - name: Unpack upstream LLVM+clang and use it by default
340         run: |
341           tar xvvf clang+llvm-14.0.1-x86_64-apple-darwin.tar.xz
342       - name: Checkout source code
343         uses: actions/checkout@v2
344         with:
345           fetch-depth: 0
346       - name: Install cbindgen
347         run: cargo install --version 0.20.0 cbindgen
348       - name: Checkout Rust-Lightning and LDK-C-Bindings git
349         run: |
350           git config --global user.email "ldk-ci@example.com"
351           git config --global user.name "LDK CI"
352           # Note this is a different endpoint, as we need one non-upstream commit!
353           git clone https://git.bitcoin.ninja/rust-lightning
354           cd rust-lightning
355           git checkout origin/2021-03-java-bindings-base
356           cd ..
357           git clone https://github.com/lightningdevkit/ldk-c-bindings
358           cd ldk-c-bindings
359           git checkout 0.0.106
360       - name: Rebuild C bindings with upstream clang, and check the sample app builds + links
361         run: |
362           cd ldk-c-bindings
363           export PATH=`pwd`/clang+llvm-14.0.1-x86_64-apple-darwin/bin:$PATH
364           CC=clang ./genbindings.sh ../rust-lightning true
365           cd ..
366       - name: Fetch OpenJDK 16
367         run: |
368           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
369           if [ "$(shasum -a 256 openjdk-16.0.1_osx-x64_bin.tar.gz | awk '{ print $1 }')" != "6098f839954439d4916444757c542c1b8778a32461706812d41cc8bbefce7f2f" ]; then
370             echo "Bad hash"
371             exit 1
372           fi
373           tar xvvf openjdk-16.0.1_osx-x64_bin.tar.gz
374       - name: Checkout latest Linux binaries
375         run: |
376           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
377           echo "Fetching deterministic binaries for LDK-GC ${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
378           # Gitweb only allows snapshots of folders by providing the object hash, which we have to extract:
379           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)"
380           wget -O bins-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}"
381           mkdir -p ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
382           cd ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
383           tar xvvf ../../bins-snapshot.tgz
384           mv ldk-java-bins-*/* ./
385           cd ../..
386           mkdir -p src/main/resources/
387           cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/liblightningjni_Linux-"* src/main/resources/
388       - name: Build Java Release Bindings
389         run: |
390           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
391           export JAVA_HOME=`pwd`/jdk-16.0.1.jdk/Contents/Home
392           export PATH=$JAVA_HOME/bin:$PATH
393           export PATH=`pwd`/clang+llvm-14.0.1-x86_64-apple-darwin/bin:$PATH
394           ./genbindings.sh ./ldk-c-bindings/ "-I$JAVA_HOME/include/ -I$JAVA_HOME/include/darwin -isysroot$(xcrun --show-sdk-path)" false false
395           if [ "${{ matrix.platform }}" = "macos-11" ]; then
396             export CC="clang --target=aarch64-apple-darwin"
397             export LDK_TARGET=aarch64-apple-darwin
398             export LDK_TARGET_CPU=apple-a14
399             ./genbindings.sh ./ldk-c-bindings/ "-I$JAVA_HOME/include/ -I$JAVA_HOME/include/darwin -isysroot$(xcrun --show-sdk-path)" false false
400             cat src/main/resources/liblightningjni_MacOSX-aarch64.nativelib > /dev/null
401           fi
402       - name: Fetch Maven 3.8.4
403         run: |
404           # We don't bother using the upstream mirrors as they remove prior
405           # releases aggressively, causing spurious CI failures when we don't
406           # care about the version used.
407           wget -O apache-maven-3.8.4-bin.tar.gz https://bitcoin.ninja/apache-maven-3.8.4-bin.tar.gz
408           if [ "$(shasum -a 256 apache-maven-3.8.4-bin.tar.gz | awk '{ print $1 }')" != "2cdc9c519427bb20fdc25bef5a9063b790e4abd930e7b14b4e9f4863d6f9f13c" ]; then
409             echo "Bad hash"
410             exit 1
411           fi
412           tar xvvf apache-maven-3.8.4-bin.tar.gz
413           export PATH=apache-maven-3.8.4/bin:$PATH
414       - name: Run Java Tests against built jar
415         run: |
416           export JAVA_HOME=`pwd`/jdk-16.0.1.jdk/Contents/Home
417           export PATH=$JAVA_HOME/bin:$PATH
418           mvn -DskipTests=true package
419           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
420           JAR_VERSION=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE:1:100}
421           mvn install:install-file -Dfile=target/ldk-java-${JAR_VERSION}.jar -DgroupId=org.lightningdevkit -DartifactId=ldk-java -Dversion=1.0-SNAPSHOT -Dpackaging=jar
422           cd javatester
423           mvn -q -B package
424           java -ea -jar target/ldk-java-tests-1.0-SNAPSHOT-jar-with-dependencies.jar
425           cd ..
426       - name: Check latest release libs are in git
427         run: |
428           if [ "${{ matrix.platform }}" = "macos-11" ]; then
429             export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
430             # Sadly, OSX binaries are not currently deterministic, more debugging is needed.
431             diff "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"liblightningjni_MacOSX-x86_64.nativelib src/main/resources/liblightningjni_MacOSX-x86_64.nativelib || echo
432             diff "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"liblightningjni_MacOSX-aarch64.nativelib src/main/resources/liblightningjni_MacOSX-aarch64.nativelib || echo
433           fi
434       - name: Upload CI x86_64 build for analysis
435         if: matrix.platform == 'macos-11'
436         uses: actions/upload-artifact@v3.0.0
437         with:
438           name: liblightningjni_MacOSX-x86_64.nativelib.ci-build
439           path: src/main/resources/liblightningjni_MacOSX-x86_64.nativelib
440       - name: Upload CI aarch64 build for analysis
441         if: matrix.platform == 'macos-11'
442         uses: actions/upload-artifact@v3.0.0
443         with:
444           name: liblightningjni_MacOSX-aarch64.nativelib.ci-build
445           path: src/main/resources/liblightningjni_MacOSX-aarch64.nativelib
446       - name: Run Java Tests against release bins
447         run: |
448           if [ "${{ matrix.platform }}" != "macos-11" ]; then
449             export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
450             export JAVA_HOME=`pwd`/jdk-16.0.1.jdk/Contents/Home
451             export PATH=$JAVA_HOME/bin:$PATH
452             cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"liblightningjni_MacOSX-{x86_64,aarch64}.nativelib src/main/resources/
453             mvn clean
454             mvn -q -B -DskipTests=true package
455             JAR_VERSION=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE:1:100}
456             mvn install:install-file -Dfile=target/ldk-java-${JAR_VERSION}.jar -DgroupId=org.lightningdevkit -DartifactId=ldk-java -Dversion=1.0-SNAPSHOT -Dpackaging=jar
457             cd javatester
458             mvn -q -B package
459             java -ea -jar target/ldk-java-tests-1.0-SNAPSHOT-jar-with-dependencies.jar
460             cd ..
461           fi