@@ -104,6 +104,148 @@ jobs:
104104 git checkout node-net/package.json
105105 git diff --exit-code
106106
107+ c_sharp_bindings :
108+ runs-on : ubuntu-latest
109+ # Ubuntu's version of clang doesn't support....anything that should work.
110+ # Ubuntu is an utter trash OS and should generally never be used for anything.
111+ # We also require at least rustc 1.51 (ie https://github.com/rust-lang/rust/pull/79998),
112+ # so we use debian testing
113+ container : debian:bookworm
114+ strategy :
115+ fail-fast : false
116+ steps :
117+ - name : Install required dependencies
118+ run : |
119+ apt-get update
120+ apt-get -y dist-upgrade
121+ apt-get -y install cargo lld llvm git g++ clang curl python3 mono-devel
122+ - name : Checkout source code
123+ uses : actions/checkout@v2
124+ with :
125+ fetch-depth : 0
126+ - name : Install cbindgen
127+ run : |
128+ git clone https://github.com/eqrion/cbindgen
129+ cd cbindgen/
130+ git checkout v0.20.0
131+ cargo update -p indexmap --precise "1.6.2" --verbose
132+ cargo install --locked --path .
133+ - name : Checkout Rust-Lightning and LDK-C-Bindings git
134+ run : |
135+ git config --global safe.directory '*'
136+ git config --global user.email "[email protected] " 137+ git config --global user.name "LDK CI"
138+ # Note this is a different endpoint, as we need one non-upstream commit!
139+ git clone https://github.com/lightningdevkit/rust-lightning
140+ cd rust-lightning
141+ git checkout origin/0.0.118-bindings
142+ cd ..
143+ git clone https://github.com/lightningdevkit/ldk-c-bindings
144+ cd ldk-c-bindings
145+ git checkout 0.0.118
146+ cd lightning-c-bindings
147+ cargo update -p memchr --precise "2.5.0" --verbose
148+ - name : Rebuild C bindings with STD
149+ run : |
150+ cd ldk-c-bindings
151+ git config --global safe.directory "*"
152+ ./genbindings.sh ../rust-lightning true
153+ - name : Build and Test C# Debug Bindings
154+ run : |
155+ ./genbindings.sh ./ldk-c-bindings/ c_sharp true true
156+ 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
157+ ln -s libldkcsharp_debug_Linux-amd64.so libldkcsharp.so
158+ export ASAN_OPTIONS=detect_leaks=0
159+ LD_PRELOAD=/usr/lib/llvm-14/lib/clang/14.0.6/lib/linux/libclang_rt.asan-x86_64.so mono test.exe
160+
161+ c_sharp_determinism :
162+ runs-on : ubuntu-latest
163+ # Ubuntu's version of clang doesn't support....anything that should work.
164+ # Ubuntu is an utter trash OS and should generally never be used for anything.
165+ # We also require at least rustc 1.51 (ie https://github.com/rust-lang/rust/pull/79998),
166+ # so we use debian testing
167+ container : debian:bookworm
168+ strategy :
169+ fail-fast : false
170+ steps :
171+ - name : Install required dependencies
172+ run : |
173+ apt-get update
174+ apt-get -y dist-upgrade
175+ apt-get -y install cargo libstd-rust-dev-windows lld llvm git g++ clang curl gcc-mingw-w64-x86-64-win32 python3 mono-devel zip faketime
176+ - name : Checkout source code
177+ uses : actions/checkout@v2
178+ with :
179+ fetch-depth : 0
180+ - name : Install cbindgen
181+ run : |
182+ git clone https://github.com/eqrion/cbindgen
183+ cd cbindgen/
184+ git checkout v0.20.0
185+ cargo update -p indexmap --precise "1.6.2" --verbose
186+ cargo install --locked --path .
187+ - name : Checkout Rust-Lightning and LDK-C-Bindings git
188+ run : |
189+ git config --global safe.directory '*'
190+ git config --global user.email "[email protected] " 191+ git config --global user.name "LDK CI"
192+ # Note this is a different endpoint, as we need one non-upstream commit!
193+ git clone https://github.com/lightningdevkit/rust-lightning
194+ cd rust-lightning
195+ git checkout origin/0.0.118-bindings
196+ cd ..
197+ git clone https://github.com/lightningdevkit/ldk-c-bindings
198+ cd ldk-c-bindings
199+ git checkout 0.0.118
200+ - name : Rebuild C bindings with STD
201+ run : |
202+ cd ldk-c-bindings
203+ export LDK_C_BINDINGS_EXTRA_TARGETS=x86_64-pc-windows-gnu
204+ export LDK_C_BINDINGS_EXTRA_TARGET_CCS=`pwd`/deterministic-build-wrappers/clang-x86_64-windows
205+ ./genbindings.sh ../rust-lightning true
206+ - name : Remove checked-in source to ensure its correctly checked-in
207+ run : rm c_sharp/src/org/ldk/enums/*.cs c_sharp/src/org/ldk/impl/*.cs c_sharp/src/org/ldk/structs/*.cs
208+ - name : Build Windows C# Bindings
209+ run : |
210+ export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
211+ LDK_TARGET=x86_64-pc-windows-gnu faketime -f "2021-01-01 00:00:00" ./genbindings.sh ./ldk-c-bindings/ c_sharp false false
212+ - name : Build Linux C# Bindings
213+ run : |
214+ export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
215+ ./genbindings.sh ./ldk-c-bindings/ c_sharp false false
216+ - name : Build Release NUPKG
217+ run : |
218+ cd c_sharp
219+ ./build-release-nupkg.sh
220+ - name : Check latest auto-generated code is in git
221+ run : |
222+ # Checkout files that get updated with version information
223+ git checkout c_sharp/packaging_artifacts/package/services/metadata/core-properties/ldk.psmdcp
224+ git checkout c_sharp/packaging_artifacts/org.ldk.nuspec
225+ git diff --exit-code
226+ - name : Checkout latest binaries
227+ shell : bash
228+ run : |
229+ export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
230+ echo "Fetching deterministic binaries for LDK-GC ${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
231+ # Gitweb only allows snapshots of folders by providing the object hash, which we have to extract:
232+ 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)"
233+ curl -o bins-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}"
234+ mkdir -p ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
235+ cd ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
236+ tar xvvf ../../bins-snapshot.tgz
237+ mv ldk-java-bins-*/* ./
238+ rm -r ldk-java-bins-*
239+ - name : Compare C# nupkg with built one
240+ shell : bash
241+ run : |
242+ export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
243+ if ! diff ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"org.ldk.nupkg c_sharp/org.ldk.nupkg; then
244+ apt-get -y install diffoscope
245+ diffoscope ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"org.ldk.nupkg c_sharp/org.ldk.nupkg || echo
246+ exit 1
247+ fi
248+
107249 java_bindings :
108250 runs-on : ubuntu-latest
109251 # Ubuntu's version of rustc uses its own LLVM instead of being a real native package.
0 commit comments