From cbfad0f0e6419c878b026b088218f816733354eb Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 15 Jun 2021 19:55:19 +0000 Subject: [PATCH] Add a CI run on OSX --- .github/workflows/build.yml | 99 +++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 24eb674c..05d785f3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -82,3 +82,102 @@ jobs: mvn package java -ea -jar target/ldk-java-tests-1.0-SNAPSHOT-jar-with-dependencies.jar cd .. + + osx: + strategy: + matrix: + include: + - platform: macos-10.15 + # MacOS 11 is currently in private preview, we've applied for access + # - platform: macos-11 + runs-on: ${{ matrix.platform }} + env: + TOOLCHAIN: stable + steps: + - name: Install other Rust platforms + run: rustup target install aarch64-apple-darwin + - name: Fetch upstream LLVM/clang snapshot + run: | + 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 + if [ "$(shasum -a 256 clang+llvm-12.0.0-x86_64-apple-darwin.tar.xz | awk '{ print $1 }')" != "7bc2259bf75c003f644882460fc8e844ddb23b27236fe43a2787870a4cd8ab50" ]; then + echo "Bad hash" + exit 1 + fi + - name: Unpack upstream LLVM+clang and use it by default + run: | + tar xvvf clang+llvm-12.0.0-x86_64-apple-darwin.tar.xz + - name: Checkout source code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Install cbindgen + run: cargo install --force cbindgen + - name: Checkout Rust-Lightning and LDK-C-Bindings git + run: | + git config --global user.email "ldk-ci@example.com" + git config --global user.name "LDK CI" + git clone https://github.com/rust-bitcoin/rust-lightning + cd rust-lightning + git remote add matt https://git.bitcoin.ninja/rust-lightning + git fetch matt + git merge matt/2021-03-java-bindings-base + cd .. + git clone https://github.com/lightningdevkit/ldk-c-bindings + - name: Rebuild C bindings with upstream clang, and check the sample app builds + links + run: | + cd ldk-c-bindings + export PATH=`pwd`/clang+llvm-12.0.0-x86_64-apple-darwin/bin:$PATH + CC=clang ./genbindings.sh ../rust-lightning true + cd .. + - name: Fetch OpenJDK 16 + run: | + 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 + if [ "$(shasum -a 256 openjdk-16.0.1_osx-x64_bin.tar.gz | awk '{ print $1 }')" != "6098f839954439d4916444757c542c1b8778a32461706812d41cc8bbefce7f2f" ]; then + echo "Bad hash" + exit 1 + fi + tar xvvf openjdk-16.0.1_osx-x64_bin.tar.gz + export JAVA_HOME=`pwd`/jdk-16.0.1.jdk/Contents/Home + export PATH=$JAVA_HOME/bin:$PATH + - name: Build Java/TS Release Bindings + run: | + # We assume the top commit is just a bindings update commit, so we + # check out the previous commit to use as the commit we git describe. + # If the top commit is a merge commit, we need to get the last merge + # head and assume the latest bindings are built against its parent. + COMMIT_PARENTS=$(git show -s --pretty=format:%P HEAD) + if [ "${#COMMIT_PARENTS}" = 40 ]; then + export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD^1)" + else + MERGE_HEAD=$(git show --pretty=format:%P HEAD | ( for last in $(cat /dev/stdin); do true; done; echo $last )) + export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag $MERGE_HEAD^1)" + fi + echo "Using $LDK_GARBAGECOLLECTED_GIT_OVERRIDE as git version" + # genbindings.sh always fails as there is no wasm32-wasi library + # available, so instead we delete the expected JNI library and check + # that it was created. + rm src/main/resources/liblightningjni_MacOSX-x86_64.nativelib + ./genbindings.sh ./ldk-c-bindings/ "-I$JAVA_HOME/include/ -I$JAVA_HOME/include/darwin -isysroot$(xcrun --show-sdk-path)" false false || echo + cat src/main/resources/liblightningjni_MacOSX-x86_64.nativelib > /dev/null + - name: Fetch Maven 3.8.1 + run: | + 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 + if [ "$(shasum -a 256 apache-maven-3.8.1-bin.tar.gz | awk '{ print $1 }')" != "b98a1905eb554d07427b2e5509ff09bd53e2f1dd7a0afa38384968b113abef02" ]; then + echo "Bad hash" + exit 1 + fi + tar xvvf apache-maven-3.8.1-bin.tar.gz + export PATH=apache-maven-3.8.1/bin:$PATH + - name: Run Java Tests against built jar + run: | + mvn -DskipTests=true package + mvn install:install-file -Dfile=target/ldk-java-1.0-SNAPSHOT.jar -DgroupId=org.ldk -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 + cd .. + - name: Check latest headers and release lib are in git + run: | + if [ "${{ matrix.platform }}" = "macos-11" ]; then + git diff --exit-code + fi -- 2.30.2