on:
pull_request:
branches:
- develop
push:
branches:
- develop
permissions:
contents: read
checks: write
name: Test and Audit Workflow
jobs:
check_format:
name: Check Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt
- name: Check formatting
run: cargo fmt --check
check_clippy:
name: Check Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: clippy
- name: Run Clippy
run: cargo clippy --all-targets -- -D warnings
audit:
name: Audit
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: "Generate Cargo.lock"
run: cargo generate-lockfile
- name: cargo-audit cache restore
id: cargo-audit_cache_restore
uses: actions/cache/restore@v4
with:
path: ~/.cargo/bin/cargo-audit
key: ${{ runner.os }}-cargo-audit
- run: cargo install cargo-audit
if: steps.cargo-audit_cache_restore.outputs.cache-hit != 'true'
- name: cargo-audit cache save
id: cargo-audit_cache_save
uses: actions/cache/save@v4
if: always() && steps.cargo-audit_cache_restore.outputs.cache-hit != 'true'
with:
path: ~/.cargo/bin/cargo-audit
key: ${{ runner.os }}-cargo-audit
- uses: rustsec/audit-check@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
build_and_test_linux:
name: Build and Test (Linux)
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Install Protobuf compiler
run: |
sudo apt-get update -qq
sudo apt-get install -y protobuf-compiler
- uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry restore
id: cargo_cache_restore_linux
uses: actions/cache/restore@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: "Build and test"
run: cargo test --all-features -- --test-threads=1
- name: Cache cargo registry save
id: cargo_cache_save_linux
uses: actions/cache/save@v4
if: always() && steps.cargo_cache_restore_linux.outputs.cache-hit != 'true'
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
build_and_test_windows:
name: Build and Test (Windows)
runs-on: windows-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- name: Install Protobuf compiler
run: choco install protoc --no-progress -y
shell: powershell
- name: Cache cargo registry restore
id: cargo_cache_restore_windows
uses: actions/cache/restore@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- uses: dtolnay/rust-toolchain@stable
- name: "Build and test"
env:
RUST_BACKTRACE: 1
run: |
cargo test --all-features -- --test-threads=1
- name: Cache cargo registry save
id: cargo_cache_save_windows
uses: actions/cache/save@v4
if: always() && steps.cargo_cache_restore_windows.outputs.cache-hit != 'true'
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}