feat: added action #1
Workflow file for this run
This file contains hidden or 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/CD Pipeline | |
on: | |
push: | |
pull_request: | |
types: [opened, reopened] | |
env: | |
RUST_BACKTRACE: 1 | |
jobs: | |
# Job 1: Format Check | |
format: | |
name: Format Check | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt | |
- name: Check formatting | |
run: cargo fmt --all -- --check | |
# Job 2: Lint Check | |
lint: | |
name: Lint Check | |
needs: [format] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: clippy | |
- name: Cache cargo registry | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-cargo-lint-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo- | |
- name: Run clippy | |
run: cargo clippy --all-targets --all-features -- -D warnings | |
- name: Check documentation | |
run: cargo doc --no-deps --document-private-items --all-features | |
env: | |
RUSTDOCFLAGS: "-D warnings" | |
# Job 3: Build | |
build: | |
name: Build | |
needs: [lint] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- name: Cache cargo registry | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo- | |
- name: Build project | |
run: cargo build --verbose --all-features | |
# Job 4: Test Suite | |
test: | |
name: Test Suite | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.rust }} | |
- name: Cache cargo registry | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-${{ matrix.rust }}-cargo-test-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.rust }}-cargo- | |
- name: Run tests | |
run: cargo test --verbose --all-features | |
- name: Run integration tests | |
run: cargo test --verbose --test '*' | |
- name: Run doc tests | |
run: cargo test --doc --all-features | |
# Job 5: Security Audit | |
security: | |
name: Security Audit | |
needs: [test] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- name: Cache cargo registry | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-cargo-audit-${{ hashFiles('**/Cargo.lock') }} | |
- name: Install cargo-audit | |
run: cargo install cargo-audit | |
- name: Run security audit | |
run: cargo audit | |
- name: Install cargo-deny | |
run: cargo install cargo-deny | |
- name: Run cargo-deny | |
run: cargo deny check |