# Hooks for prek (https://prek.j178.dev/). See README for setup. # # Same shape as the sibling repos, minus what this one has no files for: # no terraform (infra's), no prettier or astro (headquarters' web), no ruff # (arena's Python helpers, and there is no Python here). # The commit-msg hook needs its own git shim, so `prek install` alone does not # get it. Naming it here means a plain `prek install` installs both. default_install_hook_types = ["pre-commit", "commit-msg"] [[repos]] repo = "https://github.com/pre-commit/pre-commit-hooks" rev = "v6.0.0" # check-xml earns its place on one file, bridge/log4j2-quiet.xml, which # nothing else parses until MegaMek refuses to start. check-yaml and # check-json are here for the CI config this repo does not have yet; they cost # nothing while they match nothing. # # check-added-large-files matters more here than in the sibling repos: the # built database is 100MB and the bridge's dumps are 33MB, and while # .gitignore covers them by name, a differently-named copy would sail in. hooks = [ { id = "check-merge-conflict" }, { id = "check-added-large-files" }, { id = "check-toml" }, { id = "check-yaml" }, { id = "check-json" }, { id = "check-xml" }, { id = "mixed-line-ending", args = ["--fix=lf"] }, { id = "end-of-file-fixer" }, { id = "trailing-whitespace" }, ] [[repos]] repo = "https://github.com/shellcheck-py/shellcheck-py" rev = "v0.11.0.1" # Same flags as arena's and headquarters' gates: -x follows sourced files, and # info-level notes do not gate. hooks = [{ id = "shellcheck", args = ["-x", "--severity=warning"] }] [[repos]] repo = "local" [[repos.hooks]] id = "cargo-fmt" name = "cargo fmt" language = "system" entry = "cargo fmt --all --check" pass_filenames = false files = '\.rs$' # -j 2, which the sibling repos do not need. A full-parallel cargo build has # taken this machine down before, and a hook runs on every commit, so it is # the last place to let one off the leash. [[repos.hooks]] id = "cargo-clippy" name = "cargo clippy" language = "system" entry = "cargo clippy -j 2 --workspace --all-targets -- -D warnings" pass_filenames = false files = '(\.rs|Cargo\.(toml|lock))$' # The crate graph this repo's design rests on: no I/O dependency may reach the # crates that have to compile to wasm, and no producer of ComputedStats may # reach helm-db. Both erode by adding one line to a Cargo.toml, and the # failure surfaces much later as "why can this not compile to wasm", so the # trigger is Cargo.toml rather than every Rust file - a `use` cannot add a # dependency, and this way the hook stays off the common path. [[repos.hooks]] id = "crate-boundaries" name = "crate boundaries" language = "system" entry = "scripts/check-boundaries.sh" pass_filenames = false files = 'Cargo\.toml$' # Conventional Commits, with the scope naming the epic in headquarters' plan/ # that the work belongs to. The script says what else is allowed and why. [[repos.hooks]] id = "commit-scope" name = "commit scope" language = "system" entry = "scripts/check-commit-scope.sh" stages = ["commit-msg"]