From 67b75ca59c2b6cb1152e7dbe1f841271831c08bf Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Mon, 4 Nov 2024 11:54:14 +0100 Subject: [PATCH] Add workflow job to ensure native loading works of cross compiled library (#91) Motivation: We should validate that we can actually load our native lib that was cross compiled Modifications: Add job that does the validation Result: Validate cross-compilation works --- .github/workflows/ci-verify-load.yml | 96 ++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 .github/workflows/ci-verify-load.yml diff --git a/.github/workflows/ci-verify-load.yml b/.github/workflows/ci-verify-load.yml new file mode 100644 index 0000000..b68bbda --- /dev/null +++ b/.github/workflows/ci-verify-load.yml @@ -0,0 +1,96 @@ +# ---------------------------------------------------------------------------- +# Copyright 2024 The Netty Project +# +# The Netty Project licenses this file to you under the Apache License, +# version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at: +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- +name: Verify native library loading + +on: + push: + branches: [ main ] + + pull_request: + branches: [ main ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +env: + MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryhandler.count=5 -Dmaven.wagon.httpconnectionManager.ttlSeconds=240 + +jobs: + install-jars-linux-aarch64: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + # Caching of maven dependencies + - uses: actions/cache@v4 + continue-on-error: true + with: + path: ~/.m2/repository + key: sinstall-jars-linux-aarch64-maven-cache-${{ hashFiles('**/pom.xml') }} + restore-keys: | + install-jars-linux-aarch64-maven-cache- + + - name: Build docker image + run: docker compose -f docker/docker-compose.centos-7-cross.yaml build + + - name: Build project and install jars + run: docker compose -f docker/docker-compose.centos-7-cross.yaml run cross-compile-aarch64-install + + - name: Upload the maven repository + uses: actions/upload-artifact@v4 + with: + name: maven-repository + # We only need the netty jars. + path: ~/.m2/repository/io/netty/ + if-no-files-found: error + + load-native-linux-aarch64: + # The host should always be Linux + runs-on: ubuntu-latest + needs: [ install-jars-linux-aarch64 ] + steps: + - uses: actions/checkout@v4 + + - name: Download the maven repository + uses: actions/download-artifact@v4 + with: + name: maven-repository + path: /home/runner/jars + + - uses: uraimo/run-on-arch-action@v2 + name: Check native loading + id: runcmd + with: + arch: aarch64 + distro: ubuntu20.04 + + # Not required, but speeds up builds by storing container images in + # a GitHub package registry. + githubToken: ${{ github.token }} + + # Mount the .m2/repository + dockerRunArgs: | + --volume "/home/runner/jars:/root/jars" + + # Install dependencies + install: | + apt-get update -q -y + apt-get install -q -y openjdk-11-jdk + apt-get clean -q -y + + # Check if we can load the native code on aarch64 + run: | + .github/scripts/check_load_native.sh /root/jars io.netty.incubator.codec.hpke.boringssl.BoringSSLHPKE ensureAvailability