name: CI
on:
push:
branches: [main]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
fmt:
name: rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- run: cargo fmt --all -- --check
clippy-test:
name: clippy + test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Install libpcap (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libpcap-dev
- name: Install Npcap SDK (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
Invoke-WebRequest -Uri 'https://npcap.com/dist/npcap-sdk-1.13.zip' -OutFile 'npcap-sdk.zip'
Expand-Archive -Path 'npcap-sdk.zip' -DestinationPath 'C:\npcap-sdk'
Add-Content -Path $env:GITHUB_ENV -Value "LIB=C:\npcap-sdk\Lib\x64"
- name: Install Npcap runtime (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
Invoke-WebRequest -Uri 'https://npcap.com/dist/npcap-1.80.exe' -OutFile 'npcap-installer.exe'
Start-Process -FilePath '.\npcap-installer.exe' -ArgumentList '/S' -NoNewWindow -Wait
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- name: Clippy
run: cargo clippy --all-targets -- -D warnings
- name: Test
run: cargo test --all-targets
- name: Doc-tests
run: cargo test --doc
doc:
name: cargo doc
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install libpcap
run: |
sudo apt-get update
sudo apt-get install -y libpcap-dev
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Build docs
env:
RUSTDOCFLAGS: -D warnings
run: cargo doc --no-deps