From 4dc97abef9d0a7a8989bc83a1c37a3012c355834 Mon Sep 17 00:00:00 2001 From: kiskaadee Date: Mon, 14 Sep 2026 19:33:30 -0500 Subject: [PATCH] feat(git): add pre-commit hook and optimize test script for local path execution This commit streamlines the local developer workflow by enforcing automated quality checks pre-commit and speeding up test execution when development tools are present in the environment $PATH. - Add `.githooks/pre-commit` hook to automatically run the verification suite via `scripts/test` before committing. - Update `scripts/test` to check for locally available commands (`luacheck`, `ruff`, `pyright`) in PATH before falling back to `nix-shell`. - Add `luaPackages.luacheck` to developer packages in `home/dev.nix`. - Routine lockfile input revisions (`flake.lock`) update for: DankMaterialShell, dankcalendar, and home-manager. --- .githooks/pre-commit | 12 ++++++++++++ flake.lock | 24 ++++++++++++------------ home/dev.nix | 1 + scripts/test | 14 ++++++++++++-- 4 files changed, 37 insertions(+), 14 deletions(-) create mode 100755 .githooks/pre-commit diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..ed723be --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +# .githooks/pre-commit - Git pre-commit hook running automated quality checks +set -euo pipefail + +# Ensure NixOS user profile binaries are in PATH +export PATH="/etc/profiles/per-user/${USER:-kiskaadee}/bin:$HOME/.nix-profile/bin:$PATH" + +REPO_ROOT="$(git rev-parse --show-toplevel)" +cd "$REPO_ROOT" + +echo "🚀 [pre-commit] Running automated verification & static analysis suite..." +exec "$REPO_ROOT/scripts/test" diff --git a/flake.lock b/flake.lock index c5c89c1..56191d6 100644 --- a/flake.lock +++ b/flake.lock @@ -61,11 +61,11 @@ "dank-qml-common_2": { "flake": false, "locked": { - "lastModified": 1788219423, - "narHash": "sha256-U4WBPh+pfM2IRF+IOWWHaw3cWaR1kYtl+Rdp7i9S2OQ=", + "lastModified": 1789422809, + "narHash": "sha256-xfWdZ5WFluH0hcDiLrVacJok/1n/+u3wTt8rKe1xlQc=", "owner": "AvengeMedia", "repo": "dank-qml-common", - "rev": "a9ae19facd460a4150da269dafcfb044b0dd9eea", + "rev": "e145d7857264daa0359f83aa5cd382d76742a1bd", "type": "github" }, "original": { @@ -98,11 +98,11 @@ ] }, "locked": { - "lastModified": 1789325878, - "narHash": "sha256-lpgXRZ3SUtTBBsk3/hqlRtva82aI7dHxzbQsunj7oIY=", + "lastModified": 1789423018, + "narHash": "sha256-ZUEdR12HguRVDETMW9AxOjwI0oJyQsp80bmi7gdJtsA=", "owner": "AvengeMedia", "repo": "dankcalendar", - "rev": "2f811b14f973521a67af7c71a6a26a9cc42cdada", + "rev": "2cfcbf342ea0c8007e7b0491a3e2a1f05c413964", "type": "github" }, "original": { @@ -160,11 +160,11 @@ ] }, "locked": { - "lastModified": 1789406047, - "narHash": "sha256-HvOg9PZCCvgusyYJvrWKO/8V6Gfpg1/wTd9NREZTbjE=", + "lastModified": 1789410700, + "narHash": "sha256-WE50/Jsa9shfm+uAXi7SF+v7qQ3oc6ZtAOhocoery3Q=", "owner": "AvengeMedia", "repo": "DankMaterialShell", - "rev": "6af2b1fbc3eea4c2c0accee56b9c260ce88f5ea2", + "rev": "05c807b7cd87f29dc8c26f8a33cabcaa07d9c823", "type": "github" }, "original": { @@ -214,11 +214,11 @@ ] }, "locked": { - "lastModified": 1789386765, - "narHash": "sha256-4hyLFBhzQC7+qPMELWc7J/sbdA6ckXZxXU9CYRsGhsc=", + "lastModified": 1789430117, + "narHash": "sha256-t+U1mijItLJ64xZOifpfQ17kpAL73nU7pDI48ScacVc=", "owner": "nix-community", "repo": "home-manager", - "rev": "87c391f49a34660de6010f35bb50fb1bf811be9f", + "rev": "cda90fd8838825c689fde9d3f3b4e937937790df", "type": "github" }, "original": { diff --git a/home/dev.nix b/home/dev.nix index 188c364..c9caa04 100644 --- a/home/dev.nix +++ b/home/dev.nix @@ -81,6 +81,7 @@ jdt-language-server typescript-language-server lua-language-server + luaPackages.luacheck taplo marksman shellcheck diff --git a/scripts/test b/scripts/test index 3a55de9..3820e93 100755 --- a/scripts/test +++ b/scripts/test @@ -9,11 +9,21 @@ find . -type f -name "*.sh" -not -path "./.git/*" -exec shellcheck -s bash {} + echo "✅ ShellCheck passed!" echo "🌙 Checking Neovim Lua configuration (luacheck)..." -nix-shell -p luaPackages.luacheck --run "luacheck home/config/nvim --globals vim" +if command -v luacheck &>/dev/null; then + luacheck home/config/nvim --globals vim +else + nix-shell -p luaPackages.luacheck --run "luacheck home/config/nvim --globals vim" +fi echo "✅ Lua checks passed!" echo "🐍 Running Python linters & type analysis (Ruff & Pyright)..." -nix-shell -p ruff pyright --run "ruff check --no-cache . && ruff format --check . && pyright ." +if command -v ruff &>/dev/null && command -v pyright &>/dev/null; then + ruff check --no-cache . + ruff format --check . + pyright . +else + nix-shell -p ruff pyright --run "ruff check --no-cache . && ruff format --check . && pyright ." +fi echo "✅ Python checks passed!" echo "❄️ Verifying NixOS flake & sandbox checks..."