Repository navigation
Development
How to work on Glint's code: local setup, tests, conventions and the contribution workflow. The short version is in CONTRIBUTING.md.
Requires Node.js 22+, and gitleaks for the pre-commit hook.
git clone https://github.com/smith8ca/Glint.git
cd Glint
cd webhook-receiver && npm install
cd ../e2e-test && npm install
cd ..
cp webhook-receiver/.env.example webhook-receiver/.env # then edit it
git config core.hooksPath .githooks # enable the secret-scan hookcd webhook-receiver
npm run dev # ts-node, straight from src/ (no file watching: restart after edits)
npm run build # compile to dist/
npm start # run dist/index.jsTo try it without GitLab, send a request by hand:
curl -i http://localhost:3000/webhook \
-H 'Content-Type: application/json' \
-H 'X-Gitlab-Event: Merge Request Hook' \
-H "X-Gitlab-Token: $WEBHOOK_SECRET" \
-d '{"object_kind":"merge_request","project":{"id":1},"object_attributes":{"iid":1,"action":"update"}}'
# HTTP/1.1 200 OK … {"message":"Ignored: action 'update'"}cd webhook-receiver
npm test # Vitest, run once
npm run test:coverage # with V8 coverage; LCOV in coverage/The suite (100+ tests, about 99% line coverage) covers config loading, both authentication modes, payload validation, routing, the GitLab and Claude clients (mocked), private-CA trust and error formatting. It needs no network access and no credentials. CI runs it on every pull request.
Tests live in webhook-receiver/src/__tests__/, mirroring the src/ layout.
cd e2e-test
npm testThis builds both packages, starts a mock GitLab API on port 4000, spawns the real receiver on port 3001 pointed at it, sends the fixture Merge Request Hook, and waits up to 60 seconds for a note to be posted. It prints the note and exits 0 on success.
- It calls the real Anthropic API (a few cents per run).
- It reads
webhook-receiver/.envand needsANTHROPIC_API_KEY,WEBHOOK_SECRETand a non-emptyGITLAB_TOKENthere (the mock accepts any value). - It authenticates with
X-Gitlab-Token, so comment outWEBHOOK_SIGNING_TOKENwhile running it, or every request is rejected with401. - Ports and timeout can be changed with
MOCK_GITLAB_PORT,RECEIVER_PORTandNOTE_TIMEOUT_MS. - Only the MR flow is covered end to end; release notes are covered by unit tests.
CI only type-checks the harness, because it needs an API key.
-
TypeScript strict mode stays on. No
anywithout a good reason. -
Never pass
override: trueto dotenv. The e2e harness and container platforms set variables in the process environment;.envmust not overwrite them. -
Never log raw HTTP client errors. Use
describeError()fromutils/errors.ts, which strips thePRIVATE-TOKENheader. -
Background work catches its own errors. After the
202there is no response left to fail; log and move on. - Keep dependencies minimal and explain any new one in the PR.
- Files use CRLF line endings, except
.githooks/*(LF, enforced by.gitattributes). - No linter is configured yet; match the surrounding style.
- In
routes/webhook.ts, add a branch on theX-Gitlab-Eventvalue and a payload interface for the fields you need. - Validate every payload field you use before calling GitLab.
- Respond
202before the slow work; run the work in an async function with a.catchthat logsdescribeError(err). - Add GitLab calls to
services/gitlab.tsand the prompt toservices/claude.ts. - Write unit tests alongside the existing ones, and a mock route and fixture in
e2e-test/if it should be covered end to end. - Document it on API Reference and in the README.
| Branch | Purpose |
|---|---|
main |
Released code only. Every merge cuts a release. |
dev |
Integration branch. All pull requests target dev. |
feature/…, fix/…, chore/…
|
Work branches, created from dev
|
- Branch from an up-to-date
dev. - Commit in focused steps with Conventional Commit-style messages (
feat:,fix:,ci:,docs:,chore:). Glint's own release notes rely on these prefixes. - Add a line under
[Unreleased]inCHANGELOG.mdfor user-visible changes. - Open a pull request into
dev. CI must pass: Secret scan, Build and test, Typecheck e2e harness, Docker build.
Releases are covered in CI/CD and Releases.
| To change… | Edit |
|---|---|
| Webhook authentication | webhook-receiver/src/middleware/validateSecret.ts |
| Event routing, validation, comment wrapper | webhook-receiver/src/routes/webhook.ts |
| Prompts, model parameters, truncation limits | webhook-receiver/src/services/claude.ts |
| GitLab API calls, TLS trust | webhook-receiver/src/services/gitlab.ts |
| Environment variables |
webhook-receiver/src/config.ts (and .env.example, README, Configuration) |
| End-to-end orchestration |
e2e-test/src/index.ts, e2e-test/src/mockGitlab.ts
|
Glint · MIT licence · Report an issue · Found a mistake in these docs? Open an issue and say which page.
Using Glint
Reference
Contributing
Help