steps:
  # setup: Prepare Nix environment and cache (optional but recommended)
  setup:
    image: nixos/nix:latest
    commands:
      - mkdir -p ~/.config/nix && echo "experimental-features = nix-command flakes" > ~/.config/nix/nix.conf

  # lint: Check formatting and run clippy
  lint:
    image: nixos/nix:latest
    commands:
      - nix develop --command just lint
    depends_on: [setup]

  # test: Run the test suite using nextest
  test:
    image: nixos/nix:latest
    commands:
      - nix develop --command just test
    depends_on: [setup]

  # security: Scan for secrets and run cargo-audit/deny
  security:
    image: nixos/nix:latest
    commands:
      - nix develop --command just scan-secrets
      - nix develop --command just health-check
    depends_on: [setup]

  # unused_deps: Check for unused dependencies
  unused_deps:
    image: nixos/nix:latest
    commands:
      - nix develop --command cargo-machete
    depends_on: [setup]

  # coverage: Ensure newly added .rs files have >= 80% line coverage
  coverage:
    image: nixos/nix:latest
    commands:
      - git fetch --depth=1 origin ${CI_REPO_DEFAULT_BRANCH:-master}
      - nix develop --command just coverage-check ${CI_REPO_DEFAULT_BRANCH:-master}
    depends_on: [test]

when:
  event: [push, pull_request]
