name: code style and linting checks

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  rustfmt:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install rustfmt
        run: rustup component add rustfmt
      - name: rustfmt
        run: cargo fmt --all -- --check
  
  clippy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install clippy
        run: rustup component add clippy
      - name: clippy
        run: |
          cargo clippy --all-targets --all-features -- -D warnings
