Skip to content

Commit 61df96e

Browse files
committed
experiment with workflow dependencies
1 parent 3935eba commit 61df96e

File tree

2 files changed

+114
-0
lines changed

2 files changed

+114
-0
lines changed

.github/workflows/swift-prep.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
on:
2+
workflow_call:
3+
4+
jobs:
5+
prepare_compilation:
6+
runs-on: ubuntu-20.04
7+
env:
8+
TOOLCHAIN: stable
9+
steps:
10+
- name: Checkout source code
11+
uses: actions/checkout@v2
12+
- name: Checkout Rust-Lightning and LDK-C-Bindings git
13+
run: |
14+
git config --global user.email "[email protected]"
15+
git config --global user.name "LDK CI"
16+
# Note this is a different endpoint, as we need one non-upstream commit!
17+
# git clone https://git.bitcoin.ninja/rust-lightning
18+
# git clone https://github.com/TheBlueMatt/rust-lightning
19+
git clone --branch 2021-03-java-bindings-base https://github.com/TheBlueMatt/rust-lightning
20+
cd rust-lightning
21+
# git checkout origin/2021-03-java-bindings-base
22+
# git checkout v0.0.100
23+
# git checkout 8966f8d3d4911e034621c6d3c3d20140d3a7e76a
24+
echo "rust-lightning commit hash:"
25+
git rev-parse HEAD
26+
cd ..
27+
git clone https://github.com/lightningdevkit/ldk-c-bindings
28+
# git clone https://github.com/TheBlueMatt/ldk-c-bindings
29+
cd ldk-c-bindings
30+
# git checkout 1bb5ae1b34aeb74009b7b4b5ebefc957cddc30a6
31+
echo "ldk-c-bindings commit hash:"
32+
git rev-parse HEAD
33+
cd ..
34+
- name: Install Swift Toolchain
35+
run: |
36+
curl --verbose -L -o swift-5.6-RELEASE-ubuntu20.04.tar.gz https://download.swift.org/swift-5.6-release/ubuntu2004/swift-5.6-RELEASE/swift-5.6-RELEASE-ubuntu20.04.tar.gz
37+
echo "Sha sum: $(sha256sum swift-5.6-RELEASE-ubuntu20.04.tar.gz | awk '{ print $1 }')"
38+
if [ "$(sha256sum swift-5.6-RELEASE-ubuntu20.04.tar.gz | awk '{ print $1 }')" != "${EXPECTED_SWIFT_SHASUM}" ]; then
39+
echo "Bad hash"
40+
echo "Contents: \n$(cat swift-5.6-RELEASE-ubuntu20.04.tar.gz)"
41+
exit 1
42+
fi
43+
tar xvvf swift-5.6-RELEASE-ubuntu20.04.tar.gz
44+
env:
45+
EXPECTED_SWIFT_SHASUM: 3f0d926bfc08eea00a69b1d992f2ab5e08155d97476096a3ef959fe7c4cbd58b
46+
- name: Install native Rust toolchain, Valgrind, and build utilities
47+
run: |
48+
sudo apt-get update
49+
sudo apt-get -y dist-upgrade
50+
sudo apt-get -y install cargo valgrind lld git g++ clang curl
51+
- name: Install cbindgen
52+
run: cargo install --force cbindgen
53+
- name: Regenerate C bindings
54+
run: |
55+
cd ldk-c-bindings
56+
./genbindings.sh ../rust-lightning true
57+
cd ..
58+
- name: Debug bindings target directory structure
59+
run: |
60+
python ci/walker.py ldk-c-bindings/lightning-c-bindings/target
61+
- name: Copy new headers into bindings
62+
run: |
63+
mkdir -p ci/LDKSwift/Sources/LDKHeaders/include
64+
cp ldk-c-bindings/lightning-c-bindings/include/*.h ci/LDKSwift/Sources/LDKHeaders/include/
65+
cp ldk-c-bindings/ldk-net/ldk_net.h ci/LDKSwift/Sources/LDKHeaders/include/
66+
cp ldk-c-bindings/ldk-net/ldk_net.c ci/LDKSwift/Sources/LDKHeaders/
67+
- name: Set up Python
68+
uses: actions/setup-python@v2
69+
- name: Fix header files
70+
run: |
71+
python ci/fix_header_includes.py
72+
- name: Generate (copy for debugging) Swift bindings and copy batteries
73+
run: |
74+
python ./ # Generate bindings
75+
76+
# TODO: switch back to generation method after debugging
77+
# mkdir -p ci/LDKSwift/Sources/LDKSwift
78+
# cp -a bindings/LDK/. ci/LDKSwift/Sources/LDKSwift
79+
80+
cp -R bindings/batteries ci/LDKSwift/Sources/LDKSwift
81+
env:
82+
LDK_SWIFT_GENERATOR_INPUT_HEADER_PATH: ldk-c-bindings/lightning-c-bindings/include/lightning.h
83+
LDK_SWIFT_GENERATOR_OUTPUT_DIRECTORY_PATH: ci/LDKSwift/Sources/LDKSwift
84+
- name: Fix Swift files
85+
run: |
86+
python ci/fix_swift_imports.py
87+
- name: Debug CI directory structure
88+
run: |
89+
python ci/walker.py ci/
90+
- name: Build Swift bindings package
91+
run: |
92+
cd ci/LDKSwift
93+
../../swift-5.6-RELEASE-ubuntu20.04/usr/bin/swift build
94+
cd ../../
95+
env:
96+
LDK_C_BINDINGS_BASE: /home/runner/work/ldk-swift/ldk-swift/ldk-c-bindings
97+
LLVM_CLANG_ASAN_PATH: /usr/lib/llvm-11/lib/clang/11.0.0/lib/linux/libclang_rt.asan-x86_64.a
98+
RUST_BACKTRACE: 1

.github/workflows/swift.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,19 @@ jobs:
120120
- name: Check that the latest headers are in the swift repo
121121
run: |
122122
git diff --exit-code
123+
124+
test_bindings_with_sanitizer:
125+
runs-on: ubuntu-20.04
126+
steps:
127+
- uses: ./.github/workflows/swift-prep
128+
- name: Test Swift bindings package without address sanitizer
129+
run: |
130+
python ci/toggle_address_sanitation_library.py off
131+
cd ci/LDKSwift
132+
../../swift-5.6-RELEASE-ubuntu20.04/usr/bin/swift test -v
133+
cd ../../
134+
env:
135+
LDK_C_BINDINGS_BASE: /home/runner/work/ldk-swift/ldk-swift/ldk-c-bindings
136+
LLVM_CLANG_ASAN_PATH: /usr/lib/llvm-11/lib/clang/11.0.0/lib/linux/libclang_rt.asan-x86_64.a
137+
RUST_BACKTRACE: 1
138+

0 commit comments

Comments
 (0)