name: Test Kotlin/JVM
on:
  workflow_dispatch:
  push:
    paths:
      - "bdk-ffi/**"
      - "bdk-jvm/**"
  pull_request:
    paths:
      - "bdk-ffi/**"
      - "bdk-jvm/**"

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

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

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

      - name: "Set default Rust version to 1.77.1"
        run: rustup default 1.77.1

      - name: "Run JVM tests"
        run: |
          cd bdk-jvm
          ./gradlew test -P excludeConnectedTests
