name: Check rust

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

env:
  CARGO_TERM_COLOR: always

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - name: Set up nix
        uses: nixbuild/nix-quick-install-action@v34
      - name: Checkout
        uses: actions/checkout@v4
      - name: Set up nix devshell
        run: nix develop
      - name: Build rust
        run: nix develop -c cargo build
      - name: Run clippy
        run: nix develop -c cargo clippy
      - name: Run tests
        run: nix develop -c cargo nextest run
      - name: Check coverage
        run: nix develop -c cargo llvm-cov nextest --fail-under-functions 100
          --fail-under-lines 100 --fail-under-regions 100
      - name: Run cargo deny
        run: nix develop -c cargo deny check
      - name: Run additional flake checks
        run: nix flake check
