# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks

default_install_hook_types: [ 'pre-commit', 'pre-push' ]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
  rev: v5.0.0
  hooks:
    - id: check-added-large-files
      name: 'Check: Large Files'
    - id: check-case-conflict
      name: 'Check: Filename Case Conflict'
    - id: check-merge-conflict
      name: 'Check: Merge Conflict Markers'
    - id: check-symlinks
      name: 'Check: Dangling Symlinks'
    - id: check-vcs-permalinks
      name: 'Check: VCS Permalinks'
    - id: destroyed-symlinks
      name: 'Check: Destroyed Symlinks'
    - id: detect-private-key
      name: 'Check: Detect Private Keys'
    - id: mixed-line-ending
      name: 'Check: Detect Mixed Line Endings'
      args: [ '--fix', 'no' ]
    - id: check-json
      name: 'Validate: JSON Files'
    - id: check-toml
      name: 'Validate: TOML Files'
    - id: check-yaml
      name: 'Validate: YAML Files'

- repo: local
  hooks:

    - id: cargo-fmt
      name: 'Check Style (Rust)'
      language: system
      entry: 'cargo fmt --all -- --check'
      pass_filenames: false
      require_serial: true
      stages: [ 'pre-commit' ]
      fail_fast: true

    - id: cargo-clippy
      name: 'Lint (Rust: Clippy)'
      language: system
      entry: 'cargo clippy --all-targets --all-features -- -D warnings'
      pass_filenames: false
      require_serial: true
      stages: [ 'pre-commit' ]
      fail_fast: true

    - id: cargo-test
      name: 'Test (Rust)'
      language: system
      entry: 'cargo test --locked'
      pass_filenames: false
      require_serial: true
      stages: [ 'pre-commit' ]
      fail_fast: true

    - id: cargo-build
      name: 'Compile (Rust: Release)'
      language: system
      entry: 'cargo build --release --locked'
      pass_filenames: false
      require_serial: true
      stages: [ 'pre-push' ]
      always_run: true
      fail_fast: true

    - id: cargo-test-release
      name: 'Test (Rust: Release)'
      language: system
      entry: 'cargo test --release --locked'
      pass_filenames: false
      require_serial: true
      stages: [ 'pre-push' ]
      always_run: true
      fail_fast: true
