Skip to content

chore(hooks): replace pip pre-commit framework with plain .githooks - #923

Merged
edenreich merged 2 commits into
mainfrom
chore/githooks-pre-commit
Jul 16, 2026
Merged

edenreich merged 2 commits into
mainfrom
chore/githooks-pre-commit

Conversation

@edenreich

Copy link
Copy Markdown
Contributor

Why

In the #921 @infer run (29505567185), the agent's pre-commit run spent 7m2s cold-installing pip hook environments and was killed by the Bash tool timeout (exit status -1). The framework's only real job here was invoking task commands.

What

  • .githooks/pre-commit (plain POSIX sh, same pattern as infer-action): git diff --cached --check for trailing whitespace + conflict markers, task mod:tidy when go.mod/go.sum staged, task mocks:generate when internal/domain/interfaces.go staged, then task fmt + task lint
  • Uses task from PATH and announces which one it picked (pre-commit: using task from PATH (...)), so CI logs show the pipeline toolchain won; falls back to re-executing inside flox activate only for local commits outside an activated shell; fails loudly when neither is available. CI needs neither flox nor pip for the hook.
  • task precommit:install → git config core.hooksPath .githooks; task precommit:run → runs the hook directly (existing CI/agent contract unchanged)
  • Deleted .pre-commit-config.yaml, dropped pre-commit from the flox manifest, updated docs
  • Dropped framework checks (end-of-file-fixer, check-yaml/json/toml, large-files, mixed-line-ending): gofmt/golangci/markdownlint cover the code paths, broken YAML/JSON fails CI anyway

Also includes a test(telemetry) commit: scrub inherited TRACEPARENT/OTEL_* env in the package's TestMain — under a live infer session the fixture recorders were exporting fake session → chat openai/gpt-4o spans into the real trace (the _OTHER error in the #921 trace) and TestTraceSpansNestAndExport fails because its session span is no longer a root.

Follow-up for the reusable workflow (drop pip install pre-commit): inference-gateway/.github#112

Verification

  • task precommit:run passes on a clean tree; both commits in this PR were made through the new hook
  • Staged trailing whitespace → hook exits 2 with the offending line
  • Stripped-PATH runs verified all three toolchain branches (PATH / flox re-exec / neither → exit 1)
  • TRACEPARENT=... OTEL_EXPORTER_OTLP_ENDPOINT=... go test ./internal/telemetry/... fails without the TestMain scrub, passes with it

The pip-based pre-commit framework cold-installs its hook environments on
every fresh CI runner; in the #921 @infer run that took 7m2s and was killed
by the agent's Bash tool timeout. Replace it with a plain .githooks/pre-commit
shell script (same pattern as infer-action): git diff --cached --check for
whitespace/conflict markers, staged-file-gated mod:tidy and mocks:generate,
then fmt + lint.

The hook uses task from PATH (announcing which one it picked) and only falls
back to re-executing inside flox for local commits made outside an activated
shell, so CI needs neither flox nor pip. task precommit:install now sets
core.hooksPath; task precommit:run executes the hook directly, keeping the
existing CI/agent contract. pre-commit is dropped from the flox manifest.
When the telemetry unit tests run under a live infer session (an agent
running go test), ChildEnv has injected TRACEPARENT and OTLP exporter env
vars into the subprocess. The fixture recorders then export real OTLP spans
parented under the live tool span - fake 'session/chat openai/gpt-4o' trees
appeared in the #921 run's trace - and TestTraceSpansNestAndExport fails
because its session span is no longer a root. Unset the trace-context and
OTEL_* vars in TestMain so the package is hermetic.
@edenreich
edenreich requested a review from a team as a code owner July 16, 2026 19:14
@edenreich
edenreich merged commit 9b75921 into main Jul 16, 2026
1 check passed
@edenreich
edenreich deleted the chore/githooks-pre-commit branch July 16, 2026 19:21
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.148.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant