rcpufetch 0.0.5

[ALPHA] A rusty crossplatform, but simple CLI binutil for reading CPU information.
name: CI

on:
  push:
    branches: [main]
  pull_request:
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always

jobs:
  lint:
    name: fmt + clippy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy
      - run: cargo fmt --all -- --check
      - run: cargo clippy --all-targets -- -D warnings

  # Real native builds + a functional smoke-test run of the resulting binary on every
  # OS/arch combo GitHub Actions gives us actual hardware or a supported VM for. This is
  # not just `cargo check` -- it runs `rcpufetch` for real and asserts it produces output.
  native:
    name: build + run (${{ matrix.name }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            name: linux-x86_64
          - os: macos-latest
            name: macos-arm64
          - os: macos-13
            name: macos-x86_64
          - os: windows-latest
            name: windows-x86_64
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - run: cargo build --release --verbose
      - run: cargo test --release --verbose
      - name: smoke test (fancy)
        run: cargo run --release -- --no-logo
      - name: smoke test (legacy style, explicit color)
        run: cargo run --release -- --no-logo --style legacy
      - name: smoke test (--debug exits cleanly)
        run: cargo run --release -- --debug
      - name: smoke test (--help / --version)
        run: |
          cargo run --release -- --help
          cargo run --release -- --version

  # aarch64/ppc64le/riscv64 Linux: cross-compiled AND actually executed under QEMU via
  # `cross`, which wires up binfmt_misc + docker reliably on GitHub's ubuntu-latest
  # runners (unlike a local podman-machine VM, which does not do this reliably).
  cross-linux:
    name: cross build + run (${{ matrix.target }})
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        target:
          - aarch64-unknown-linux-gnu
          - powerpc64le-unknown-linux-gnu
          - riscv64gc-unknown-linux-gnu
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}
      - uses: taiki-e/install-action@cross
      - run: cross build --release --target ${{ matrix.target }} --verbose
      - name: run under QEMU
        run: cross run --release --target ${{ matrix.target }} -- --no-logo --style legacy

  # Targets we can only verify compile cleanly (no runnable host/VM in this workflow):
  # x86 (32-bit), Windows via GNU toolchain, and BSD architectures other than the ones
  # covered by real VMs below.
  cross-check-only:
    name: cross-compile check (${{ matrix.target }})
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        target:
          - i686-unknown-linux-gnu
          - x86_64-unknown-freebsd
          - aarch64-unknown-freebsd
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}
      - run: cargo check --target ${{ matrix.target }} --verbose

  # Real FreeBSD, in an actual FreeBSD VM (not a Linux container -- BSDs need their own
  # kernel, which Docker/Podman containers can't provide since they share the host
  # kernel). This is what actually validates src/bsd.rs end-to-end, including the
  # upstream gap this port fixes (cpufetch's C version is x86-only on FreeBSD).
  freebsd:
    name: build + run (FreeBSD VM)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: vmactions/freebsd-vm@v1
        with:
          usesh: true
          prepare: |
            pkg install -y curl
            curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal
          run: |
            . "$HOME/.cargo/env"
            cargo build --release --verbose
            ./target/release/rcpufetch --no-logo --style legacy
            ./target/release/rcpufetch --version

  # Real OpenBSD, same reasoning as FreeBSD above. rustc has no OpenBSD target shipped
  # via rustup, so this installs the OpenBSD package-manager's native rust build inside
  # the VM instead of cross-compiling -- the only way to actually validate OpenBSD.
  openbsd:
    name: build + run (OpenBSD VM)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: vmactions/openbsd-vm@v1
        with:
          usesh: true
          prepare: |
            pkg_add rust
          run: |
            cargo build --release --verbose
            ./target/release/rcpufetch --no-logo --style legacy
            ./target/release/rcpufetch --version

  # Real Windows container -- not "Windows in Docker" on Linux (WCOW containers require
  # a Windows host with matching kernel build; can't run on macOS/Linux podman/docker),
  # but the windows-latest runner above already covers a real Windows binary end-to-end.
  # This job additionally checks the GNU-toolchain build, which is the one people cross
  # compile from Linux/macOS for.
  windows-gnu-cross-check:
    name: cross-compile check (windows-gnu)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: x86_64-pc-windows-gnu
      - run: cargo check --target x86_64-pc-windows-gnu --verbose