Add Android CI #35
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [main, v1.0.*] | |
pull_request: | |
branches: [main, v1.0.*] | |
jobs: | |
android-build: | |
runs-on: ubuntu-latest | |
env: | |
# ANDROID_NATIVE_API_LEVEL may be useful to set, but by default it is set to lowest supported by the NDK | |
# and that is enough for the purpose of this script | |
ANDROID_ARM32_CMAKE_OPTIONS: -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake -DANDROID_ABI=armeabi-v7a | |
ANDROID_ARM64_CMAKE_OPTIONS: -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
path: src | |
- name: Install dependencies | |
run: | | |
sudo apt update | |
sudo apt install ninja-build | |
- name: Configure | |
run: | | |
rm -rf build install | |
cmake -B build/shared_32 -S src -GNinja ${{ env.ANDROID_ARM32_CMAKE_OPTIONS }} -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=install/shared_32 -DLIBUSB_BUILD_EXAMPLES=ON -DLIBUSB_BUILD_TESTING=ON -DLIBUSB_BUILD_SHARED_LIBS=ON | |
cmake -B build/static_32 -S src -GNinja ${{ env.ANDROID_ARM32_CMAKE_OPTIONS }} -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=install/static_32 -DLIBUSB_BUILD_EXAMPLES=ON -DLIBUSB_BUILD_TESTING=ON -DLIBUSB_BUILD_SHARED_LIBS=OFF | |
cmake -B build/shared_64 -S src -GNinja ${{ env.ANDROID_ARM64_CMAKE_OPTIONS }} -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=install/shared_64 -DLIBUSB_BUILD_EXAMPLES=ON -DLIBUSB_BUILD_TESTING=ON -DLIBUSB_BUILD_SHARED_LIBS=ON | |
cmake -B build/static_64 -S src -GNinja ${{ env.ANDROID_ARM64_CMAKE_OPTIONS }} -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=install/static_64 -DLIBUSB_BUILD_EXAMPLES=ON -DLIBUSB_BUILD_TESTING=ON -DLIBUSB_BUILD_SHARED_LIBS=OFF | |
- name: Build Shared ARM32 | |
working-directory: build/shared_32 | |
run: ninja install | |
- name: Build Static ARM32 | |
working-directory: build/static_32 | |
run: ninja install | |
- name: Build Shared ARM64 | |
working-directory: build/shared_64 | |
run: ninja install | |
- name: Build Static ARM64 | |
working-directory: build/static_64 | |
run: ninja install | |
- name: Check artifacts | |
uses: andstor/file-existence-action@v2 | |
with: | |
files: "install/shared_32/lib/libusb-1.0.so, \ | |
install/shared_32/include/libusb-1.0/libusb.h, \ | |
install/static_32/lib/libusb-1.0.a, \ | |
install/static_32/include/libusb-1.0/libusb.h, \ | |
install/shared_64/lib/libusb-1.0.so, \ | |
install/shared_64/include/libusb-1.0/libusb.h, \ | |
install/static_64/lib/libusb-1.0.a, \ | |
install/static_64/include/libusb-1.0/libusb.h" | |
fail: true | |
# No test runs/results: cross-compiled Android binaries are not runnable on a host machine | |
publish-test-results: | |
name: "Publish Tests Results" | |
needs: [android-build] | |
runs-on: ubuntu-latest | |
permissions: | |
checks: write | |
pull-requests: write | |
if: always() | |
steps: | |
- name: Download Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: artifacts | |
- name: Publish Test Results | |
uses: EnricoMi/publish-unit-test-result-action@v2 | |
with: | |
files: "artifacts/**/*.xml" |