`v2: Add left-hook pre-push#1003
`v2: Add left-hook pre-push#1003KKonstantinov wants to merge 11 commits intomodelcontextprotocol:mainfrom
Conversation
… npm install on checkout and merge
|
What happens if the test(s) fail? I once had a colleague tell me they don't like putting things like tests in a pre-commit script because you should never stop a developer from committing their code. To be fair, this was in the context of employees working on a commercial software stack, not an open source SDK. Still, it has stuck with me and I think there is something to it. Example might be if a developer is going out of town for a week and wants to commit their work in progress on a feature. If it is failing a test and can't be committed, then no one else can pick it up while they are out. |
They can still do |
|
Appreciate the PR! Maybe we should discuss this in an in issue/discussion to figure out what we want to agree on? fwiw my view is that if you want to run things locally you always can, and if not CI will be there to catch this. I've personally found pre-commit/other hooks burn more of my time than they save, or are frustrating when trying to commit a WIP or draft piece of work (appreciate can use |
|
could we do pre-push by default, and make pre-commit optional? |
…cript-sdk into feature/ts-sdk-hooks
… into feature/ts-sdk-hooks
This is a great idea and alleviates a lot of the concerns. Done and pushed. cc @pcarleton |
|
Following up on this. We could observe a lot of PRs having a "prettier fix" commit quite often - this on top of a "test fix" commit. Having some hooks would resolve that. |
|
@modelcontextprotocol/client
@modelcontextprotocol/server
@modelcontextprotocol/express
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
This is a follow-up to #976 with a goal of improving DX and reducing contributor friction by ensuring linting, formatting, and builds are validated before pushing.
It introduces the following git hooks via Lefthook:
Default Hooks (
lefthook.yml)Pre-push (runs in parallel):
pnpm typecheck:all)pnpm lint:all)pnpm build:all)Post-checkout & Post-merge:
pnpm installto keep dependencies in syncOptional Pre-commit Hooks (
lefthook-local.example.yml)For contributors who prefer earlier feedback, an optional pre-commit configuration is provided:
This enables:
pnpm typecheck:all)pnpm lint:fix:all) withstage_fixed: trueMotivation and Context
PRs could get slowed down by failing CI when there is an accidental omission by the contributor to run lint/typecheck/build before pushing.
Using pre-push as the default (rather than pre-commit) balances catching issues early while not slowing down the commit workflow. Contributors who want faster feedback can opt into the pre-commit hooks.
How Has This Been Tested?
npx lefthook run pre-pushlefthook-local.example.ymltolefthook-local.ymlBreaking Changes
No breaking changes, a pure DX improvement.
Types of changes
Checklist