hostab 0.0.2

Your dev tool to manage /etc/hosts like a pro — written in Rust
Documentation
name: CI

on:
  push:
    branches: ["main"]
    tags-ignore: ["v*"]
    paths-ignore:
      - "README.md"
  pull_request:
    branches: ["main"]
    paths-ignore:
      - "README.md"

env:
  CARGO_TERM_COLOR: always

jobs:
  # ---- Lint & Format ----
  lint:
    name: Lint & fmt
    runs-on: ubuntu-24.04
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy

      - name: Cache cargo
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: lint-cargo-${{ hashFiles('Cargo.lock') }}

      - name: Check formatting
        run: cargo fmt --all -- --check

      - name: Clippy
        run: cargo clippy --all-targets -- -D warnings

  # ---- Unit tests (all platforms) ----
  unit-tests:
    name: Unit (${{ matrix.name }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-24.04
            name: ubuntu-24.04
            target: x86_64-unknown-linux-gnu
          - os: macos-14
            name: macos-14
            target: aarch64-apple-darwin
          - os: windows-2022
            name: windows-msvc
            target: x86_64-pc-windows-msvc
          - os: windows-2022
            name: windows-mingw
            target: x86_64-pc-windows-gnu
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - name: Install NASM (Windows MSVC)
        if: matrix.name == 'windows-msvc'
        uses: ilammy/setup-nasm@v1

      - name: Cache cargo
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ matrix.name }}-cargo-${{ hashFiles('Cargo.lock') }}

      - name: Build
        run: cargo build --release --target ${{ matrix.target }}

      - name: Run unit tests
        run: cargo test --release

      - name: Run integration tests
        shell: bash
        run: |
          if [[ "${{ matrix.target }}" == *"windows"* ]]; then
            HOSTAB_BIN="target/${{ matrix.target }}/release/hostab.exe"
          else
            HOSTAB_BIN="target/${{ matrix.target }}/release/hostab"
          fi
          export HOSTAB_BIN
          cargo test --test integration_test --release