From b62e2ca158272c6a12b8e4904a51a232f97ede07 Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Mon, 7 Sep 2026 09:27:44 -0700 Subject: [PATCH] Enforce GitHub issue template compliance Issues that don't follow the issue template are automatically labeled with `needs-template` and receive a bot comment explaining what sections are missing. The label is removed when the issue is edited to become compliant. Includes the workflow, decision logic, compliance checker, and comprehensive tests verifying sync with the actual template definitions. --- .github/scripts/issue-template-compliance.mjs | 163 ++++++++++ .../workflows/issue-template-compliance.yml | 63 ++++ .../issue-template-compliance.test.mjs | 302 ++++++++++++++++++ 3 files changed, 528 insertions(+) create mode 100644 .github/scripts/issue-template-compliance.mjs create mode 100644 .github/workflows/issue-template-compliance.yml create mode 100644 config/scripts/issue-template-compliance.test.mjs diff --git a/.github/scripts/issue-template-compliance.mjs b/.github/scripts/issue-template-compliance.mjs new file mode 100644 index 00000000000..84719e3978a --- /dev/null +++ b/.github/scripts/issue-template-compliance.mjs @@ -0,0 +1,163 @@ +import { appendFileSync, readFileSync } from 'node:fs' +import { pathToFileURL } from 'node:url' + +// Why hardcoded: the runner has no YAML parser without a pnpm install. The +// vitest drift guard fails whenever these diverge from .github/ISSUE_TEMPLATE. +export const ISSUE_TEMPLATES = [ + { file: 'bug_report.yml', name: 'Bug report', requiredFields: ['Operating system', 'Details'] }, + { + file: 'feature_request.yml', + name: 'Feature request', + requiredFields: ['Problem or use case', 'Proposed solution'] + }, + { file: 'other.yml', name: 'Other', requiredFields: ['Details'] } +] + +export const COMPLIANCE_LABEL = 'needs-template' +export const COMMENT_MARKER = '' +// Why: GitHub renders a skipped optional form field as this literal. +const EMPTY_FIELD_VALUE = '_No response_' + +// Issue forms render each field as `###