forked from TheBlueMatt/ldk-garbagecollected
-
Notifications
You must be signed in to change notification settings - Fork 0
778 lines (764 loc) · 40.4 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
name: Continuous Integration Checks
on: [push, pull_request]
jobs:
wasm_bindings:
runs-on: ubuntu-latest
# Ubuntu's version of clang doesn't support....anything that should work.
# Ubuntu is an utter trash OS and should generally never be used for anything.
# We also require at least rustc 1.51 (ie https://github.com/rust-lang/rust/pull/79998),
# so we use debian testing
container: debian:bookworm
strategy:
fail-fast: false
steps:
- name: Install build utilities and test that clang can build for wasm
run: |
apt-get update
apt-get -y dist-upgrade
apt-get -y install cargo libstd-rust-dev-wasm32 lld git g++ clang curl node-typescript npm python3 wasi-libc
echo "int main() {}" > genbindings_wasm_test_file.c
clang -nostdlib -o /dev/null --target=wasm32-wasi -Wl,--no-entry genbindings_wasm_test_file.c
rm genbindings_wasm_test_file.c
- name: Checkout source code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install cbindgen
run: |
git clone https://github.com/eqrion/cbindgen
cd cbindgen/
git checkout v0.20.0
cargo update -p indexmap --precise "1.6.2" --verbose
cargo install --locked --path .
- name: Checkout Rust-Lightning and LDK-C-Bindings git
run: |
git config --global safe.directory '*'
git config --global user.email "[email protected]"
git config --global user.name "LDK CI"
# Note this is a different endpoint, as we need one non-upstream commit!
git clone https://github.com/lightningdevkit/rust-lightning
cd rust-lightning
git checkout origin/0.0.121-bindings
cd ..
git clone https://github.com/lightningdevkit/ldk-c-bindings
cd ldk-c-bindings
git checkout 0.0.121
cd lightning-c-bindings
cargo update -p memchr --precise "2.5.0" --verbose
- name: Rebuild C bindings without STD
run: |
cd ldk-c-bindings
git config --global safe.directory "*"
./genbindings.sh ../rust-lightning false
- name: Build and Test TS Debug Bindings for Node
run: |
# We need FinalizationRegistry and top-level await support, which requires node 14.6/8,
# however Debian ships with Node 12
# Thus, we install the binary nodejs from nodejs.org and test with that.
curl https://nodejs.org/dist/v16.13.1/node-v16.13.1-linux-x64.tar.xz > nodejs.tar.xz
tar xvvf nodejs.tar.xz
export PATH=$(pwd)/$(echo node-*/bin):$PATH
./genbindings.sh ./ldk-c-bindings/ wasm true false
- name: Build and Test TS Release Bindings for Node
run: |
export PATH=$(pwd)/$(echo node-*/bin):$PATH
./genbindings.sh ./ldk-c-bindings/ wasm false false
- name: Install Playwright for Web Tests
run: |
export HOME=/root/ # Github actions is apparently broken
export PATH=$(pwd)/$(echo node-*/bin):$PATH
# npx playwright install-deps is broken so we do it manually, see https://github.com/microsoft/playwright/issues/11165
apt-get install -y --no-install-recommends fonts-liberation libenchant-2-2 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
mkdir -p $HOME/.cache/ms-playwright # `playwright install` is too dumb to create this for us
chmod -R 777 $HOME/
npm i -D [email protected]
npx [email protected] install
- name: Build and Test TS Debug Bindings for Web
run: |
export HOME=/root/ # Github actions is apparently broken
export PATH=$(pwd)/$(echo node-*/bin):$PATH
git config --global safe.directory "*"
./genbindings.sh ./ldk-c-bindings/ wasm true true
cd ts
rm liblightningjs.wasm && ln -s $(pwd)/../liblightningjs_debug.wasm ./liblightningjs.wasm
python3 -m http.server &
SERVER_PID=$!
node test/browser.mjs
kill $SERVER_PID
- name: Build and Test TS Release Bindings for Web
run: |
export HOME=/root/ # Github actions is apparently broken
export PATH=$(pwd)/$(echo node-*/bin):$PATH
./genbindings.sh ./ldk-c-bindings/ wasm false true
cd ts
rm liblightningjs.wasm && ln -s $(pwd)/../liblightningjs_release.wasm ./liblightningjs.wasm
python3 -m http.server &
SERVER_PID=$!
node test/browser.mjs
kill $SERVER_PID
- name: Check latest TS files are in git
run: |
git checkout ts/package.json
git checkout node-net/package.json
git diff --exit-code
c_sharp_bindings:
runs-on: ubuntu-latest
# Ubuntu's version of clang doesn't support....anything that should work.
# Ubuntu is an utter trash OS and should generally never be used for anything.
# We also require at least rustc 1.51 (ie https://github.com/rust-lang/rust/pull/79998),
# so we use debian testing
container: debian:bookworm
strategy:
fail-fast: false
steps:
- name: Install required dependencies
run: |
apt-get update
apt-get -y dist-upgrade
apt-get -y install cargo lld llvm git g++ clang curl python3 mono-devel
- name: Checkout source code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install cbindgen
run: |
git clone https://github.com/eqrion/cbindgen
cd cbindgen/
git checkout v0.20.0
cargo update -p indexmap --precise "1.6.2" --verbose
cargo install --locked --path .
- name: Checkout Rust-Lightning and LDK-C-Bindings git
run: |
git config --global safe.directory '*'
git config --global user.email "[email protected]"
git config --global user.name "LDK CI"
# Note this is a different endpoint, as we need one non-upstream commit!
git clone https://github.com/lightningdevkit/rust-lightning
cd rust-lightning
git checkout origin/0.0.121-bindings
cd ..
git clone https://github.com/lightningdevkit/ldk-c-bindings
cd ldk-c-bindings
git checkout 0.0.121
cd lightning-c-bindings
cargo update -p memchr --precise "2.5.0" --verbose
- name: Rebuild C bindings with STD
run: |
cd ldk-c-bindings
git config --global safe.directory "*"
./genbindings.sh ../rust-lightning true
- name: Build and Test C# Debug Bindings
run: |
./genbindings.sh ./ldk-c-bindings/ c_sharp true true
mono-csc -out:test.exe -langversion:3 -unsafe c_sharp/src/org/ldk/enums/*.cs c_sharp/src/org/ldk/impl/*.cs c_sharp/src/org/ldk/util/*.cs c_sharp/src/org/ldk/structs/*.cs c_sharp/test/src/tests.cs
ln -s libldkcsharp_debug_Linux-amd64.so libldkcsharp.so
export ASAN_OPTIONS=detect_leaks=0
LD_PRELOAD=/usr/lib/llvm-14/lib/clang/14.0.6/lib/linux/libclang_rt.asan-x86_64.so mono test.exe
c_sharp_determinism:
runs-on: ubuntu-latest
# Ubuntu's version of clang doesn't support....anything that should work.
# Ubuntu is an utter trash OS and should generally never be used for anything.
# We also require dotnet so we use fedora
container: fedora:39
strategy:
fail-fast: false
steps:
- name: Install required dependencies
run: |
dnf install -y mingw64-gcc git cargo dotnet clang llvm lld faketime rust-std-static-x86_64-pc-windows-gnu which diffutils
- name: Checkout source code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install cbindgen
run: |
cargo install cbindgen
- name: Checkout Rust-Lightning and LDK-C-Bindings git
run: |
git config --global safe.directory '*'
git config --global user.email "[email protected]"
git config --global user.name "LDK CI"
# Note this is a different endpoint, as we need one non-upstream commit!
git clone https://github.com/lightningdevkit/rust-lightning
cd rust-lightning
git checkout origin/0.0.121-bindings
cd ..
git clone https://github.com/lightningdevkit/ldk-c-bindings
cd ldk-c-bindings
git checkout 0.0.121
- name: Rebuild C bindings with STD
run: |
cd ldk-c-bindings
export LDK_C_BINDINGS_EXTRA_TARGETS=x86_64-pc-windows-gnu
export LDK_C_BINDINGS_EXTRA_TARGET_CCS=`pwd`/deterministic-build-wrappers/clang-x86_64-windows
export LDK_C_BINDINGS_EXTRA_TARGET_LINK_LTO=true
./genbindings.sh ../rust-lightning true
- name: Remove checked-in source to ensure its correctly checked-in
run: rm c_sharp/src/org/ldk/enums/*.cs c_sharp/src/org/ldk/impl/*.cs c_sharp/src/org/ldk/structs/*.cs
- name: Build Windows C# Bindings
run: |
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
LDK_TARGET=x86_64-pc-windows-gnu LDK_TARGET_CPU=sandybridge ./genbindings.sh ./ldk-c-bindings/ c_sharp false false
- name: Build Linux C# Bindings
run: |
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
./genbindings.sh ./ldk-c-bindings/ c_sharp false false
- name: Build Release NUPKG
run: |
cd c_sharp
./build-release-nupkg.sh
- uses: actions/upload-artifact@v3
with:
name: org.ldk.nupkg
path: c_sharp/org.ldk.nupkg
- name: Check latest auto-generated code is in git
run: |
# Checkout files that get updated with version information
git checkout c_sharp/packaging_artifacts/package/services/metadata/core-properties/ldk.psmdcp
git checkout c_sharp/packaging_artifacts/org.ldk.nuspec
git diff --exit-code
- name: Checkout latest binaries
shell: bash
run: |
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
echo "Fetching deterministic binaries for LDK-GC ${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
# Gitweb only allows snapshots of folders by providing the object hash, which we have to extract:
SNAPSHOT_LINK="$(curl "https://git.bitcoin.ninja/index.cgi?p=ldk-java-bins;a=tree;f=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE};hb=refs/heads/main" | grep snapshot | grep -o 'href="[a-zA-Z0-9/?\.=;\-]*"' | sed 's/href="//' | tr -d '"' | grep snapshot)"
curl -o bins-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}"
mkdir -p ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
cd ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
tar xvvf ../../bins-snapshot.tgz
mv ldk-java-bins-*/* ./
rm -r ldk-java-bins-*
- name: Compare C# nupkg with built one
shell: bash
run: |
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
if ! diff ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"org.ldk.nupkg c_sharp/org.ldk.nupkg; then
dnf -y install diffoscope
diffoscope ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"org.ldk.nupkg c_sharp/org.ldk.nupkg || echo
exit 1
fi
java_bindings:
runs-on: ubuntu-latest
# Ubuntu's version of rustc uses its own LLVM instead of being a real native package.
# This leaves us with an incompatible LLVM version when linking. Instead, use a real OS.
container: debian:bookworm
strategy:
fail-fast: false
steps:
- name: Install native Rust toolchain, Valgrind, and build utilitis
run: |
apt-get update
apt-get -y dist-upgrade
apt-get -y install cargo valgrind lld git g++ clang openjdk-17-jdk maven faketime zip unzip llvm curl
- name: Checkout source code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install cbindgen
run: |
git config --global safe.directory '*'
git clone https://github.com/eqrion/cbindgen
cd cbindgen/
git checkout v0.20.0
cargo update -p indexmap --precise "1.6.2" --verbose
cargo install --locked --path .
- name: Checkout Rust-Lightning and LDK-C-Bindings git
run: |
git config --global user.email "[email protected]"
git config --global user.name "LDK CI"
# Note this is a different endpoint, as we need one non-upstream commit!
git clone https://github.com/lightningdevkit/rust-lightning
cd rust-lightning
git checkout origin/0.0.121-bindings
cd ..
git clone https://github.com/lightningdevkit/ldk-c-bindings
cd ldk-c-bindings
git checkout 0.0.121
cd lightning-c-bindings
cargo update -p memchr --precise "2.5.0" --verbose
- name: Pin proc-macro and quote to meet MSRV
run: |
cd ldk-c-bindings/c-bindings-gen
cargo update -p quote --precise "1.0.30" --verbose
cargo update -p proc-macro2 --precise "1.0.65" --verbose
- name: Rebuild C bindings, and check the sample app builds + links
run: |
cd ldk-c-bindings
./genbindings.sh ../rust-lightning true
- name: Build Java Debug Bindings
run: ./genbindings.sh ./ldk-c-bindings/ "-I/usr/lib/jvm/java-17-openjdk-amd64/include/ -I/usr/lib/jvm/java-17-openjdk-amd64/include/linux/" true false
- name: Run Java Tests against Debug Bindings
run: |
mv liblightningjni_debug_Linux-amd64.so liblightningjni.so
export ASAN_OPTIONS=detect_leaks=0
LD_PRELOAD=/usr/lib/llvm-14/lib/clang/14.0.6/lib/linux/libclang_rt.asan-x86_64.so LD_LIBRARY_PATH=. mvn test
- name: Build Java Release Bindings
run: |
./genbindings.sh ./ldk-c-bindings/ "-I/usr/lib/jvm/java-17-openjdk-amd64/include/ -I/usr/lib/jvm/java-17-openjdk-amd64/include/linux/" false false
- name: Check latest headers are in git
run: |
git checkout pom.xml
git diff --exit-code
java_determinism:
runs-on: ubuntu-latest
# Ubuntu's version of rustc uses its own LLVM instead of being a real native package.
# This leaves us with an incompatible LLVM version when linking. Instead, use a real OS.
container: debian:bookworm
strategy:
fail-fast: false
steps:
- name: Install native Rust toolchain, Valgrind, and build utilitis
run: |
apt-get update
apt-get -y dist-upgrade
apt-get -y install cargo valgrind lld git g++ clang openjdk-17-jdk maven faketime zip unzip llvm curl
- name: Checkout source code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install cbindgen
run: |
git config --global safe.directory '*'
git clone https://github.com/eqrion/cbindgen
cd cbindgen/
git checkout v0.20.0
cargo update -p indexmap --precise "1.6.2" --verbose
cargo install --locked --path .
- name: Checkout Rust-Lightning and LDK-C-Bindings git
run: |
git config --global user.email "[email protected]"
git config --global user.name "LDK CI"
# Note this is a different endpoint, as we need one non-upstream commit!
git clone https://github.com/lightningdevkit/rust-lightning
cd rust-lightning
git checkout origin/0.0.121-bindings
cd ..
git clone https://github.com/lightningdevkit/ldk-c-bindings
cd ldk-c-bindings
git checkout 0.0.121
cd lightning-c-bindings
cargo update -p memchr --precise "2.5.0" --verbose
- name: Pin proc-macro and quote to meet MSRV
run: |
cd ldk-c-bindings/c-bindings-gen
cargo update -p quote --precise "1.0.30" --verbose
cargo update -p proc-macro2 --precise "1.0.65" --verbose
- name: Rebuild C bindings, and check the sample app builds + links
run: |
cd ldk-c-bindings
./genbindings.sh ../rust-lightning true
- name: Checkout latest MacOS binaries
shell: bash
run: |
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
echo "Fetching deterministic binaries for LDK-GC ${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
# Gitweb only allows snapshots of folders by providing the object hash, which we have to extract:
SNAPSHOT_LINK="$(curl "https://git.bitcoin.ninja/index.cgi?p=ldk-java-bins;a=tree;f=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE};hb=refs/heads/main" | grep snapshot | grep -o 'href="[a-zA-Z0-9/?\.=;\-]*"' | sed 's/href="//' | tr -d '"' | grep snapshot)"
curl -o bins-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}"
mkdir -p ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
cd ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
tar xvvf ../../bins-snapshot.tgz
mv ldk-java-bins-*/* ./
rm -r ldk-java-bins-*
cd ../..
mkdir -p src/main/resources/
- name: Copy latest MacOS leaktracking libs
run: |
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"liblightningjni_MacOSX-aarch64-leaktracking.nativelib src/main/resources/liblightningjni_MacOSX-aarch64.nativelib
cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"liblightningjni_MacOSX-x86_64-leaktracking.nativelib src/main/resources/liblightningjni_MacOSX-x86_64.nativelib
- name: Build Leaktracking Java Release Bindings
run: |
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
./genbindings.sh ./ldk-c-bindings/ "-I/usr/lib/jvm/java-17-openjdk-amd64/include/ -I/usr/lib/jvm/java-17-openjdk-amd64/include/linux/" leaks false
- name: Build deterministic release jar
run: |
./build-release-jar.sh
mv ldk-java.jar ldk-java-leaktracking.jar
- name: Copy latest MacOS libs
shell: bash
run: |
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/liblightningjni_MacOSX-"{aarch64,x86_64}.nativelib src/main/resources/
- name: Build Java leaktracking Bindings
run: |
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
./genbindings.sh ./ldk-c-bindings/ "-I/usr/lib/jvm/java-17-openjdk-amd64/include/ -I/usr/lib/jvm/java-17-openjdk-amd64/include/linux/" leaks false
mkdir ldk-java-bins/new/
cp src/main/resources/liblightningjni_Linux-amd64.nativelib ldk-java-bins/new/liblightningjni_Linux-amd64-leaktracking.nativelib
- name: Build Java Release Bindings
run: |
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
./genbindings.sh ./ldk-c-bindings/ "-I/usr/lib/jvm/java-17-openjdk-amd64/include/ -I/usr/lib/jvm/java-17-openjdk-amd64/include/linux/" false false
- name: Build deterministic release jar
run: ./build-release-jar.sh
- uses: actions/upload-artifact@v3
with:
name: ldk-java.jar
path: ldk-java.jar
- uses: actions/upload-artifact@v3
with:
name: ldk-java-leaktracking.jar
path: ldk-java-leaktracking.jar
- name: Check latest library and jars are in bins repo
run: |
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"liblightningjni_Mac*.nativelib ldk-java-bins/new/
cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"LDK-release.aar ldk-java-bins/new/
cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"org.ldk.nupkg ldk-java-bins/new/
cp src/main/resources/liblightningjni_Linux-amd64.nativelib ldk-java-bins/new/
cp ldk-java-sources.jar ldk-java-bins/new/
cp ldk-java.jar ldk-java-bins/new/
cp ldk-java-leaktracking.jar ldk-java-bins/new/
cp ldk-java-classes.jar ldk-java-bins/new/
cd ldk-java-bins
rm "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/liblightningjs.wasm" # TODO: Test this
if ! diff -r "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/" new/; then
apt-get -y install diffoscope
diffoscope new/ldk-java-sources.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-sources.jar" || echo
diffoscope new/ldk-java-classes.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-classes.jar" || echo
diffoscope new/ldk-java.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java.jar" || echo
diffoscope new/ldk-java-leaktracking.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-leaktracking.jar" || echo
exit 1
fi
- name: Run Java Tests against built release jar
run: |
mvn install:install-file -Dfile=ldk-java.jar -DgroupId=org.lightningdevkit -DartifactId=ldk-java -Dversion=1.0-SNAPSHOT -Dpackaging=jar
cd javatester
mvn package
java -ea -jar target/ldk-java-tests-1.0-SNAPSHOT-jar-with-dependencies.jar
macos_determinism:
runs-on: ubuntu-latest
# Ubuntu's version of rustc uses its own LLVM instead of being a real native package.
# This leaves us with an incompatible LLVM version when linking. Instead, use a real OS.
container: debian:bookworm
strategy:
fail-fast: false
steps:
- name: Install native Rust toolchain, Valgrind, and build utilitis
run: |
apt-get update
apt-get -y dist-upgrade
apt-get -y install cargo valgrind openjdk-17-jdk lld git g++ clang llvm curl rust-src
- name: Checkout source code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install cbindgen
run: |
git config --global safe.directory '*'
git clone https://github.com/eqrion/cbindgen
cd cbindgen/
git checkout v0.20.0
cargo update -p indexmap --precise "1.6.2" --verbose
cargo install --locked --path .
- name: Checkout Rust-Lightning and LDK-C-Bindings git
run: |
git config --global user.email "[email protected]"
git config --global user.name "LDK CI"
# Note this is a different endpoint, as we need one non-upstream commit!
git clone https://github.com/lightningdevkit/rust-lightning
cd rust-lightning
git checkout origin/0.0.121-bindings
cd ..
git clone https://github.com/lightningdevkit/ldk-c-bindings
cd ldk-c-bindings
git checkout 0.0.121
- name: Fetch MacOS SDK
run: |
curl -o Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers.tar.gz https://bitcoincore.org/depends-sources/sdks/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers.tar.gz
tar xvvf Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers.tar.gz
- name: Rebuild C bindings, and check the sample app builds + links
run: |
# rust-src doesn't distribute the rustlib Cargo.lock, but an empty
# file seems to suffice to make `-Zbuild-std` happy.
touch /usr/lib/rustlib/src/rust/Cargo.lock
export MACOS_SDK="$PWD/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers"
cd ldk-c-bindings
./genbindings.sh ../rust-lightning true
- name: Fetch MacOS OpenJDK 18 for x86_64
run: |
curl -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
if [ "$(shasum -a 256 openjdk-18.0.1.1_macos-x64_bin.tar.gz | awk '{ print $1 }')" != "f02d17ec5a387555f8489abc352d973b6c10364409b597046025938e2266d72a" ]; then
echo "Bad hash"
exit 1
fi
mkdir jdk-x86_64
cd jdk-x86_64
tar xvvf ../openjdk-18.0.1.1_macos-x64_bin.tar.gz
- name: Fetch MacOS OpenJDK 18 for aarch64
run: |
curl -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
if [ "$(shasum -a 256 openjdk-18.0.1.1_macos-aarch64_bin.tar.gz | awk '{ print $1 }')" != "29773ad68063bdad7fbaeb762cd873d3f243e86de380d3ac5335cdb929371fb5" ]; then
echo "Bad hash"
exit 1
fi
mkdir jdk-aarch64
cd jdk-aarch64
tar xvvf ../openjdk-18.0.1.1_macos-aarch64_bin.tar.gz
- name: Build MacOS aarch64 Java leaktracking Release Bindings
run: |
MACOS_SDK="$PWD/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers"
JAVA_HOME=jdk-aarch64/jdk-18.0.1.1.jdk/Contents/Home
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
CC=clang LDK_TARGET=aarch64-apple-darwin LDK_TARGET_CPU=apple-a14 ./genbindings.sh ./ldk-c-bindings/ "-I$JAVA_HOME/include/ -I$JAVA_HOME/include/darwin -isysroot$MACOS_SDK" leaks false
mv src/main/resources/liblightningjni_MacOSX-aarch64.nativelib src/main/resources/liblightningjni_MacOSX-aarch64-leaktracking.nativelib
- name: Build MacOS x86_64 Java leaktracking Release Bindings
run: |
MACOS_SDK="$PWD/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers"
JAVA_HOME=jdk-x86_64/jdk-18.0.1.1.jdk/Contents/Home
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
CC=clang LDK_TARGET=x86_64-apple-darwin LDK_TARGET_CPU=sandybridge ./genbindings.sh ./ldk-c-bindings/ "-I$JAVA_HOME/include/ -I$JAVA_HOME/include/darwin -isysroot$MACOS_SDK" leaks false
mv src/main/resources/liblightningjni_MacOSX-x86_64.nativelib src/main/resources/liblightningjni_MacOSX-x86_64-leaktracking.nativelib
- name: Build MacOS aarch64 Java Release Bindings
run: |
MACOS_SDK="$PWD/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers"
JAVA_HOME=jdk-aarch64/jdk-18.0.1.1.jdk/Contents/Home
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
CC=clang LDK_TARGET=aarch64-apple-darwin LDK_TARGET_CPU=apple-a14 ./genbindings.sh ./ldk-c-bindings/ "-I$JAVA_HOME/include/ -I$JAVA_HOME/include/darwin -isysroot$MACOS_SDK" false false
- name: Build MacOS x86_64 Java Release Bindings
run: |
MACOS_SDK="$PWD/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers"
JAVA_HOME=jdk-x86_64/jdk-18.0.1.1.jdk/Contents/Home
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
CC=clang LDK_TARGET=x86_64-apple-darwin LDK_TARGET_CPU=sandybridge ./genbindings.sh ./ldk-c-bindings/ "-I$JAVA_HOME/include/ -I$JAVA_HOME/include/darwin -isysroot$MACOS_SDK" false false
- name: Checkout latest binaries
run: |
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
echo "Fetching deterministic binaries for LDK-GC ${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
# Gitweb only allows snapshots of folders by providing the object hash, which we have to extract:
SNAPSHOT_LINK="$(curl "https://git.bitcoin.ninja/index.cgi?p=ldk-java-bins;a=tree;f=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE};hb=refs/heads/main" | grep snapshot | grep -o 'href="[a-zA-Z0-9/?\.=;\-]*"' | sed 's/href="//' | tr -d '"' | grep snapshot)"
curl -o bins-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}"
mkdir -p ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
cd ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
tar xvvf ../../bins-snapshot.tgz
mv ldk-java-bins-*/* ./
rm -r ldk-java-bins-*
cd ../..
- name: Check latest MacOS libraries are in the bins repo
shell: bash
run: |
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
for F in liblightningjni_MacOSX-{x86_64,aarch64}{,-leaktracking}.nativelib; do
if ! diff "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/$F" "src/main/resources/$F"; then
apt-get -y install diffoscope
# Sadly these binaries are still non-deterministic, but only due
# to a few-byte tag, thus we use diffoscope to ensure there
# aren't any "real" differences and move on.
diffoscope "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/$F" "src/main/resources/$F" || echo
fi
done
android:
runs-on: ubuntu-latest
# Frankly, I'm not really sure why debian and ubuntu differ in the results here, they really shouldn't
container: debian:bullseye
strategy:
fail-fast: false
steps:
- name: Install rust targets
run: |
apt-get update
apt-get -y dist-upgrade
apt-get -y install git g++ clang faketime zip unzip curl openjdk-17-jdk
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup.sh
chmod +x ./rustup.sh
./rustup.sh -y
. $HOME/.cargo/env
# Temporarily use 1.67.1 to fix https://github.com/rust-lang/rust/issues/108943
rustup install 1.67.1
rustup default 1.67.1
rustup target add armv7-linux-androideabi
rustup target add aarch64-linux-android
rustup target add i686-linux-android
rustup target add x86_64-linux-android
- name: Checkout source code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install android NDK compilers
run: |
git config --global safe.directory '*'
curl https://dl.google.com/android/repository/android-ndk-r22b-linux-x86_64.zip > android-ndk-r22b-linux-x86_64.zip
if [ "$(sha256sum android-ndk-r22b-linux-x86_64.zip | awk '{ print $1 }')" != "ac3a0421e76f71dd330d0cd55f9d99b9ac864c4c034fc67e0d671d022d4e806b" ]; then
echo "Bad hash"
exit 1
fi
unzip android-ndk-r22b-linux-x86_64.zip
- name: Install cbindgen
run: |
. $HOME/.cargo/env
cargo install cbindgen
- name: Checkout Rust-Lightning and LDK-C-Bindings git
run: |
git config --global user.email "[email protected]"
git config --global user.name "LDK CI"
# Note this is a different endpoint, as we need one non-upstream commit!
git clone https://github.com/lightningdevkit/rust-lightning
cd rust-lightning
git checkout origin/0.0.121-bindings
cd ..
git clone https://github.com/lightningdevkit/ldk-c-bindings
cd ldk-c-bindings
git checkout 0.0.121
cd lightning-c-bindings
. $HOME/.cargo/env
cargo update -p memchr --precise "2.5.0" --verbose
- name: Checkout Android AAR binaries and artifacts
run: |
# Gitweb only allows snapshots of folders by providing the object hash, which we have to extract:
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
echo "Fetching deterministic binaries for LDK-GC ${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
RELEASE_PAGE="https://git.bitcoin.ninja/index.cgi?p=ldk-java-bins;a=tree;f=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE};hb=refs/heads/main"
SNAPSHOT_LINK="$(curl "$RELEASE_PAGE" | grep snapshot | grep -o 'href="[a-zA-Z0-9/?\.=;\-]*"' | sed 's/href="//' | tr -d '"' | grep snapshot)"
curl -o bins-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}"
ANDROID_PAGE="https://git.bitcoin.ninja/index.cgi?p=ldk-java-bins;a=tree;f=android-artifacts;hb=refs/heads/main"
SNAPSHOT_LINK="$(curl "$ANDROID_PAGE" | grep snapshot | grep -o 'href="[a-zA-Z0-9/?\.=;\-]*"' | sed 's/href="//' | tr -d '"' | grep snapshot)"
curl -o android-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}"
mkdir -p ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
cd ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
tar xvvf ../../bins-snapshot.tgz
mv ldk-java-bins-*/* ./
rm -r ldk-java-bins-*
mkdir -p ../android-artifacts
cd ../android-artifacts
tar xvvf ../../android-snapshot.tgz
mv ldk-java-bins-*/* ./
rm -r ldk-java-bins-*
- name: Build Android aar
run: |
. $HOME/.cargo/env
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-classes.jar" ./
export ANDROID_TOOLCHAIN="$(pwd)/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64"
export PATH="$PATH:$ANDROID_TOOLCHAIN/bin"
./android-build.sh ./rust-lightning ./ldk-c-bindings/ ./ldk-java-bins/android-artifacts
- uses: actions/upload-artifact@v3
with:
name: LDK-release.aar
path: LDK-release.aar
- name: Check latest library and jars are in bins repo
run: |
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
if ! diff LDK-release.aar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"LDK-release.aar; then
apt-get -y install diffoscope
diffoscope LDK-release.aar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/LDK-release.aar"
exit 1
fi
osx:
strategy:
matrix:
include:
- platform: macos-11
- platform: macos-12
- platform: macos-13
fail-fast: false
runs-on: ${{ matrix.platform }}
steps:
- name: Install Rust components
run: |
rustup target install aarch64-apple-darwin
rustup component add rust-src
- name: Checkout source code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install cbindgen
run: cargo install cbindgen
- name: Checkout Rust-Lightning and LDK-C-Bindings git
run: |
git config --global user.email "[email protected]"
git config --global user.name "LDK CI"
# Note this is a different endpoint, as we need one non-upstream commit!
git clone https://github.com/lightningdevkit/rust-lightning
cd rust-lightning
git checkout origin/0.0.121-bindings
cd ..
git clone https://github.com/lightningdevkit/ldk-c-bindings
cd ldk-c-bindings
git checkout 0.0.121
cd lightning-c-bindings
cargo update -p memchr --precise "2.5.0" --verbose
- name: Rebuild C bindings and check the sample app builds + links
run: |
cd ldk-c-bindings
CC=clang ./genbindings.sh ../rust-lightning true
- name: Fetch OpenJDK 18
run: |
if [ "$(uname -m)" = "arm64" ]; then
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
if [ "$(shasum -a 256 openjdk-18.0.1.1_macos-aarch64_bin.tar.gz | awk '{ print $1 }')" != "29773ad68063bdad7fbaeb762cd873d3f243e86de380d3ac5335cdb929371fb5" ]; then
echo "Bad hash"
exit 1
fi
tar xvvf openjdk-18.0.1.1_macos-aarch64_bin.tar.gz
else
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
if [ "$(shasum -a 256 openjdk-18.0.1.1_macos-x64_bin.tar.gz | awk '{ print $1 }')" != "f02d17ec5a387555f8489abc352d973b6c10364409b597046025938e2266d72a" ]; then
echo "Bad hash"
exit 1
fi
tar xvvf openjdk-18.0.1.1_macos-x64_bin.tar.gz
fi
- name: Checkout latest Linux binaries
run: |
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
echo "Fetching deterministic binaries for LDK-GC ${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
# Gitweb only allows snapshots of folders by providing the object hash, which we have to extract:
SNAPSHOT_LINK="$(wget -O /dev/stdout "https://git.bitcoin.ninja/index.cgi?p=ldk-java-bins;a=tree;f=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE};hb=refs/heads/main" | grep snapshot | grep -o 'href="[a-zA-Z0-9/?\.=;\-]*"' | sed 's/href="//' | tr -d '"' | grep snapshot)"
wget -O bins-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}"
mkdir -p ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
cd ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
tar xvvf ../../bins-snapshot.tgz
mv ldk-java-bins-*/* ./
cd ../..
mkdir -p src/main/resources/
cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/liblightningjni_Linux-"* src/main/resources/
- name: Build Java Release Bindings
run: |
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
export JAVA_HOME=`pwd`/jdk-18.0.1.1.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
./genbindings.sh ./ldk-c-bindings/ "-I$JAVA_HOME/include/ -I$JAVA_HOME/include/darwin -isysroot$(xcrun --show-sdk-path)" false false
if [ "${{ matrix.platform }}" = "macos-11" ]; then
export CC="clang --target=aarch64-apple-darwin"
export LDK_TARGET=aarch64-apple-darwin
export LDK_TARGET_CPU=apple-a14
./genbindings.sh ./ldk-c-bindings/ "-I$JAVA_HOME/include/ -I$JAVA_HOME/include/darwin -isysroot$(xcrun --show-sdk-path)" false false
cat src/main/resources/liblightningjni_MacOSX-aarch64.nativelib > /dev/null
fi
- name: Fetch Maven 3.8.4
run: |
# We don't bother using the upstream mirrors as they remove prior
# releases aggressively, causing spurious CI failures when we don't
# care about the version used.
wget -O apache-maven-3.8.4-bin.tar.gz https://bitcoin.ninja/apache-maven-3.8.4-bin.tar.gz
if [ "$(shasum -a 256 apache-maven-3.8.4-bin.tar.gz | awk '{ print $1 }')" != "2cdc9c519427bb20fdc25bef5a9063b790e4abd930e7b14b4e9f4863d6f9f13c" ]; then
echo "Bad hash"
exit 1
fi
tar xvvf apache-maven-3.8.4-bin.tar.gz
export PATH=apache-maven-3.8.4/bin:$PATH
- name: Run Java Tests against built jar
run: |
export JAVA_HOME=`pwd`/jdk-18.0.1.1.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
mvn -DskipTests=true package
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
JAR_VERSION=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE:1:100}
mvn install:install-file -Dfile=target/ldk-java-${JAR_VERSION}.jar -DgroupId=org.lightningdevkit -DartifactId=ldk-java -Dversion=1.0-SNAPSHOT -Dpackaging=jar
cd javatester
mvn -q -B package
java -ea -jar target/ldk-java-tests-1.0-SNAPSHOT-jar-with-dependencies.jar
- name: Run Java Tests against release bins
run: |
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
export JAVA_HOME=`pwd`/jdk-18.0.1.1.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java.jar" ./
mvn install:install-file -Dfile=ldk-java.jar -DgroupId=org.lightningdevkit -DartifactId=ldk-java -Dversion=1.0-SNAPSHOT -Dpackaging=jar
cd javatester
mvn clean
mvn -q -B package
java -ea -jar target/ldk-java-tests-1.0-SNAPSHOT-jar-with-dependencies.jar