Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,9 @@ jobs:
- name: Install dependencies
run: bun install --frozen-lockfile

- name: Typecheck
run: bun run typecheck

- name: Test
# TZ is pinned to Asia/Shanghai because cost-tracker.test.ts uses
- name: Quality gate
# quality:ci pins TZ for tests because cost-tracker.test.ts uses
# +08:00 timestamps and aggregateCostReport bucket boundaries are
# computed via dayjs(...).startOf("day"), which is system-TZ-coupled.
# TODO: make aggregateCostReport TZ-agnostic and drop this pin.
env:
TZ: Asia/Shanghai
run: bun run test

- name: Build (Next.js)
run: bun run build

- name: Build (CLI)
run: bun run build:cli
run: bun run quality:ci
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bun run quality:precommit
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,21 @@ bun run dev
# Run tests
bun run test

# Run the pre-commit quality gate
bun run quality:precommit

# Run the full CI quality gate
bun run quality:ci

# Run CLI locally
bun dist/cli.js --help
```

`bun install` installs Husky hooks through the `prepare` script. The pre-commit
hook runs `bun run quality:precommit` to check staged whitespace, TypeScript, and
tests before code is committed. CI runs `bun run quality:ci`, which adds the
production dashboard and CLI builds.

---

## License
Expand Down
3 changes: 3 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@
"scripts"
],
"scripts": {
"prepare": "husky",
"dev": "next dev",
"build": "next build",
"build:cli": "tsup",
"build:web": "next build",
"start": "next start",
"test": "node --test --import tsx --test-reporter spec 'src/core/__tests__/*.test.ts' 'src/components/sessions/*.test.ts'",
"test:e2e:task-launch": "node scripts/task-launch-e2e.mjs",
"typecheck": "tsc --noEmit"
"typecheck": "tsc --noEmit",
"quality:precommit": "git diff --cached --check && bun run typecheck && TZ=Asia/Shanghai bun run test",
"quality:build": "bun run build:web && bun run build:cli",
"quality:ci": "bun run typecheck && TZ=Asia/Shanghai bun run test && bun run quality:build",
"quality": "bun run quality:ci"
},
"keywords": [
"claude",
Expand Down Expand Up @@ -80,6 +85,7 @@
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"husky": "^9.1.7",
"shadcn": "^3.8.4",
"tailwindcss": "^4",
"tsup": "^8.5.1",
Expand Down
37 changes: 37 additions & 0 deletions src/core/__tests__/quality-gates.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import assert from "node:assert/strict";
import { readFileSync, statSync } from "node:fs";
import { test } from "node:test";

const repoRoot = new URL("../../../", import.meta.url);

function readRepoFile(path: string): string {
return readFileSync(new URL(path, repoRoot), "utf8");
}

test("package scripts define the shared DevLog quality gates", () => {
const pkg = JSON.parse(readRepoFile("package.json"));

assert.equal(pkg.scripts.prepare, "husky");
assert.equal(
pkg.scripts["quality:precommit"],
"git diff --cached --check && bun run typecheck && TZ=Asia/Shanghai bun run test",
);
assert.equal(
pkg.scripts["quality:build"],
"bun run build:web && bun run build:cli",
);
assert.equal(
pkg.scripts["quality:ci"],
"bun run typecheck && TZ=Asia/Shanghai bun run test && bun run quality:build",
);
assert.equal(pkg.scripts.quality, "bun run quality:ci");
});

test("Husky pre-commit hook runs the shared pre-commit gate", () => {
const hookPath = new URL(".husky/pre-commit", repoRoot);
const hook = readFileSync(hookPath, "utf8");
const mode = statSync(hookPath).mode;

assert.match(hook, /bun run quality:precommit/);
assert.equal(mode & 0o111, 0o111);
});
Loading