Changes to android CI #476
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 | |
pull_request: | |
jobs: | |
validate: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Validate version files | |
# Make sure we still know how to edit the version files. (But discard the changes.) | |
run: .github/set-versions.sh -n 0.0.1 | |
java-test: | |
strategy: | |
matrix: | |
runs-on: ["ubuntu-22.04", "macos-12"] | |
runs-on: ${{ matrix.runs-on }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: olafurpg/setup-scala@v14 | |
with: | |
java-version: 11 | |
- name: Install llvm (ubuntu) | |
# Not installing llvm for Mac because https://stackoverflow.com/a/35753922/107357 | |
if: startsWith(matrix.runs-on, 'ubuntu') | |
run: sudo apt-get update && sudo apt-get install -y llvm | |
- uses: IronCoreLabs/rust-toolchain@v1 | |
with: | |
toolchain: stable | |
- name: Cargo fmt and build | |
run: cargo fmt -- --check && cargo build -p ironoxide-java | |
- name: Scala tests | |
run: sbt test | |
working-directory: java/tests | |
android-build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
arch: [i686-linux-android, x86_64-linux-android, aarch64-linux-android] | |
# These folder names will be used as the names of artifacts uploaded by this job. | |
# In order to delete these artifacts, the same names must go into the list in the `android-delete-artifacts` job. | |
include: | |
- arch: i686-linux-android | |
folder-name: x86 | |
- arch: x86_64-linux-android | |
folder-name: x86_64 | |
- arch: aarch64-linux-android | |
folder-name: arm64-v8a | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: IronCoreLabs/rust-toolchain@v1 | |
- name: Build | |
run: | | |
cargo install cargo-ndk | |
rustup target install ${{ matrix.arch }} | |
cargo ndk -t ${{ matrix.arch }} build -p ironoxide-android | |
cp -r target/${{ matrix.arch }}/debug/build/ironoxide-android*/out/java android/ironoxide-android/src/main/ | |
mkdir -p android/ironoxide-android/src/main/jniLibs/${{ matrix.folder-name }}/ | |
cp -r target/${{ matrix.arch }}/debug/libironoxide_android.so android/ironoxide-android/src/main/jniLibs/${{ matrix.folder-name }}/ | |
- name: Zip src/main | |
run: | | |
cd android/ironoxide-android/src/main | |
zip -r android_build.zip * | |
# Uploads the src/main as an artifact with the provided folder name as its name. | |
# In order to delete this artifact, the same name must go into the list in the `android-delete-artifacts` job. | |
- name: Upload src/main as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.folder-name }} | |
path: android/ironoxide-android/src/main/android_build.zip | |
android-test: | |
needs: android-build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
api-level: [24, 30] | |
arch: [x86, x86_64, arm64-v8a] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download android build | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ matrix.arch }} | |
- name: Unzip Android build | |
run: unzip -o android_build.zip -d android/ironoxide-android/src/main | |
# Taken from https://github.com/ReactiveCircus/android-emulator-runner/blob/main/README.md | |
- name: Enable KVM | |
run: | | |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
sudo udevadm control --reload-rules | |
sudo udevadm trigger --name-match=kvm | |
- name: Run tests | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
working-directory: ./android | |
arch: ${{ matrix.arch }} | |
api-level: ${{ matrix.api-level }} | |
ndk: "26.3.11579264" # matches android/ironoxide-android/build.gradle | |
script: ./gradlew connectedAndroidTest | |
# This tests that gradle can build ironoxide-android so we can catch issues before release. | |
android-release-test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Run build script | |
run: ./build.sh | |
working-directory: android | |
# This will test that we're able to build the .aar file required for release. | |
# In particular, it will catch if the NDK version we have specified is different than the one installed on the machine. | |
- name: Run gradle build | |
run: ./gradlew build | |
working-directory: android | |
cpp-build: | |
runs-on: macos-12 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: IronCoreLabs/rust-toolchain@v1 | |
with: | |
toolchain: stable | |
- name: Setup iOS build | |
run: | | |
rustup target add x86_64-apple-ios aarch64-apple-ios | |
cargo install cargo-lipo | |
- name: Build for iOS | |
run: cargo lipo -p ironoxide-cpp | |
cpp-test: | |
# Cmake on macos fails to find TargetConditionals.h | |
# See https://github.com/IronCoreLabs/ironoxide-swig-bindings/issues/222 | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: IronCoreLabs/rust-toolchain@v1 | |
with: | |
toolchain: stable | |
- name: Build and test | |
run: | | |
cargo build -p ironoxide-cpp | |
cd cpp/ | |
cmake . | |
make | |
./cpp-tests |