chore: install pre-commit/pre-push git hooks - #162
Open
PenguinzTech wants to merge 1 commit into
Open
Conversation
Repo had no .pre-commit-config.yaml, no install-hooks target, and no hooks at all — every commit was completely ungated. Wires up the standard PenguinTech pre-commit framework (gitleaks, shellcheck, ruff, hadolint, actionlint at commit time; bandit + Dockerfile rootless check at push time), adds make install-hooks/verify-hooks (setup now depends on install-hooks), and adds the canonical [tool.ruff] block. Also replaces a stale husky snippet in docs/hub_module/TESTING.md (husky is unused anywhere in this org) with the make install-hooks flow. Fixes a worktree-path bug in the verify() helper: it resolved hooks via "$(git rev-parse --show-toplevel)/.git/hooks/<hook>", which is wrong inside a linked worktree (.git there is a file, not a directory) and made every hook falsely report NOT INSTALLED. Now resolves via `git rev-parse --git-common-dir`. Node/ESLint intentionally left out of this pass — see PR description.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.pre-commit-config.yaml, noinstall-hookstarget, no hooks at all — every commit was completely ungated.pre-commitframework: gitleaks, shellcheck, ruff (+ruff-format), hadolint, actionlint, plus hygiene fixers at commit time; bandit + Dockerfile-rootless check at push time.make install-hooks/make verify-hooks;make setupnow depends oninstall-hooks.[tool.ruff]block in a new rootpyproject.toml(repo has no packageable rootpyproject.toml— config-only,target-version = "py313"matching the 89/90 Dockerfiles onpython:3.13).docs/hub_module/TESTING.md(husky is unused anywhere in this org, contradictsdevops.md) with themake install-hooksflow.Notable findings (not fixed here — out of scope for a hooks-only PR)
scripts/install-pre-commit.sh'sverify()resolved hooks via"$(git rev-parse --show-toplevel)/.git/hooks/<hook>". Inside a linked worktree.gitis a file, not a directory, so this always false-negatived. Fixed to resolve viagit rev-parse --git-common-dir. Same bug exists inadmin/scripts/install-pre-commit.sh— worth porting upstream.shared/py_libsduplication — does not exist onv2.2.xshared/py_libs/pyproject.tomlvsshared/shared/py_libs/pyproject.tomlas an apparent duplicate. That's true onmain/chore/add-codeowners, butv2.2.x(this PR's base) already migratedshared/entirely to publishedpenguin-libspackages (commita0b5c315) — there is noshared/directory at all on this branch. The two lineages have diverged since common ancestora89906ff; nothing to resolve here.admin/hub_module/frontend/node_modules/is committed to gitnode_modules/being in root.gitignore. Its installedeslintpackage is broken (MODULE_NOT_FOUND: ../lib/cli) even though the version matchespackage.json. This is why no Node/ESLint hook is included in.pre-commit-config.yaml— it would fail on every touch regardless of code quality. Recommend: stop committingnode_modules/, reinstall clean, then add the ESLint hook back.deck(38MB Go binary) committed at repo rootcheck-added-large-files(1MB threshold) didn't flag it in a full-repo scan — worth a follow-up look, but unrelated to this PR.package-lock.jsonis gitignored (root.gitignoreline ~180)general.md/devops.mdnpm pinning ("commitpackage-lock.json, exact versions,npm ciin CI"). Pre-existing, unrelated to hooks.make lint/make test-securitytargets swallow all errors via|| truemake pre-commit"passes" regardless of findings. Pre-existing, separate from the new framework this PR adds (which is enforced going forward via git hooks on staged files).pre-commit run --all-filespre-commit run/pre-commit run --hook-stage pre-pushagainst just the staged files, and the commit/push above both ran clean through the real hooks).Test plan
make install-hooks— framework + both hooks registeredmake verify-hooks— both hooks report installed, executable, non-emptypre-commit run(commit-stage, staged files) — all pass/skip cleanpre-commit run --hook-stage pre-push— all pass/skip cleangit commitandgit pushof this branch ran through the real hooks and passed.worktrees/already in.gitignore(no change needed)