tun-rs 2.8.3

Cross-platform TUN and TAP library
Documentation
name: Push or PR

on:
  [ push, pull_request ]

env:
  CARGO_TERM_COLOR: always

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: check
        run: |

          rustup target add x86_64-linux-android
          cargo check --target x86_64-linux-android
          cargo check --features async_tokio --target x86_64-linux-android
          cargo check --features async_tokio,async_framed --target x86_64-linux-android
          cargo check --features async_io,async_framed --target x86_64-linux-android
          cargo check --features interruptible --target x86_64-linux-android
          
          rustup target add x86_64-apple-ios
          cargo check --target x86_64-apple-ios
          cargo check --features async_tokio --target x86_64-apple-ios
          cargo check --features async_tokio,async_framed --target x86_64-apple-ios
          cargo check --features async_io,async_framed --target x86_64-apple-ios
          cargo check --features interruptible --target x86_64-apple-ios
          
          rustup target add x86_64-unknown-linux-ohos
          cargo check --target x86_64-unknown-linux-ohos
          cargo check --features async_tokio --target x86_64-unknown-linux-ohos
          cargo check --features async_tokio,async_framed --target x86_64-unknown-linux-ohos
          cargo check --features async_io,async_framed --target x86_64-unknown-linux-ohos
          cargo check --features interruptible --target x86_64-unknown-linux-ohos
          
          rustup target add x86_64-unknown-netbsd
          cargo check --target x86_64-unknown-netbsd
          cargo check --features async_tokio --target x86_64-unknown-netbsd
          cargo check --features async_tokio,async_framed --target x86_64-unknown-netbsd
          cargo check --features async_io,async_framed --target x86_64-unknown-netbsd
          cargo check --features interruptible --target x86_64-unknown-netbsd
          cargo clippy --target x86_64-unknown-netbsd  --features async_io -- -D warnings
          
          rustup target add i686-pc-windows-msvc
          cargo check --target i686-pc-windows-msvc
          cargo check --features async_tokio --target i686-pc-windows-msvc
          cargo check --features async_tokio,async_framed --target i686-pc-windows-msvc
          cargo check --features async_io,async_framed --target i686-pc-windows-msvc
          cargo check --features interruptible --target i686-pc-windows-msvc

  build_n_test:
    strategy:
      fail-fast: false
      matrix:
        os: [ ubuntu-latest, macos-latest, windows-latest ]

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

    steps:
      - uses: actions/checkout@v6
      - name: rustfmt
        if: ${{ !cancelled() }}
        run: cargo fmt --all -- --check
      - name: check
        if: ${{ !cancelled() }}
        run: |

          cargo check
          cargo check --features async_tokio
          cargo check --features async_tokio,async_framed
          cargo check --features async_io,async_framed
          cargo check --features interruptible
      - name: clippy
        if: ${{ !cancelled() }}
        run: |

          cargo clippy --all-targets -- -D warnings
          cargo clippy --all-targets --features async_io -- -D warnings
          cargo clippy --all-targets --features async_tokio,async_framed -- -D warnings
          cargo clippy --all-targets --features interruptible -- -D warnings
      - name: Build
        if: ${{ !cancelled() }}
        run: |

          cargo build --verbose --examples --tests
          cargo build --verbose --examples --tests --features async_io
          cargo build --verbose --examples --tests --features async_tokio
      - name: Abort on error
        if: ${{ failure() }}
        run: echo "Some of jobs failed" && false

  build_n_test_freebsd:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v6
      - name: Build x86_64-FreeBSD
        uses: cross-platform-actions/action@v1.0.0
        env:
          TARGET: x86_64-unknown-freebsd
        with:
          operating_system: freebsd
          environment_variables: TARGET
          architecture: x86-64
          version: 13.2
          shell: bash
          memory: 5G
          cpu_count: 4
          run: |

            uname -a
            echo $SHELL
            pwd
            ls -lah
            whoami
            env | sort
            sudo pkg install -y git protobuf llvm15
            curl --proto 'https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
            source $HOME/.cargo/env
            export CC=clang
            export CXX=clang++
            export CARGO_TERM_COLOR=always
            find ./
            cargo check --target x86_64-unknown-freebsd
            cargo check --features async_tokio --target x86_64-unknown-freebsd
            cargo check --features async_tokio,async_framed --target x86_64-unknown-freebsd
            cargo check --features async_io,async_framed --target x86_64-unknown-freebsd
            cargo check --features interruptible --target x86_64-unknown-freebsd
            cargo clippy --all-targets -- -D warnings
            cargo build --verbose --examples --tests
            cargo build --verbose --examples --tests --features async_io
            cargo build --verbose --examples --tests --features async_tokio

  build_n_test_android:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v6
      - name: Install cargo ndk and rust compiler for android target
        if: ${{ !cancelled() }}
        run: |

          cargo install --locked cargo-ndk
          rustup target add x86_64-linux-android
      - name: clippy
        if: ${{ !cancelled() }}
        run: cargo clippy --target x86_64-linux-android -- -D warnings
      - name: Build
        if: ${{ !cancelled() }}
        run: |

          cargo ndk -t x86_64 rustc --verbose  --features="async_tokio" --lib --crate-type=cdylib
      - name: Abort on error
        if: ${{ failure() }}
        run: echo "Android build job failed" && false

  build_n_test_ios:
    runs-on: macos-latest

    steps:
      - uses: actions/checkout@v6
      - name: Install cargo lipo and rust compiler for ios target
        if: ${{ !cancelled() }}
        run: |

          cargo install --locked cargo-lipo
          rustup target add x86_64-apple-ios  aarch64-apple-ios
      - name: clippy
        if: ${{ !cancelled() }}
        run: cargo clippy  --features="async_tokio" --target x86_64-apple-ios -- -D warnings
      - name: Build
        if: ${{ !cancelled() }}
        run: |

          cargo lipo --verbose  --features="async_tokio"
      - name: Abort on error
        if: ${{ failure() }}
        run: echo "iOs build job failed" && false
  build_n_test_tvos:
    strategy:
      matrix:
        target: [aarch64-apple-tvos, aarch64-apple-tvos-sim, x86_64-apple-tvos]
      fail-fast: false
    runs-on: macos-latest

    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@nightly
        with:
          components: clippy, rust-src
      - name: clippy
        if: ${{ !cancelled() }}
        run: cargo +nightly clippy -Zbuild-std --target ${{matrix.target}} --features="async_tokio" -- -D warnings
      - name: Build
        if: ${{ !cancelled() }}
        run: |

          cargo +nightly build -Zbuild-std --verbose --target ${{matrix.target}} --features="async_tokio"
      - name: Abort on error
        if: ${{ failure() }}
        run: echo "tvOS build job failed" && false
  build_n_test_openharmony:
    strategy:
      matrix:
        target: [aarch64-unknown-linux-ohos, armv7-unknown-linux-ohos, x86_64-unknown-linux-ohos]
      fail-fast: false
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v6
      - uses: openharmony-rs/setup-ohos-sdk@v1.0.0
        id: setup-ohos
        with:
          version: "5.0.1"
      - name: Install ohrs and rust compiler for ohos target
        if: ${{ !cancelled() }}
        run: |

          cargo install --locked ohrs
          rustup target add ${{ matrix.target }}
      - name: fmt & clippy
        if: ${{ !cancelled() }}
        run: |

          cargo fmt --all -- --check
          ohrs cargo --disable-target -- clippy --target ${{matrix.target}} --features="async_tokio" -- -D warnings
      - name: Abort on error
        if: ${{ failure() }}
        run: echo "OpenHarmony build job failed" && false

  semver:
    name: Check semver
    strategy:
      matrix:
        os: [ ubuntu-latest, macos-latest, windows-latest ]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v6
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
      - uses: obi1kenobi/cargo-semver-checks-action@v2