Skip to content

Development

The repository is a monorepo:

Folder What it is
cloud/ GitNotify on Cloudflare Workers (src, tests, migrations, scripts), with the email relay in cloud/relay/
selfhosted/ self-hosted GitNotify in Rust with SQLite, one binary
docs/ these guides, the canonical source of the documentation site
site/ the documentation site, built with Astro and Starlight

The source is at https://git.h1n054ur.dev/borderless-tech/gitnotify. GitNotify is free software under the GNU General Public License, version 3 or (at your option) any later version.

Requires bun. Commands run from cloud/.

Terminal window
cd cloud
bun install
cp .dev.vars.example .dev.vars # local values, never commit it
bun run db:migrate:local
bun run dev # wrangler dev
Command Does
bunx biome ci . lint and format check (bun run format writes)
bun run check wrangler types and tsc --noEmit
bun run test Vitest: unit (Node) and integration (workerd with D1, queues and Durable Objects), including a 50-server load test

All three must be green before you push, and CI runs the same. Changing wrangler.jsonc needs bun run check, which regenerates worker-configuration.d.ts. The compatibility_date must not be newer than the workerd bundled with @cloudflare/vitest-plugin, or the integration tests refuse to start. New D1 migrations go in cloud/migrations/ and are applied before the code that needs them is deployed.

Path What it is
src/index.ts the GitHub, Discord, Slack and Telegram endpoints, the sign-in pages, the admin API, and the queue and cron handlers
src/queue.ts the queue consumer: facts to core state, then fan-out to servers, workspaces and groups, intents, setup and repair, and digest jobs
src/core/ the platform-neutral core: signature verification, event parsing, pull request and run state, incidents, installations, and the digest builder and schedule
src/discord/, src/slack/, src/telegram/ the three integrations: rendering, delivery, commands, interactions, setup and repair, digests
src/shared/ platform-neutral helpers for GitHub proof, linking, ownership, digests, email, encryption and audit
tests/unit, tests/integration, tests/fixtures the tests and GitHub payload fixtures
  • src/core never imports src/discord, src/slack, src/telegram or src/shared. src/shared may import core but never an integration. The three integrations never import each other. tests/unit/boundary.test.ts and tests/unit/platform-boundary.test.ts check this.
  • Core holds raw GitHub text. Escaping happens only in each integration's renderer.
  • The Zod schemas in src/core/github/events.ts declare only the fields the cards read.
  • Logs carry ids and outcomes, never payload text. Telegram tests also assert that logs hold no text, titles, usernames or secrets.
  • Every rendered Discord card is checked for its flags, empty allowed_mentions and length. Slack cards stay within Block Kit's limits, and Telegram cards within 4,096 characters.

Integration tests run in workerd. They fake the chat platforms by stubbing fetch, and never call the real Discord, Slack or Telegram APIs. Seed state with the helpers in tests/integration/.

The relay in cloud/relay/ is a separate Worker with its own package.json, lockfile and tests. It must stay self-contained, because it is deployed on its own.

Terminal window
cd cloud/relay
bun install
bun run check && bun run test

Lint runs from cloud/ with bunx biome ci .. src/index.ts holds the checks and the send, src/render.ts the Ember HTML and text, src/types.ts the protocol, and tests/ the signature, replay, allowlist, cap and escaping tests. See Email relay.

Requires a current Rust toolchain. Commands run from selfhosted/.

Terminal window
cd selfhosted
cargo fmt --check
cargo clippy --all-targets --locked -- -D warnings
cargo test --locked

All three must be green before you push. The self-hosted server's behaviour is held to the Worker's by shared golden cases: bun run golden:export in cloud/ runs the Worker's own functions and writes the cases to cloud/tests/golden and selfhosted/tests/golden. To run the server, see Install GitNotify.

The guides are Markdown files in docs/. Edit them there, never in site/src/content: the site generates its Starlight collection from docs/ using the route list in site/scripts/docs-map.mjs, which also drives the sidebar.

Terminal window
cd site
bun install
bun run dev # local preview
bun run verify # sync the docs, astro check, build and check links

When you write a guide:

  • Start the file with one # Title on the first line and no frontmatter. The site uses it as the page title.
  • Link to other guides by their bare file name, such as [Discord](discord.md) or [Repair](slack.md#repair). Anchors must match real headings.
  • Link to repository files outside docs/ with full URLs to the forge.
  • Use tables, numbered steps and short lists. The site does not render Mermaid or HTML.
  • Add a new page to site/scripts/docs-map.mjs and to docs/README.md.

Run the checks for every folder your change touches:

Terminal window
cd cloud && bunx biome ci . && bun run check && bun run test
cd cloud/relay && bun run check && bun run test
cd selfhosted && cargo fmt --check && cargo clippy --all-targets --locked -- -D warnings && cargo test --locked
cd site && bun run verify

CI runs only the jobs for the folders a change touches. Update the guide in docs/ in the same change as any user-facing behaviour.