ci: add branch protection, CI workflow, and PR template

- husky pre-commit hook blocks direct commits to main
- github actions CI runs lint + build on PRs
- PR template and CONTRIBUTING.md for workflow docs
This commit is contained in:
Nicholai Vogel 2026-01-24 14:23:14 -07:00
parent bb0f8d2eda
commit f554f4e38c
6 changed files with 108 additions and 2 deletions

15
.github/pull_request_template.md vendored Executable file
View File

@ -0,0 +1,15 @@
## what
<!-- what does this PR do -->
## why
<!-- context/motivation, link to issue if applicable -->
## how to test
<!-- steps to verify -->
## notes
<!-- tradeoffs, anything reviewers should know -->

26
.github/workflows/ci.yml vendored Executable file
View File

@ -0,0 +1,26 @@
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- run: bun install --frozen-lockfile
- run: bun run lint
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- run: bun install --frozen-lockfile
- run: bun run build

8
.husky/pre-commit Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
branch=$(git rev-parse --abbrev-ref HEAD)
if [ "$branch" = "main" ]; then
echo "direct commits to main are blocked."
echo "create a feature branch: git checkout -b <username>/<feature>"
exit 1
fi

52
CONTRIBUTING.md Executable file
View File

@ -0,0 +1,52 @@
contributing
===
local setup
---
```bash
git clone git@github.com:High-Performance-Structures/compass.git
cd compass
bun install
bun dev
```
branching
---
branch off main using the format `<username>/<feature>`:
```bash
git checkout -b nicholai/add-gantt-zoom
```
direct commits to main are blocked by a pre-commit hook.
commits
---
use conventional commits:
```
type(scope): subject
```
- types: feat, fix, docs, style, refactor, perf, test, build, ci, chore
- subject: imperative mood, 50 chars max
- body: 72 chars max width, explain *why* not *what*
pull requests
---
1. push your branch and open a PR against main
2. CI runs lint + build automatically
3. both checks must pass before merge
4. PRs are squash-and-merged (single clean commit on main)
the PR template will guide you on what to include.
deployment
---
deployment to cloudflare workers happens manually via `bun deploy`.
this is separate from the PR/merge workflow.

View File

@ -71,6 +71,7 @@
"drizzle-kit": "^0.31.8",
"eslint": "^9",
"eslint-config-next": "15.4.6",
"husky": "^9.1.7",
"tailwindcss": "^4",
"typescript": "^5",
"wrangler": "^4.59.3",
@ -1194,6 +1195,8 @@
"humanize-ms": ["humanize-ms@1.2.1", "", { "dependencies": { "ms": "^2.0.0" } }, "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ=="],
"husky": ["husky@9.1.7", "", { "bin": { "husky": "bin.js" } }, "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA=="],
"iconv-lite": ["iconv-lite@0.7.2", "", { "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" } }, "sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw=="],
"ignore": ["ignore@5.3.2", "", {}, "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g=="],

View File

@ -13,7 +13,8 @@
"cf-typegen": "wrangler types --env-interface CloudflareEnv ./cloudflare-env.d.ts",
"db:generate": "drizzle-kit generate",
"db:migrate:local": "wrangler d1 migrations apply compass-db --local",
"db:migrate:prod": "wrangler d1 migrations apply compass-db --remote"
"db:migrate:prod": "wrangler d1 migrations apply compass-db --remote",
"prepare": "husky"
},
"dependencies": {
"@dnd-kit/core": "^6.3.1",
@ -82,8 +83,9 @@
"drizzle-kit": "^0.31.8",
"eslint": "^9",
"eslint-config-next": "15.4.6",
"husky": "^9.1.7",
"tailwindcss": "^4",
"typescript": "^5",
"wrangler": "^4.59.3"
}
}
}