Skip to content

Coding Practices

Coding Practices #723

name: Coding Practices
on:
workflow_dispatch:
push:
branches: ["main"]
pull_request:
types: [opened, synchronize, reopened, converted_to_draft, ready_for_review]
branches: ["*"]
env:
RUST_CACHE_PATH: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
jobs:
changes:
runs-on: ubuntu-latest
# Required to expose outputs to dependent jobs (unused-dependencies, licenses-compatibility)
outputs:
dependencies: ${{ steps.changes.outputs.dependencies }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
dependencies:
- "Cargo.toml"
- "Cargo.lock"
- "crates/**/Cargo.toml"
- "crates/**/Cargo.lock"
- "examples/**/Cargo.toml"
- "examples/**/Cargo.lock"
unused-dependencies:
needs: changes
if: ${{ needs.changes.outputs.dependencies == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: jaxxstorm/action-install-gh-release@v1.10.0
with:
repo: bnjbvr/cargo-machete
tag: v0.7.0
binaries-location: cargo-machete-v0.7.0-x86_64-unknown-linux-musl
- run: cargo-machete
licenses-compatibility:
needs: changes
if: ${{ needs.changes.outputs.dependencies == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: jaxxstorm/action-install-gh-release@v1.10.0
with:
repo: EmbarkStudios/cargo-deny
tag: 0.16.4
binaries-location: cargo-deny-0.16.4-x86_64-unknown-linux-musl
- run: cargo deny-amaru
license-headers:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: viperproject/check-license-header@v2
with:
path: .
config: .github/check-license-header.config.json
strict: false
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache/restore@v4
with:
path: ${{ env.RUST_CACHE_PATH }}
key: cargo-x86_64-unknown-linux-gnu
restore-keys: |
cargo-x86_64-unknown-linux-gnu
- run: cargo clippy-amaru
formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: cargo fmt-amaru