From 058d749202bbeb16fbab0e8e3cbbeece58fa8d3f Mon Sep 17 00:00:00 2001 From: PerfectPan <24316656+PerfectPan@users.noreply.github.com> Date: Wed, 18 Nov 2026 21:15:24 +0800 Subject: [PATCH 1/2] ci(checks): enforce the duplicate code gate Co-Authored-By: Codex --- .github/pull_request_template.md | 1 + .github/workflows/pull-request.yml | 3 +++ AGENTS.md | 1 + CONTRIBUTING.md | 1 + docs/architecture.md | 1 + 5 files changed, 7 insertions(+) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 562a4c3..8f6a0f1 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -11,6 +11,7 @@ - [ ] `pnpm lint` (vp check) and `pnpm typecheck` +- [ ] `pnpm duplicates` (fails on any reported clone, while `pnpm duplicates:audit` only reports findings) - [ ] `pnpm test` — unit tests - [ ] `pnpm --filter @blog/web build` + size gate (`wrangler deploy --dry-run`, < 3 MiB gzip) - [ ] Behavior verified beyond CI green (relevant flow, local e2e, or the preview deployment — see AGENTS.md §9) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index cc744d8..9d2c5e2 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -35,6 +35,9 @@ jobs: - name: Lint (vp check) run: pnpm lint + - name: Check for duplicate code + run: pnpm duplicates + - name: Unit Tests run: pnpm test diff --git a/AGENTS.md b/AGENTS.md index 69e40c7..0f84a23 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -91,6 +91,7 @@ pnpm deploy ```bash pnpm typecheck pnpm lint # = vp check(Oxfmt 格式检查 + Oxlint lint,含 shadcn token 规则,与 CI lint job 一致) +pnpm duplicates # 检出任何一处重复即失败。`pnpm duplicates:audit` 只生成报告。 pnpm --filter @blog/web build pnpm --filter @blog/web exec wrangler deploy -c dist/server/wrangler.json --dry-run # 守 3 MiB ``` diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a2b29c0..db2059a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -64,6 +64,7 @@ Specs and Plans in the delivery PR. ```bash pnpm lint # vp check — Oxfmt format check + Oxlint across the repo pnpm typecheck # tsc (TypeScript 7 native) +pnpm duplicates # Fails on any reported clone. `pnpm duplicates:audit` only reports findings. pnpm test # vp test (Vitest 5) — unit tests pnpm --filter @blog/web build pnpm --filter @blog/web exec wrangler deploy -c dist/server/wrangler.json --dry-run diff --git a/docs/architecture.md b/docs/architecture.md index a9d3415..8d6be6a 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -225,6 +225,7 @@ pnpm --filter @blog/web dev # vp dev(Vite+) - **改表结构**:加 `apps/web/migrations/000N_*.sql`;deploy 时自动应用到远端、本地用 `--local`。 - **改可见性逻辑**:`packages/shared/src/access.ts`(`canAccessVisibility`)+ 在数据层 fn 里强制。 - **提交前最低验证**:`pnpm typecheck`;`pnpm lint`(`vp check`:Oxfmt 格式检查 + Oxlint); + `pnpm duplicates` 检出任何一处重复即失败(`pnpm duplicates:audit` 只生成报告)。 `pnpm --filter @blog/web build`;`pnpm --filter @blog/web exec wrangler deploy -c apps/web/dist/server/wrangler.json --dry-run`(体积守门)。 - **密钥**:`wrangler secret put `(绝不进 git);非密钥配置走 `wrangler.jsonc` 的 `vars`。 From 1244bc5e70b3230fbf2691d9cee96a2dbbead1dc Mon Sep 17 00:00:00 2001 From: PerfectPan <24316656+PerfectPan@users.noreply.github.com> Date: Wed, 18 Nov 2026 21:29:29 +0800 Subject: [PATCH 2/2] docs: keep the pre-commit checks as one list Co-Authored-By: Claude Opus 5.5 --- docs/architecture.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/architecture.md b/docs/architecture.md index 8d6be6a..6372939 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -225,7 +225,7 @@ pnpm --filter @blog/web dev # vp dev(Vite+) - **改表结构**:加 `apps/web/migrations/000N_*.sql`;deploy 时自动应用到远端、本地用 `--local`。 - **改可见性逻辑**:`packages/shared/src/access.ts`(`canAccessVisibility`)+ 在数据层 fn 里强制。 - **提交前最低验证**:`pnpm typecheck`;`pnpm lint`(`vp check`:Oxfmt 格式检查 + Oxlint); - `pnpm duplicates` 检出任何一处重复即失败(`pnpm duplicates:audit` 只生成报告)。 + `pnpm duplicates` 检出任何一处重复即失败(`pnpm duplicates:audit` 只生成报告); `pnpm --filter @blog/web build`;`pnpm --filter @blog/web exec wrangler deploy -c apps/web/dist/server/wrangler.json --dry-run`(体积守门)。 - **密钥**:`wrangler secret put `(绝不进 git);非密钥配置走 `wrangler.jsonc` 的 `vars`。