Merge pull request #159 from 0xnim/master #463
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 CI | |
on: | |
pull_request: | |
branches: [ "master", "rewrite/v3" ] | |
push: | |
branches: [ "master", "rewrite/v3" ] | |
workflow_dispatch: | |
env: | |
CARGO_TERM_COLOR: always | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
format: | |
name: Check Code Formatting | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo- | |
- name: Install Rust nightly | |
uses: dtolnay/rust-toolchain@nightly | |
with: | |
components: rustfmt | |
- name: Run cargo fmt | |
run: cargo fmt --all -- --check | |
clippy: | |
name: Run Clippy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo- | |
- name: Install Rust nightly | |
uses: dtolnay/rust-toolchain@nightly | |
with: | |
components: clippy | |
- name: Run Clippy | |
run: cargo clippy --all-targets -- -D warnings | |
security: | |
name: Check Security Vulnerabilities | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo- | |
- name: Install Rust nightly | |
uses: dtolnay/rust-toolchain@nightly | |
- name: Install and Run Cargo Audit | |
run: | | |
if ! command -v cargo-audit &> /dev/null; then | |
cargo install cargo-audit | |
fi | |
cargo audit | |
test: | |
name: Run Tests | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: macos-14 | |
target: aarch64-apple-darwin | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
- os: windows-latest | |
target: x86_64-pc-windows-msvc | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ matrix.os }}-cargo- | |
- name: Install Rust nightly | |
uses: dtolnay/rust-toolchain@nightly | |
with: | |
targets: ${{ matrix.target }} | |
- name: Run Tests | |
run: cargo test --target ${{ matrix.target }} --verbose |