Skip to content

Commit cbfad0f

Browse files
committed
Add a CI run on OSX
1 parent 88b220f commit cbfad0f

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

.github/workflows/build.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,102 @@ jobs:
8282
mvn package
8383
java -ea -jar target/ldk-java-tests-1.0-SNAPSHOT-jar-with-dependencies.jar
8484
cd ..
85+
86+
osx:
87+
strategy:
88+
matrix:
89+
include:
90+
- platform: macos-10.15
91+
# MacOS 11 is currently in private preview, we've applied for access
92+
# - platform: macos-11
93+
runs-on: ${{ matrix.platform }}
94+
env:
95+
TOOLCHAIN: stable
96+
steps:
97+
- name: Install other Rust platforms
98+
run: rustup target install aarch64-apple-darwin
99+
- name: Fetch upstream LLVM/clang snapshot
100+
run: |
101+
wget -O clang+llvm-12.0.0-x86_64-apple-darwin.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.0/clang+llvm-12.0.0-x86_64-apple-darwin.tar.xz
102+
if [ "$(shasum -a 256 clang+llvm-12.0.0-x86_64-apple-darwin.tar.xz | awk '{ print $1 }')" != "7bc2259bf75c003f644882460fc8e844ddb23b27236fe43a2787870a4cd8ab50" ]; then
103+
echo "Bad hash"
104+
exit 1
105+
fi
106+
- name: Unpack upstream LLVM+clang and use it by default
107+
run: |
108+
tar xvvf clang+llvm-12.0.0-x86_64-apple-darwin.tar.xz
109+
- name: Checkout source code
110+
uses: actions/checkout@v2
111+
with:
112+
fetch-depth: 0
113+
- name: Install cbindgen
114+
run: cargo install --force cbindgen
115+
- name: Checkout Rust-Lightning and LDK-C-Bindings git
116+
run: |
117+
git config --global user.email "ldk-ci@example.com"
118+
git config --global user.name "LDK CI"
119+
git clone https://github.com/rust-bitcoin/rust-lightning
120+
cd rust-lightning
121+
git remote add matt https://git.bitcoin.ninja/rust-lightning
122+
git fetch matt
123+
git merge matt/2021-03-java-bindings-base
124+
cd ..
125+
git clone https://github.com/lightningdevkit/ldk-c-bindings
126+
- name: Rebuild C bindings with upstream clang, and check the sample app builds + links
127+
run: |
128+
cd ldk-c-bindings
129+
export PATH=`pwd`/clang+llvm-12.0.0-x86_64-apple-darwin/bin:$PATH
130+
CC=clang ./genbindings.sh ../rust-lightning true
131+
cd ..
132+
- name: Fetch OpenJDK 16
133+
run: |
134+
wget -O openjdk-16.0.1_osx-x64_bin.tar.gz https://download.java.net/java/GA/jdk16.0.1/7147401fd7354114ac51ef3e1328291f/9/GPL/openjdk-16.0.1_osx-x64_bin.tar.gz
135+
if [ "$(shasum -a 256 openjdk-16.0.1_osx-x64_bin.tar.gz | awk '{ print $1 }')" != "6098f839954439d4916444757c542c1b8778a32461706812d41cc8bbefce7f2f" ]; then
136+
echo "Bad hash"
137+
exit 1
138+
fi
139+
tar xvvf openjdk-16.0.1_osx-x64_bin.tar.gz
140+
export JAVA_HOME=`pwd`/jdk-16.0.1.jdk/Contents/Home
141+
export PATH=$JAVA_HOME/bin:$PATH
142+
- name: Build Java/TS Release Bindings
143+
run: |
144+
# We assume the top commit is just a bindings update commit, so we
145+
# check out the previous commit to use as the commit we git describe.
146+
# If the top commit is a merge commit, we need to get the last merge
147+
# head and assume the latest bindings are built against its parent.
148+
COMMIT_PARENTS=$(git show -s --pretty=format:%P HEAD)
149+
if [ "${#COMMIT_PARENTS}" = 40 ]; then
150+
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD^1)"
151+
else
152+
MERGE_HEAD=$(git show --pretty=format:%P HEAD | ( for last in $(cat /dev/stdin); do true; done; echo $last ))
153+
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag $MERGE_HEAD^1)"
154+
fi
155+
echo "Using $LDK_GARBAGECOLLECTED_GIT_OVERRIDE as git version"
156+
# genbindings.sh always fails as there is no wasm32-wasi library
157+
# available, so instead we delete the expected JNI library and check
158+
# that it was created.
159+
rm src/main/resources/liblightningjni_MacOSX-x86_64.nativelib
160+
./genbindings.sh ./ldk-c-bindings/ "-I$JAVA_HOME/include/ -I$JAVA_HOME/include/darwin -isysroot$(xcrun --show-sdk-path)" false false || echo
161+
cat src/main/resources/liblightningjni_MacOSX-x86_64.nativelib > /dev/null
162+
- name: Fetch Maven 3.8.1
163+
run: |
164+
wget -O apache-maven-3.8.1-bin.tar.gz https://apache.osuosl.org/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz
165+
if [ "$(shasum -a 256 apache-maven-3.8.1-bin.tar.gz | awk '{ print $1 }')" != "b98a1905eb554d07427b2e5509ff09bd53e2f1dd7a0afa38384968b113abef02" ]; then
166+
echo "Bad hash"
167+
exit 1
168+
fi
169+
tar xvvf apache-maven-3.8.1-bin.tar.gz
170+
export PATH=apache-maven-3.8.1/bin:$PATH
171+
- name: Run Java Tests against built jar
172+
run: |
173+
mvn -DskipTests=true package
174+
mvn install:install-file -Dfile=target/ldk-java-1.0-SNAPSHOT.jar -DgroupId=org.ldk -DartifactId=ldk-java -Dversion=1.0-SNAPSHOT -Dpackaging=jar
175+
cd javatester
176+
mvn package
177+
java -ea -jar target/ldk-java-tests-1.0-SNAPSHOT-jar-with-dependencies.jar
178+
cd ..
179+
- name: Check latest headers and release lib are in git
180+
run: |
181+
if [ "${{ matrix.platform }}" = "macos-11" ]; then
182+
git diff --exit-code
183+
fi

0 commit comments

Comments
 (0)