ifstat-rs 3.0.0

A tool to report network interface statistics.
Documentation
name: tests
# This script should test and run the program in native environment.

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

jobs:
  build-and-test:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
          - os: macos-latest
            target: aarch64-apple-darwin
          - os: macos-latest
            target: x86_64-apple-darwin
          - os: windows-latest
            target: stable-x86_64-pc-windows-gnu

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          profile: minimal
          override: true

      - name: Set environment variables
        run: |
          echo "TARGET=${{ matrix.target }}" >> $GITHUB_ENV

      - name: Show dep tree for debug purposes
        run: cargo tree

      - name: Build and Test on Linux
        if: matrix.target == 'x86_64-unknown-linux-gnu'
        run: |
          cargo test
          cargo build --release

      - name: Build and Test on macOS ARM
        if: matrix.target == 'aarch64-apple-darwin'
        run: |
          cargo test
          cargo build --release

      - name: Build and Test on macOS Intel
        if: matrix.target == 'x86_64-apple-darwin'
        run: |
          # runners are ARM so building Intel is cross-compiling
          rustup target install "${{ matrix.target }}"
          cargo test --target "${{ matrix.target }}"
          cargo build --release --target "${{ matrix.target }}"

      - name: Build and Test on Windows
        if: matrix.target == 'stable-x86_64-pc-windows-gnu'
        run: |
          cargo test
          cargo build --release

      - name: Show target listing for debug purposes
        continue-on-error: true
        run: |
          file target/*/ifstat-rs* || true
          file target/*/*/ifstat-rs* || true
          find target -name "ifstat-rs*" || true

      - name: Move build files to build_output (non-cross)
        if: matrix.target != 'x86_64-apple-darwin'
        continue-on-error: true
        run: |
          mkdir -p build_output
          cp target/release/ifstat-rs${{ matrix.target == 'stable-x86_64-pc-windows-gnu' && '.exe' || '' }} build_output/

      - name: Move build files to build_output (cross)
        if: matrix.target == 'x86_64-apple-darwin'
        continue-on-error: true
        run: |
          mkdir -p build_output
          cp target/${{ matrix.target }}/release/ifstat-rs build_output/

      - name: Run program on Linux
        if: matrix.target == 'x86_64-unknown-linux-gnu'
        run: |
          timeout 60s ./build_output/ifstat-rs -V
          timeout 60s ./build_output/ifstat-rs --version
          timeout 60s ./build_output/ifstat-rs --help
          timeout 60s ./build_output/ifstat-rs --list-interfaces
          timeout 60s ./build_output/ifstat-rs -i foo,bar,baz 0.1 1
          timeout 60s ./build_output/ifstat-rs -a 0.1 2
          timeout 60s ./build_output/ifstat-rs -l 1 1
          timeout 60s ./build_output/ifstat-rs --first-measurement 1 2 3
          timeout 60s ./build_output/ifstat-rs -z 0.1 1

      - name: Run program on macOS
        if: matrix.target == 'aarch64-apple-darwin' || matrix.target == 'x86_64-apple-darwin'
        run: |
          ./build_output/ifstat-rs -V
          ./build_output/ifstat-rs --version
          ./build_output/ifstat-rs --help
          ./build_output/ifstat-rs --list-interfaces
          ./build_output/ifstat-rs -i foo,bar,baz 0.1 1
          ./build_output/ifstat-rs -a 0.1 2
          ./build_output/ifstat-rs -l 1 1
          ./build_output/ifstat-rs --first-measurement 1 2 3
          ./build_output/ifstat-rs -z 0.1 1

      - name: Run program on Windows
        if: matrix.target == 'stable-x86_64-pc-windows-gnu'
        run: |
          ./build_output/ifstat-rs.exe -V
          ./build_output/ifstat-rs.exe --version
          ./build_output/ifstat-rs.exe --help
          ./build_output/ifstat-rs.exe --list-interfaces
          ./build_output/ifstat-rs.exe -i foo,bar,baz 0.1 1
          ./build_output/ifstat-rs.exe -a 0.1 2
          ./build_output/ifstat-rs.exe -l 1 1
          ./build_output/ifstat-rs.exe --first-measurement 1 2 3
          ./build_output/ifstat-rs.exe -z 0.1 1