mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-25 18:24:36 +00:00
c63bfb6d94
## What Adds a trusted-bot exception to the PR gate so Dependabot's PRs are no longer auto-closed. ## Why The PR gate (`scripts/pr-gate/`, run by `.github/workflows/pr-gate.yml`) auto-closes PRs that don't fit the contribution workflow. Dependabot PRs were getting closed because the bot: - has no repo permission, - links no `approved` issue, and - opens dependency bumps that often exceed the 50-line small-fix cap. ## How - `config.ts` — new `TRUSTED_BOT_AUTHORS` constant (currently `["dependabot[bot]"]`), so the allowlist is easy to extend. - `rules.ts` — new `checkTrustedBot()` rule, wired into `evaluate()` right after the maintainer bypass and before the repo-access check. - `tests/PrGateRules.test.ts` — unit tests for the rule plus an `evaluate()`-level test proving a 5000-line Dependabot PR now passes instead of closing. - `README.md` — documented the new rule in the gate-logic ordering. The match is exact, so a lookalike login (e.g. `not-dependabot[bot]`) won't slip through. Add more bots (Renovate, etc.) to `TRUSTED_BOT_AUTHORS` as needed. ## Testing `npx vitest tests/PrGateRules.test.ts --run` → 39 passed. Lint + prettier clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
47 lines
2.2 KiB
TypeScript
47 lines
2.2 KiB
TypeScript
export const REPO = { owner: "openfrontio", repo: "OpenFrontIO" } as const;
|
|
|
|
export const TRUSTED_REPO_PERMISSIONS = ["admin", "maintain", "write"] as const;
|
|
|
|
// Bot authors whose PRs are exempt from the gate (e.g. Dependabot dependency bumps).
|
|
export const TRUSTED_BOT_AUTHORS = ["dependabot[bot]"] as const;
|
|
|
|
export const SMALL_FIX_LINE_THRESHOLD = 50;
|
|
|
|
export const APPROVED_ISSUE_LABEL = "approved";
|
|
|
|
export const LABELS = {
|
|
BYPASS: "bypass-pr-check",
|
|
SMALL_FIX: "small-fix",
|
|
AUTO_CLOSED: "auto-closed-needs-issue",
|
|
} as const;
|
|
|
|
export const LABEL_COLORS: Record<string, string> = {
|
|
[LABELS.SMALL_FIX]: "0E8A16",
|
|
[LABELS.AUTO_CLOSED]: "B60205",
|
|
};
|
|
|
|
export const LABEL_DESCRIPTIONS: Record<string, string> = {
|
|
[LABELS.SMALL_FIX]: `Small fix (≤ ${SMALL_FIX_LINE_THRESHOLD} lines) — auto-applied by PR gate`,
|
|
[LABELS.AUTO_CLOSED]: "PR closed by gate — see comment for next steps",
|
|
};
|
|
|
|
export const CLOSE_COMMENT = (author: string): string =>
|
|
`Hi @${author}, thanks for the contribution.
|
|
|
|
This PR was automatically closed because it doesn't fit our contribution workflow:
|
|
|
|
- You aren't currently assigned to an issue labelled \`${APPROVED_ISSUE_LABEL}\`, **and**
|
|
- The change is larger than ${SMALL_FIX_LINE_THRESHOLD} lines (our cap for unsolicited contributions).
|
|
|
|
**To contribute to OpenFront:**
|
|
|
|
1. **For bugs or small quality-of-life improvements:** open an [issue](https://github.com/${REPO.owner}/${REPO.repo}/issues/new/choose). A maintainer will label it \`${APPROVED_ISSUE_LABEL}\` if it's something we'll work on.
|
|
2. **For feature ideas:** discuss in the [dev Discord](https://discord.gg/K9zernJB5z) first. We don't accept unsolicited feature PRs — even if they're good ideas, every merged feature is a permanent maintenance burden.
|
|
3. **Once an issue is labelled \`${APPROVED_ISSUE_LABEL}\`**, comment asking to be assigned. After you're assigned, you can open a PR referencing that issue.
|
|
|
|
If you believe this was closed in error, please reach out on our [Discord](https://discord.gg/K9zernJB5z) or comment below.
|
|
|
|
See [CONTRIBUTING.md](https://github.com/${REPO.owner}/${REPO.repo}/blob/main/CONTRIBUTING.md) for the full contribution process.
|
|
|
|
— *Automated PR gate. [Source](https://github.com/${REPO.owner}/${REPO.repo}/tree/main/scripts/pr-gate).*`;
|