Change Android build gradle #10
This file contains hidden or 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: Build and Test | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| build-linux-and-test: | |
| name: Build Linux Library and Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 11 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '11' | |
| - name: Clone DefraDB | |
| run: git clone https://github.com/sourcenetwork/defradb /tmp/defradb | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: '/tmp/defradb/go.mod' | |
| cache: false | |
| - name: Make scripts executable | |
| run: | | |
| chmod +x gradlew build.sh | |
| find /tmp/defradb -name "*.sh" -exec chmod +x {} + | |
| - name: Build Linux library | |
| run: ./build.sh --defra-dir /tmp/defradb --linux | |
| - name: Compile test | |
| run: | | |
| mkdir -p test-out | |
| javac -cp build/libs/defradb.jar test/DefraTest.java -d test-out | |
| - name: Run test | |
| run: java -cp build/libs/defradb.jar:test-out DefraTest | |
| build-android: | |
| name: Build Android Library and Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Free disk space | |
| uses: jlumbroso/free-disk-space@main | |
| with: | |
| tool-cache: false | |
| android: false | |
| dotnet: true | |
| haskell: true | |
| large-packages: true | |
| docker-images: true | |
| swap-storage: false | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Setup Android NDK | |
| uses: nttld/setup-ndk@v1 | |
| id: setup-ndk | |
| with: | |
| ndk-version: r26d | |
| - name: Clone DefraDB | |
| run: git clone https://github.com/sourcenetwork/defradb /tmp/defradb | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: '/tmp/defradb/go.mod' | |
| cache: false | |
| - name: Make scripts executable | |
| run: | | |
| chmod +x gradlew build.sh | |
| find /tmp/defradb -name "*.sh" -exec chmod +x {} + | |
| - name: Build Android library | |
| run: ./build.sh --defra-dir /tmp/defradb --android | |
| env: | |
| ANDROID_NDK: ${{ steps.setup-ndk.outputs.ndk-path }} | |
| - name: Stage AAR for instrumented test module | |
| run: | | |
| mkdir -p androidTest/libs | |
| cp build/outputs/aar/*-debug.aar androidTest/libs/defradb.aar | |
| - 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 Android instrumented tests | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| api-level: 29 | |
| arch: x86_64 | |
| disable-animations: true | |
| script: cd androidTest && ../gradlew connectedAndroidTest |