on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
  merge_group:
    
name: Static code analysis

jobs:
  format:
    name: Format Code
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions-rust-lang/setup-rust-toolchain@v1.4.4
      - uses: mbrobbel/rustfmt-check@0.5.0
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
  static_code_analysis:
    name: Static code analysis
    needs: format
    runs-on: ubuntu-latest
    steps:
      - uses: actions-rust-lang/setup-rust-toolchain@v1.4.4
        with:
          components: clippy
      - uses: actions/checkout@v3
      - name: Check with clippy with all features enabled
        run: cargo clippy --all-features -- -D warnings