Skip to content

Commit 943ba90

Browse files
committed
Deterministically build the jars and check in CI, from a new repo
1 parent 61378e1 commit 943ba90

File tree

1 file changed

+45
-15
lines changed

1 file changed

+45
-15
lines changed

.github/workflows/build.yml

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
run: |
1616
apt-get update
1717
apt-get -y dist-upgrade
18-
apt-get -y install cargo libstd-rust-dev-wasm32 valgrind lld git g++ clang openjdk-11-jdk maven
18+
apt-get -y install cargo libstd-rust-dev-wasm32 valgrind lld git g++ clang openjdk-11-jdk maven faketime zip unzip
1919
- name: Checkout source code
2020
uses: actions/checkout@v2
2121
with:
@@ -26,11 +26,10 @@ jobs:
2626
run: |
2727
git config --global user.email "[email protected]"
2828
git config --global user.name "LDK CI"
29-
git clone https://github.com/rust-bitcoin/rust-lightning
29+
# Note this is a different endpoint, as we need one non-upstream commit!
30+
git clone https://git.bitcoin.ninja/rust-lightning
3031
cd rust-lightning
31-
git remote add matt https://git.bitcoin.ninja/rust-lightning
32-
git fetch matt
33-
git merge matt/2021-03-java-bindings-base
32+
git checkout origin/2021-03-java-bindings-base
3433
cd ..
3534
git clone https://github.com/lightningdevkit/ldk-c-bindings
3635
- name: Rebuild C bindings without STD for WASM
@@ -54,7 +53,7 @@ jobs:
5453
mv liblightningjni_debug_Linux-amd64.so liblightningjni.so
5554
export ASAN_OPTIONS=detect_leaks=0
5655
LD_PRELOAD=/usr/lib/llvm-11/lib/clang/11.0.1/lib/linux/libclang_rt.asan-x86_64.so LD_LIBRARY_PATH=. mvn test
57-
- name: Build Java/TS Release Bindings
56+
- name: Detect current git version
5857
run: |
5958
# We assume the top commit is just a bindings update commit, so we
6059
# check out the previous commit to use as the commit we git describe.
@@ -68,18 +67,37 @@ jobs:
6867
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag $MERGE_HEAD^1)"
6968
fi
7069
echo "Using $LDK_GARBAGECOLLECTED_GIT_OVERRIDE as git version"
71-
./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
72-
- name: Check latest headers and release lib are in git
70+
echo "$LDK_GARBAGECOLLECTED_GIT_OVERRIDE" > .git_ver
71+
- name: Checkout latest MacOS binaries
7372
run: |
74-
git diff --exit-code
73+
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(cat .git_ver)"
74+
git clone https://git.bitcoin.ninja/ldk-java-bins
75+
mkdir -p src/main/resources/
76+
cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/liblightningjni_MacOSX-*" src/main/resources/
77+
- name: Build Java/TS Release Bindings
78+
run: |
79+
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(cat .git_ver)"
80+
./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
81+
- name: Build deterministic release jar
82+
run: ./build-release-jar.sh
7583
- name: Run Java Tests against built release jar
7684
run: |
77-
mvn -DskipTests=true package
7885
mvn install:install-file -Dfile=target/ldk-java-1.0-SNAPSHOT.jar -DgroupId=org.ldk -DartifactId=ldk-java -Dversion=1.0-SNAPSHOT -Dpackaging=jar
7986
cd javatester
8087
mvn package
8188
java -ea -jar target/ldk-java-tests-1.0-SNAPSHOT-jar-with-dependencies.jar
8289
cd ..
90+
- name: Check latest headers are in git
91+
run: |
92+
git diff --exit-code
93+
- name: Check latest library and jars are in bins repo
94+
run: |
95+
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(cat .git_ver)"
96+
cp src/main/resources/liblightningjni_Linux-amd64.nativelib "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"
97+
cp target/ldk-java-1.0-SNAPSHOT.jar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"
98+
cp target/ldk-java-1.0-SNAPSHOT-sources.jar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"
99+
cd ldk-java-bins
100+
git diff --exit-code
83101
84102
osx:
85103
strategy:
@@ -137,7 +155,7 @@ jobs:
137155
tar xvvf openjdk-16.0.1_osx-x64_bin.tar.gz
138156
export JAVA_HOME=`pwd`/jdk-16.0.1.jdk/Contents/Home
139157
export PATH=$JAVA_HOME/bin:$PATH
140-
- name: Build Java/TS Release Bindings
158+
- name: Detect current git version
141159
run: |
142160
# We assume the top commit is just a bindings update commit, so we
143161
# check out the previous commit to use as the commit we git describe.
@@ -151,10 +169,19 @@ jobs:
151169
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag $MERGE_HEAD^1)"
152170
fi
153171
echo "Using $LDK_GARBAGECOLLECTED_GIT_OVERRIDE as git version"
172+
echo "$LDK_GARBAGECOLLECTED_GIT_OVERRIDE" > .git_ver
173+
- name: Checkout latest Linux binaries
174+
run: |
175+
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(cat .git_ver)"
176+
git clone https://git.bitcoin.ninja/ldk-java-bins
177+
mkdir -p src/main/resources/
178+
cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/liblightningjni_Linux-*" src/main/resources/
179+
- name: Build Java/TS Release Bindings
180+
run: |
181+
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(cat .git_ver)"
154182
# genbindings.sh always fails as there is no wasm32-wasi library
155-
# available, so instead we delete the expected JNI library and check
156-
# that it was created.
157-
rm src/main/resources/liblightningjni_MacOSX-x86_64.nativelib
183+
# available, so instead we check that the expected JNI library
184+
# is created.
158185
./genbindings.sh ./ldk-c-bindings/ "-I$JAVA_HOME/include/ -I$JAVA_HOME/include/darwin -isysroot$(xcrun --show-sdk-path)" false false || echo
159186
cat src/main/resources/liblightningjni_MacOSX-x86_64.nativelib > /dev/null
160187
- name: Fetch Maven 3.8.1
@@ -174,8 +201,11 @@ jobs:
174201
mvn package
175202
java -ea -jar target/ldk-java-tests-1.0-SNAPSHOT-jar-with-dependencies.jar
176203
cd ..
177-
- name: Check latest headers and release lib are in git
204+
- name: Check latest release libs are in git
178205
run: |
179206
if [ "${{ matrix.platform }}" = "macos-11" ]; then
207+
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(cat .git_ver)"
208+
cp src/main/resources/liblightningjni_MacOS-amd64.nativelib "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"
209+
cd ldk-java-bins
180210
git diff --exit-code
181211
fi

0 commit comments

Comments
 (0)