Skip to content

fix(ci): Optimize GitHub Actions workflows and fix all build/test errors #2

fix(ci): Optimize GitHub Actions workflows and fix all build/test errors

fix(ci): Optimize GitHub Actions workflows and fix all build/test errors #2

Workflow file for this run

name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Cancel outdated workflow runs
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: 0
jobs:
# Job 1: Format check
format:
name: Format Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check
# Job 2: Clippy linting
clippy:
name: Clippy Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "clippy"
- name: Run clippy
run: cargo clippy --workspace --all-targets --locked -- -D warnings
# Job 3: Build and Test (Matrix for multiple platforms)
test:
name: Test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
rust: [stable]
steps:
- uses: actions/checkout@v4
- name: Install Rust ${{ matrix.rust }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- name: Install system dependencies (Linux)
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get install -y libpcap-dev pkg-config
- name: Install system dependencies (macOS)
if: matrix.os == 'macos-latest'
run: brew install libpcap pkg-config
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "test-${{ matrix.os }}"
- name: Build
run: cargo build --workspace --locked --verbose
- name: Run tests
run: cargo test --workspace --locked --verbose
env:
# Skip network tests on Windows (requires Npcap installation)
SKIP_NETWORK_TESTS: ${{ matrix.os == 'windows-latest' && '1' || '0' }}
- name: Build release
run: cargo build --release --workspace --locked
# Job 4: Security audit
security_audit:
name: Security Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run cargo-deny
uses: EmbarkStudios/cargo-deny-action@v2
with:
log-level: warn
command: check advisories
arguments: --all-features
# Job 5: MSRV (Minimum Supported Rust Version) check
msrv:
name: MSRV Check (1.70)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust 1.70
uses: dtolnay/rust-toolchain@1.70
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libpcap-dev pkg-config
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "msrv"
- name: Check build with MSRV
run: cargo build --workspace --locked --verbose