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