mirror of
https://github.com/imsnif/bandwhich.git
synced 2026-02-09 01:59:18 +08:00
86 lines
2.6 KiB
YAML
86 lines
2.6 KiB
YAML
name: ci
|
|
on:
|
|
pull_request:
|
|
push:
|
|
branches:
|
|
- main
|
|
jobs:
|
|
test:
|
|
name: test
|
|
env:
|
|
# Emit backtraces on panics.
|
|
RUST_BACKTRACE: 1
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
rust:
|
|
- 1.70.0 # MSRV
|
|
- stable
|
|
- nightly
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
toolchain: ${{ matrix.rust }}
|
|
components: rustfmt, clippy
|
|
|
|
- name: Check formatting
|
|
run: cargo fmt --all -- --check
|
|
|
|
- name: Build
|
|
run: cargo build --verbose
|
|
|
|
# This is useful for debugging problems when the expected build artifacts
|
|
# (like shell completions and man pages) aren't generated.
|
|
- name: Show build.rs stderr
|
|
shell: bash
|
|
run: |
|
|
# it's probably okay to assume no spaces?
|
|
STDERR_FILES=$(find "./target/debug" -name stderr | grep bandwhich)
|
|
for FILE in $STDERR_FILES; do
|
|
echo "::group::$FILE"
|
|
cat "$FILE"
|
|
echo "::endgroup::"
|
|
done
|
|
|
|
- name: Run clippy
|
|
run: cargo clippy --all-targets --all-features -- -D warnings
|
|
|
|
- name: Install npcap on Windows
|
|
# PRs cannot not be trusted with repository secrets
|
|
if: (matrix.os == 'windows-latest') && (github.event_name != 'pull_request')
|
|
env:
|
|
NPCAP_OEM_URL: ${{ secrets.NPCAP_OEM_URL }}
|
|
run: |
|
|
Invoke-WebRequest -Uri "$env:NPCAP_OEM_URL" -OutFile "$env:TEMP/npcap-oem.exe"
|
|
# for this ridiculous `&` syntax alone, I'd rather use COBOL than Powershell
|
|
# see https://stackoverflow.com/a/1674950/5637701
|
|
& "$env:TEMP/npcap-oem.exe" /S
|
|
|
|
- name: Run tests
|
|
# npcap is needed to run tests on Windows, so this is an unfortunate
|
|
# sacrifice we have to make in the name of security
|
|
if: (matrix.os != 'windows-latest') || (github.event_name != 'pull_request')
|
|
run: cargo test --verbose
|
|
|
|
- name: Upload unix binary
|
|
if: matrix.os != 'windows-latest'
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ${{ matrix.os }}-${{ matrix.rust }}
|
|
path: target/debug/bandwhich
|
|
|
|
- name: Upload windows binary
|
|
if: matrix.os == 'windows-latest'
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ${{ matrix.os }}-${{ matrix.rust }}
|
|
path: |
|
|
target/debug/bandwhich.exe
|
|
target/debug/bandwhich.pdb
|