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