Rust #1240
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Rust | |
on: | |
schedule: | |
- cron: "0 0 * * *" | |
push: | |
branches: ["*"] | |
pull_request: | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
clippy: | |
runs-on: ubuntu-22.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-20.04, ubuntu-22.04] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install WireGuard | |
run: sudo apt update && sudo apt install wireguard-dkms | |
- 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 | |
# Boilerplate from: https://github.com/marketplace/actions/rust-grcov | |
# This is set up as a separate job since nightly Rust is required. When | |
# `-Zinstrument-coverage` is stable, combine this with the test job. | |
# https://github.com/rust-lang/rust/issues/79121 | |
test_linux_coverage: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install WireGuard | |
run: sudo apt update && sudo apt install wireguard-dkms | |
- name: Setup nightly Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: nightly | |
override: true | |
- name: Build | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --all-features --tests | |
env: | |
CARGO_INCREMENTAL: '0' | |
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' | |
RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_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 --no-fail-fast | |
env: | |
CARGO_INCREMENTAL: '0' | |
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' | |
RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' | |
- id: coverage | |
uses: actions-rs/grcov@v0.1 | |
- uses: codecov/codecov-action@v1 | |
with: | |
files: ${{ steps.coverage.outputs.report }} | |
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 | |
# Similar to the plain "coverage" job, this is a separate job since it requires nightly Rust. | |
test_macos_coverage: | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install wireguard-go | |
run: brew install wireguard-tools | |
- name: Setup nightly Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: nightly | |
override: true | |
- 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_INCREMENTAL: '0' | |
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' | |
RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' | |
- id: coverage | |
uses: actions-rs/grcov@v0.1 | |
- uses: codecov/codecov-action@v1 | |
with: | |
files: ${{ steps.coverage.outputs.report }} |