name: CLI CI
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Check formatting
if: matrix.os == 'ubuntu-latest'
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Build
run: cargo build --verbose
- name: Build for tests (ensures binary exists for integration tests)
run: cargo build --bin hostie
- name: Run tests
run: cargo test --verbose
- name: Run integration tests (tests CLI with mocked hosts files)
run: cargo test --test integration_tests --verbose
- name: Test summary
run: |
echo "✅ All tests passed successfully on ${{ matrix.os }}!"
echo "📊 Integration tests: 18 tests covering CLI functionality with mocked hosts files"
- name: Cache cargo-audit
if: matrix.os == 'ubuntu-latest'
uses: actions/cache@v4
with:
path: ~/.cargo/bin/cargo-audit
key: ${{ runner.os }}-cargo-audit
restore-keys: ${{ runner.os }}-cargo-audit
- name: Install cargo-audit
if: matrix.os == 'ubuntu-latest'
run: which cargo-audit || cargo install cargo-audit
- name: Security audit
if: matrix.os == 'ubuntu-latest'
run: cargo audit