sysinfolinux 0.1.1

Library to get system information such as processes, CPUs, disks, components and networks on Linux
on:
  pull_request:

name: CI

# If a new push on the PR is done, cancel the build
concurrency:
  group: ${{ github.head_ref }}
  cancel-in-progress: true

env:
  RUSTFLAGS: -Dwarnings
  CROSS_VERSION: git:167aa99f5c460bb88e9c8b31065f11a3325c9c73
  CROSS_REPOSITORY: https://github.com/GuillaumeGomez/cross

jobs:
  rustfmt:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable
          components: rustfmt
      - run: cargo fmt -- --check
      - name: test that all source files are covered by rustfmt
        run: |
          for f in $(find src/ -name '*.rs' | grep -v 'src/pcis.rs'); do echo -e '\n\n\n\n\n' >> $f; done
          cargo fmt
          git diff --exit-code  # expect all changes from above wiped away

  clippy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: nightly
          components: clippy
      - run: cargo clippy --all-targets --features serde -- -D warnings
      - run: cargo clippy --all-targets --features multithread -- -D warnings

  check:
    name: Check ${{ matrix.toolchain }} / ${{ matrix.triple.target }}
    runs-on: ${{ matrix.triple.os }}
    strategy:
      fail-fast: false
      matrix:
        triple:
          - { os: 'ubuntu-latest',  target: 'x86_64-unknown-linux-gnu', cross: false }
          - { os: 'ubuntu-latest',  target: 'i686-unknown-linux-gnu',   cross: true }
          ## ARM64
          - { os: 'ubuntu-latest', target: 'aarch64-unknown-linux-gnu',  cross: true }
          - { os: 'ubuntu-latest', target: 'aarch64-unknown-linux-musl', cross: true }
          ## ARMv7
          - { os: 'ubuntu-latest', target: 'armv7-unknown-linux-gnueabihf',  cross: true }
          - { os: 'ubuntu-latest', target: 'armv7-unknown-linux-musleabihf', cross: true }
          ## ARMv6
          - { os: 'ubuntu-latest', target: 'arm-unknown-linux-gnueabihf',  cross: true }
          - { os: 'ubuntu-latest', target: 'arm-unknown-linux-musleabihf', cross: true }
        toolchain:
          - "1.95.0"  # minimum supported rust version
    steps:
      - uses: actions/checkout@v4
      - name: Install toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: ${{ matrix.toolchain }}

      - name: Install cross-target
        run: rustup target add ${{ matrix.triple.target }}

      - name: Check
        uses: ClementTsang/cargo-action@v0.0.7
        with:
          command: rustc
          args: --target=${{ matrix.triple.target }} --manifest-path=Cargo.toml
          use-cross: ${{ matrix.triple.cross }}
          cross-version: ${{ env.CROSS_VERSION }}
          repository-url: ${{ env.CROSS_REPOSITORY }}

      - name: Check debug feature
        uses: ClementTsang/cargo-action@v0.0.7
        with:
          command: rustc
          args: --target=${{ matrix.triple.target }} --manifest-path=Cargo.toml --features=debug
          use-cross: ${{ matrix.triple.cross }}
          cross-version: ${{ env.CROSS_VERSION }}
          repository-url: ${{ env.CROSS_REPOSITORY }}

      - name: Check debug feature
        uses: ClementTsang/cargo-action@v0.0.7
        with:
          command: rustc
          args: --target=${{ matrix.triple.target }} --manifest-path=Cargo.toml --no-default-features --features=debug
          use-cross: ${{ matrix.triple.cross }}
          cross-version: ${{ env.CROSS_VERSION }}
          repository-url: ${{ env.CROSS_REPOSITORY }}

      - name: Check serde feature
        uses: ClementTsang/cargo-action@v0.0.7
        with:
          command: rustc
          args: --target=${{ matrix.triple.target }} --manifest-path=Cargo.toml --features=serde
          use-cross: ${{ matrix.triple.cross }}
          cross-version: ${{ env.CROSS_VERSION }}
          repository-url: ${{ env.CROSS_REPOSITORY }}

      - name: Check serde feature
        uses: ClementTsang/cargo-action@v0.0.7
        with:
          command: rustc
          args: --target=${{ matrix.triple.target }} --manifest-path=Cargo.toml --no-default-features --features=serde
          use-cross: ${{ matrix.triple.cross }}
          cross-version: ${{ env.CROSS_VERSION }}
          repository-url: ${{ env.CROSS_REPOSITORY }}

      - name: Check debug/serde feature (system)
        uses: ClementTsang/cargo-action@v0.0.7
        with:
          command: rustc
          args: --target=${{ matrix.triple.target }} --manifest-path=Cargo.toml --no-default-features --features=debug,serde,system
          use-cross: ${{ matrix.triple.cross }}
          cross-version: ${{ env.CROSS_VERSION }}
          repository-url: ${{ env.CROSS_REPOSITORY }}

      - name: Check debug/serde feature (disk)
        uses: ClementTsang/cargo-action@v0.0.7
        with:
          command: rustc
          args: --target=${{ matrix.triple.target }} --manifest-path=Cargo.toml --no-default-features --features=debug,serde,disk
          use-cross: ${{ matrix.triple.cross }}
          cross-version: ${{ env.CROSS_VERSION }}
          repository-url: ${{ env.CROSS_REPOSITORY }}

      - name: Check debug/serde feature (component)
        uses: ClementTsang/cargo-action@v0.0.7
        with:
          command: rustc
          args: --target=${{ matrix.triple.target }} --manifest-path=Cargo.toml --no-default-features --features=debug,serde,component
          use-cross: ${{ matrix.triple.cross }}
          cross-version: ${{ env.CROSS_VERSION }}
          repository-url: ${{ env.CROSS_REPOSITORY }}

      - name: Check debug/serde feature (network)
        uses: ClementTsang/cargo-action@v0.0.7
        with:
          command: rustc
          args: --target=${{ matrix.triple.target }} --manifest-path=Cargo.toml --no-default-features --features=debug,serde,network
          use-cross: ${{ matrix.triple.cross }}
          cross-version: ${{ env.CROSS_VERSION }}
          repository-url: ${{ env.CROSS_REPOSITORY }}

      - name: Check debug/serde feature (user)
        uses: ClementTsang/cargo-action@v0.0.7
        with:
          command: rustc
          args: --target=${{ matrix.triple.target }} --manifest-path=Cargo.toml --no-default-features --features=debug,serde,user
          use-cross: ${{ matrix.triple.cross }}
          cross-version: ${{ env.CROSS_VERSION }}
          repository-url: ${{ env.CROSS_REPOSITORY }}

      - name: Check debug/serde feature (gpu)
        uses: ClementTsang/cargo-action@v0.0.7
        with:
          command: rustc
          args: --target=${{ matrix.triple.target }} --manifest-path=Cargo.toml --no-default-features --features=debug,serde,gpu
          use-cross: ${{ matrix.triple.cross }}
          cross-version: ${{ env.CROSS_VERSION }}
          repository-url: ${{ env.CROSS_REPOSITORY }}

      - name: Check without multithreading
        uses: ClementTsang/cargo-action@v0.0.7
        with:
          command: check
          args: --target=${{ matrix.triple.target }} --manifest-path=Cargo.toml --no-default-features
          use-cross: ${{ matrix.triple.cross }}
          cross-version: ${{ env.CROSS_VERSION }}
          repository-url: ${{ env.CROSS_REPOSITORY }}

      - name: Check features (system)
        uses: ClementTsang/cargo-action@v0.0.7
        with:
          command: check
          args: --target=${{ matrix.triple.target }} --manifest-path=Cargo.toml --no-default-features --features system
          use-cross: ${{ matrix.triple.cross }}
          cross-version: ${{ env.CROSS_VERSION }}
          repository-url: ${{ env.CROSS_REPOSITORY }}

      - name: Check features (disk)
        uses: ClementTsang/cargo-action@v0.0.7
        with:
          command: check
          args: --target=${{ matrix.triple.target }} --manifest-path=Cargo.toml --no-default-features --features disk
          use-cross: ${{ matrix.triple.cross }}
          cross-version: ${{ env.CROSS_VERSION }}
          repository-url: ${{ env.CROSS_REPOSITORY }}

      - name: Check features (component)
        uses: ClementTsang/cargo-action@v0.0.7
        with:
          command: check
          args: --target=${{ matrix.triple.target }} --manifest-path=Cargo.toml --no-default-features --features component
          use-cross: ${{ matrix.triple.cross }}
          cross-version: ${{ env.CROSS_VERSION }}
          repository-url: ${{ env.CROSS_REPOSITORY }}

      - name: Check features (network)
        uses: ClementTsang/cargo-action@v0.0.7
        with:
          command: check
          args: --target=${{ matrix.triple.target }} --manifest-path=Cargo.toml --no-default-features --features network
          use-cross: ${{ matrix.triple.cross }}
          cross-version: ${{ env.CROSS_VERSION }}
          repository-url: ${{ env.CROSS_REPOSITORY }}

      - name: Check features (user)
        uses: ClementTsang/cargo-action@v0.0.7
        with:
          command: check
          args: --target=${{ matrix.triple.target }} --manifest-path=Cargo.toml --no-default-features --features user
          use-cross: ${{ matrix.triple.cross }}
          cross-version: ${{ env.CROSS_VERSION }}
          repository-url: ${{ env.CROSS_REPOSITORY }}

      - name: Check features (gpu)
        uses: ClementTsang/cargo-action@v0.0.7
        with:
          command: check
          args: --target=${{ matrix.triple.target }} --manifest-path=Cargo.toml --no-default-features --features gpu
          use-cross: ${{ matrix.triple.cross }}
          cross-version: ${{ env.CROSS_VERSION }}
          repository-url: ${{ env.CROSS_REPOSITORY }}

      - name: Check example
        uses: ClementTsang/cargo-action@v0.0.7
        with:
          command: check
          args: --target=${{ matrix.triple.target }} --example simple
          use-cross: ${{ matrix.triple.cross }}
          cross-version: ${{ env.CROSS_VERSION }}
          repository-url: ${{ env.CROSS_REPOSITORY }}

  tests:
    needs: [check]
    name: Test (rust ${{matrix.toolchain}})
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        toolchain:
          - "1.95.0"  # minimum supported rust version
          - nightly
    steps:
      - uses: actions/checkout@v4
      - name: Install toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: ${{ matrix.toolchain }}
      - name: Check docs
        run: cargo rustdoc -- -Z unstable-options --generate-link-to-definition
        if: matrix.toolchain == 'nightly'
      - name: Check docs with serde
        run: cargo rustdoc --features serde -- -Z unstable-options --generate-link-to-definition
        if: matrix.toolchain == 'nightly'
      - name: Execute tests
        run: cargo test
        env:
          RUST_BACKTRACE: full
      - name: Execute tests (no features)
        run: cargo test --no-default-features
        env:
          RUST_BACKTRACE: full
      - name: Run CPU test
        run: cargo test --lib -- --ignored --test-threads 1
        env:
          RUST_BACKTRACE: full
      - name: Check serde feature
        run: |
          cargo check --features serde
          cargo test --features serde --doc
        env:
          RUST_BACKTRACE: full

  c_interface:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable
      - run: make