From 280b51e666d0d41890ba777598a42628174ea67d Mon Sep 17 00:00:00 2001 From: Danila Poyarkov Date: Sun, 7 Jun 2026 00:36:47 +0300 Subject: [PATCH] ci: gate invalid pull requests with CodeRabbit (#327) * ci: gate invalid pull requests with CodeRabbit * fix: harden CodeRabbit PR hygiene gate * fix: make invalid PR label creation idempotent --- .coderabbit.yaml | 22 ++++ .github/PULL_REQUEST_TEMPLATE.md | 21 ++-- .github/copilot-instructions.md | 38 +++++++ .github/scripts/close-invalid-prs.ts | 140 ++++++++++++++++++++++++ .github/workflows/close-invalid-prs.yml | 42 +++++++ CONTRIBUTING.md | 8 ++ 6 files changed, 264 insertions(+), 7 deletions(-) create mode 100644 .coderabbit.yaml create mode 100644 .github/copilot-instructions.md create mode 100644 .github/scripts/close-invalid-prs.ts create mode 100644 .github/workflows/close-invalid-prs.yml diff --git a/.coderabbit.yaml b/.coderabbit.yaml new file mode 100644 index 000000000..6026fac88 --- /dev/null +++ b/.coderabbit.yaml @@ -0,0 +1,22 @@ +# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json +language: "en-US" +early_access: false + +reviews: + profile: "assertive" + request_changes_workflow: true + high_level_summary: true + review_status: true + auto_review: + enabled: true + drafts: false + pre_merge_checks: + description: + mode: "error" + custom_checks: + - name: "PR Hygiene" + mode: "error" + instructions: "Fail if the PR title or description is not written in English, does not follow the repository PR template, contains leftover template comments or placeholders such as 'Fixes #', TODO, TBD, has no meaningful summary, has no concrete list of changes, or does not document validation. Pass only when the PR clearly explains what changed, why it changed, and how it was validated." + +chat: + auto_reply: true diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index e342f548c..6701fd544 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,10 +1,17 @@ -Fixes # +> Security vulnerability? Do not open a public PR. Report it privately through GitHub Security Advisories: https://github.com/open-pencil/open-pencil/security/advisories/new -> Security vulnerability? Please do not open a public PR. Report it privately through GitHub Security Advisories: https://github.com/open-pencil/open-pencil/security/advisories/new +Before opening a PR, read `CONTRIBUTING.md` and `AGENTS.md`. PRs that ignore the template, use placeholder text, are not written in English, or do not explain validation may be closed as invalid. ---- +### Summary -**Checklist:** -- [ ] `bun run check` passes (lint + typecheck) -- [ ] Tests added or updated -- [ ] CHANGELOG.md updated (if user-facing) + + +### What changed + +- Add a concise summary here. + +### Validation + +- [ ] `bun run check` +- [ ] Tests added or updated, or not needed because: explain here +- [ ] CHANGELOG.md updated, or not needed because: explain here diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 000000000..b91139c82 --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,38 @@ +# OpenPencil Copilot instructions + +OpenPencil is a Bun workspace for a Vue 3 + CanvasKit design editor with Tauri desktop support. + +## Pull request requirements + +- Write PR titles and bodies in English. +- Follow `.github/PULL_REQUEST_TEMPLATE.md` exactly. +- Remove template comments and placeholders before opening a PR. +- Never leave dangling text like `Fixes #`, `TODO`, `TBD`, or unfinished checklist explanations. +- Summarize what changed, why it changed, and how it was validated. +- If a user-facing change is made, update `CHANGELOG.md`. +- Follow `CONTRIBUTING.md` and `AGENTS.md` for repository conventions. + +## Validation + +Use Bun, not npm or Node scripts unless the package explicitly requires Node. + +Before proposing changes, run targeted checks when possible and document them in the PR body. For broad changes, run: + +```sh +bun run check +``` + +Package publishing changes should also run: + +```sh +bun scripts/smoke-packages.ts +``` + +## Code conventions + +- No `any` unless there is a clear typed alternative problem and a justification. +- No non-null assertions; use guards. +- Use `crypto.getRandomValues()`, never `Math.random()`. +- Keep Vue components free of `