hdfs-sys 0.3.0

Bindings to HDFS Native C API
Documentation
name: CI

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
  cancel-in-progress: true

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Format
        run: cargo fmt --all -- --check

      - name: Clippy
        run: cargo clippy --all-features --all-targets -- -D warnings

  unit:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        # We should support windows, but so far we can't build hadoop on it.
        # Visit [Tracking issue of windows support](https://github.com/Xuanwo/hdfs-sys/issues/17) for more details.
        os: [ ubuntu-latest, macos-latest, windows-latest ]
        feature: [
          "hdfs_2_6",
          "hdfs_2_10",
          "hdfs_3_3",
        ]

    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-java@v3
        id: setup_java
        with:
          distribution: 'temurin'
          java-version: '8'

      # Add jvm.dll in PATH to make sure windows can find it.
      - name: Update path for windows
        if: matrix.os == 'windows-latest'
        run: |
          echo "${{ steps.setup_java.outputs.path }}\lib" >> $GITHUB_PATH
          echo "${{ steps.setup_java.outputs.path }}\jre\bin\server" >> $GITHUB_PATH
          echo "LIB=${LIB};${{ steps.setup_java.outputs.path }}\lib;${{ steps.setup_java.outputs.path }}\jre\bin\server" >> $GITHUB_ENV

      # Add libjvm.dylib in RPATH to make sure macos can find it.
      - name: Update path for macos
        if: matrix.os == 'macos-latest'
        run: |
          mkdir -p ~/lib
          ln -s ${{ steps.setup_java.outputs.path }}/jre/lib/server/libjvm.dylib ~/lib/

      - name: Build
        run: cargo build --features ${{ matrix.feature }}
      - name: Test
        run: cargo test --features ${{ matrix.feature }} -- --nocapture
        env:
          RUST_LOG: DEBUG
          RUST_BACKTRACE: full
          LD_LIBRARY_PATH: ${{ env.JAVA_HOME }}/lib/server:${{ env.JAVA_HOME }}/lib/amd64/server:${{ env.JAVA_HOME }}/jre/lib/server:${{ env.JAVA_HOME }}/jre/lib/amd64/server