name: Rust
on:
schedule:
- cron: "0 0 * * *"
push:
branches: ["*"]
pull_request:
env:
CARGO_TERM_COLOR: always
jobs:
clippy:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v2
- name: Annotate commit with clippy warnings
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-targets --all-features -- -D warnings
rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Rustfmt
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt
- name: Run Rustfmt
run: cargo fmt --all -- --check
test_linux:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-24.04]
steps:
- uses: actions/checkout@v2
- name: Install WireGuard
run: sudo apt update && sudo apt install wireguard-tools
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --all-features --tests
- name: Apply CAP_NET_ADMIN to tests
run: find ./target/debug/deps -maxdepth 1 -type f -executable | xargs -n 1 sudo setcap CAP_NET_ADMIN=+eip
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features
test_linux_coverage:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v2
- name: Install WireGuard
run: sudo apt update && sudo apt install wireguard-tools
- name: Set up Toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: llvm-tools-preview
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --all-features --tests
env:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: '-C instrument-coverage'
RUSTDOCFLAGS: '-C instrument-coverage'
- name: Apply CAP_NET_ADMIN to tests
run: find ./target/debug/deps -maxdepth 1 -type f -executable | xargs -n 1 sudo setcap CAP_NET_ADMIN=+eip
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --no-fail-fast
env:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: '-C instrument-coverage'
RUSTDOCFLAGS: '-C instrument-coverage'
- name: Install grcov
run: cargo install grcov
- name: Run grcov
id: coverage
run: grcov . --binary-path target/debug/deps/ -s . -t lcov --branch -o coverage.lcov
- uses: codecov/codecov-action@v5
with:
files: coverage.lcov
test_macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Install wireguard-go
run: brew install wireguard-tools
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features
env:
CARGO_TARGET_X86_64_APPLE_DARWIN_RUNNER: sudo
CARGO_TARGET_AARCH64_APPLE_DARWIN_RUNNER: sudo
test_macos_coverage:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Install wireguard-go
run: brew install wireguard-tools
- name: Set up Toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: llvm-tools-preview
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --no-fail-fast
env:
CARGO_TARGET_X86_64_APPLE_DARWIN_RUNNER: sudo
CARGO_TARGET_AARCH64_APPLE_DARWIN_RUNNER: sudo
CARGO_INCREMENTAL: '0'
RUSTFLAGS: '-C instrument-coverage'
RUSTDOCFLAGS: '-C instrument-coverage'
- name: Install grcov
run: cargo install grcov
- name: Run grcov
id: coverage
run: grcov . --binary-path target/debug/deps/ -s . -t lcov --branch -o coverage.lcov
- uses: codecov/codecov-action@v5
with:
files: coverage.lcov