btleplug 0.12.0

A Cross-Platform Rust Bluetooth Low Energy (BLE) GATT library.
Documentation
name: Rust

on:
  push:
    branches: [dev, master]
  pull_request:
  workflow_dispatch:  

env:
  CARGO_TERM_COLOR: always
  grcov-version: 0.8.0

jobs:
  build:
    strategy:
      matrix:
        target:
          - macos
          - linux
          - windows
          - android
        include:
          - target: macos
            os: macOS-latest
            cbt: aarch64-apple-darwin
          - target: linux
            os: ubuntu-latest
            cbt: x86_64-unknown-linux-gnu
          - target: windows
            os: windows-latest
            cbt: x86_64-pc-windows-msvc
          - target: android
            os: ubuntu-latest
            cbt: aarch64-linux-android

    runs-on: ${{ matrix.os }}

    env:
      CARGO_BUILD_TARGET: ${{ matrix.cbt }}

    steps:
      - uses: actions/checkout@v2
      - name: Install dependencies
        if: ${{ runner.os == 'Linux' }}
        run: |
          sudo apt-get update
          sudo apt-get install libdbus-1-dev
      - uses: actions/setup-java@v2
        if: ${{ matrix.target == 'android' }}
        with:
          distribution: 'zulu'
          java-version: '17'
      - name: Setup NDK
        if: ${{ matrix.target == 'android' }}
        uses: nttld/setup-ndk@v1
        id: setup-ndk
        with:
          ndk-version: r25b
          local-cache: true
      - name: rust toolchain
        if: ${{ matrix.target == 'android' }}
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          target: aarch64-linux-android
          toolchain: stable
          override: true
      - name: Check
        run: cargo check --all --bins --examples
      - name: Check without default features
        run: cargo check --all --bins --examples --no-default-features
      - name: Check with all features
        run: cargo check --all --bins --examples --all-features
      - name: Run tests
        if: ${{ matrix.target != 'android' }}
        run: cargo test --all
      - name: Run clippy
        uses: actions-rs/clippy-check@v1
        with:
          name: clippy ${{ matrix.os }}
          token: ${{ secrets.GITHUB_TOKEN }}
          args: --all-features

  format:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Format Rust code
        run: cargo fmt --all -- --check

#  coverage:
#    strategy:
#      matrix:
#        os:
#          - macOS-latest
#          - ubuntu-latest
#          - windows-latest
#    runs-on: ${{ matrix.os }}
#
#    env:
#      RUSTC_BOOTSTRAP: 1
#    steps:
#      - uses: actions/checkout@v2
#      - name: Install dependencies
#        if: ${{ runner.os == 'Linux' }}
#        run: sudo apt-get install libdbus-1-dev
#      - name: Cache grcov
#        uses: actions/cache@v2
#        with:
#          path: |
#            ~/.cargo/bin/grcov
#            ~/.cargo/bin/grcov.exe
#            ~/.cargo/.crates.toml
#            ~/.cargo/.crates2.json
#          key: ${{ runner.os }}-cargo-bin-${{ env.grcov-version }}
#      - name: Install grcov
#        uses: actions-rs/install@v0.1
#        with:
#          crate: grcov
#          version: ${{ env.grcov-version }}
#      - name: Install llvm-tools
#        run: rustup component add llvm-tools-preview
#      - name: Build for coverage
#        run: cargo build --all-features
#        env:
#          RUSTFLAGS: "-Zinstrument-coverage -Ccodegen-units=1"
#      - name: Run tests with coverage
#        run: cargo test --all-features
#        env:
#          RUSTFLAGS: "-Zinstrument-coverage"
#          LLVM_PROFILE_FILE: "test-coverage-%p-%m.profraw"
#      - name: Convert coverage
#        run: grcov . -s . --binary-path target/debug/ -t lcov --branch --ignore-not-existing -o target/debug/lcov.info
#      - name: Upload coverage to codecov.io
#        uses: codecov/codecov-action@v1
#        with:
#          directory: ./target/debug
#          fail_ci_if_error: true