on:
  push:
  merge_group:

name: Rust

jobs:
  format:
    name: Format Code
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions-rust-lang/setup-rust-toolchain@v1.10.1
      - uses: mbrobbel/rustfmt-check@0.12.0
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
  static_code_analysis:
    name: Static code analysis
    needs: format
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions-rust-lang/setup-rust-toolchain@v1.10.1
        with:
          components: clippy
      - name: Check code without default features
        run: cargo check --no-default-features
      - name: Check with clippy with all features enabled
        run: cargo clippy --all-features -- -D warnings
  unit-tests:
    env:
      RUST_BACKTRACE: 0
    name: Unit tests
    needs: format
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions-rust-lang/setup-rust-toolchain@v1.10.1
      - name: Run unit tests
        run: cargo test

