name: CI
permissions:
  contents: read
  actions: write

on:
  push:
    branches: [main]
  workflow_dispatch:

jobs:
  check:
    name: Format, lint, build & test
    runs-on: ubuntu-24.04
    if: ${{ github.event_name == 'workflow_dispatch' || !startsWith(github.event.head_commit.message, 'release:') }}

    steps:
      - uses: actions/checkout@v4
        with:
          submodules: recursive

      - uses: DeterminateSystems/determinate-nix-action@v3

      - uses: nix-community/cache-nix-action@v7
        with:
          primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock', 'Cargo.lock') }}
          restore-prefixes-first-match: nix-${{ runner.os }}-
          gc-max-store-size-linux: 5G

      - name: Check formatting, clippy lint, unit tests & ort version
        run: nix flake check --show-trace
