name: Test Android
on:
  push:
    paths:
      - "bdk-ffi/**"
      - "bdk-android/**"
  pull_request:
    paths:
      - "bdk-ffi/**"
      - "bdk-android/**"

jobs:
  build:
    runs-on: ubuntu-20.04
    steps:
      - name: "Check out PR branch"
        uses: actions/checkout@v2

      - name: "Cache"
        uses: actions/cache@v2
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            ./target
          key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}

      - name: "Set up JDK"
        uses: actions/setup-java@v2
        with:
          distribution: temurin
          java-version: 11

      - name: "Install Rust Android targets"
        run: rustup target add x86_64-linux-android aarch64-linux-android armv7-linux-androideabi

      - name: "Run Android tests"
        run: |
          cd bdk-android
          ./gradlew test --console=rich
