name: Build and test

on:
    push:
        branches: ["main"]
    pull_request:

    workflow_dispatch:

concurrency:
    group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
    cancel-in-progress: true

env:
    CARGO_TERM_COLOR: always

jobs:
    build_and_test:
        runs-on: ubuntu-latest
        steps:
            - uses: actions/checkout@v3
            - name: Set up cargo cache
              uses: Swatinem/rust-cache@v2
            - name: Run clippy
              run: cargo clippy -- -Wwarnings
            - name: Run fmt
              run: cargo fmt --all --check
            # - name: Build
            #   run: cargo build --verbose
            # - name: Run tests all
            #   run: cargo test --all --verbose
