Просмотр исходного кода

chore: enforce PR template and tidy its sections (#5078)

* chore: enforce PR template and closing keywords for agents

Add AGENTS.md with pull request rules, a PR Body Check workflow that
fails when the template is dropped or the issue placeholder is left in,
and closing keyword guidance in the PR template.

* fix: only flag an unedited Fixes #[issue] placeholder line

* chore: drop AGENTS.md and tidy PR template sections

* chore: avoid a real issue reference in the checklist wording
Daniel Gibbs 2 дней назад
Родитель
Сommit
1c6eb98f47
2 измененных файлов с 55 добавлено и 13 удалено
  1. 11 13
      .github/pull_request_template.md
  2. 44 0
      .github/workflows/action-pr-body-check.yml

+ 11 - 13
.github/pull_request_template.md

@@ -1,20 +1,23 @@
 # Description
 
-Please include a summary of the change and which issues are fixed.
+<!-- Summarise the change and why it is needed. -->
 
 Fixes #[issue]
 
+Affected servers: <!-- shortnames, e.g. ck, rust, or "all" -->
+
 ## Type of change
 
 - [ ] Bug fix (a change which fixes an issue).
 - [ ] New feature (a change which adds functionality).
 - [ ] New Server (new server added).
 - [ ] Refactor (restructures existing code).
+- [ ] Chore (CI, workflows, tooling or other maintenance).
 - [ ] Comment update (typo, spelling, explanation, examples, etc).
 
 ## Testing
 
-Please list the exact validation you performed and the outcome.
+<!-- List the exact validation you performed and the outcome. -->
 
 - Commands/tests run:
 - Result:
@@ -30,28 +33,23 @@ Please list the exact validation you performed and the outcome.
 - [ ] No breaking changes.
 - [ ] Breaking changes included (describe below).
 
-## Documentation impact
+## Documentation
+
+<!-- If documentation needs updating, open a PR on the docs repo (preferred) or request an update. -->
 
 - [ ] No documentation update required.
-- [ ] User documentation update required.
-- [ ] Developer documentation update required.
+- [ ] User documentation update required ([LinuxGSM-Docs](https://github.com/GameServerManagers/LinuxGSM-Docs)).
+- [ ] Developer documentation update required ([LinuxGSM-Dev-Docs](https://github.com/GameServerManagers/LinuxGSM-Dev-Docs)).
 
 ## Checklist
 
 PR will not be merged until all steps are complete.
 
-- [ ] This pull request links to an issue.
+- [ ] This pull request links to an issue ("Fixes", or "Related to" for a partial fix).
 - [ ] This pull request uses the develop branch as its base.
 - [ ] This pull request subject follows the Conventional Commits standard.
 - [ ] This code follows the style guidelines of this project.
 - [ ] I have performed a self-review of my code.
 - [ ] I have provided a detailed enough description of this PR.
 
-## Documentation
-
-If documentation does need updating either update it by creating a PR (preferred) or request a documentation update.
-
-- User docs: <https://github.com/GameServerManagers/LinuxGSM-Docs>
-- Dev docs: <https://github.com/GameServerManagers/LinuxGSM-Dev-Docs>
-
 **Thank you for your Pull Request!**

+ 44 - 0
.github/workflows/action-pr-body-check.yml

@@ -0,0 +1,44 @@
+name: PR Body Check
+on:
+  pull_request:
+    types:
+      - opened
+      - edited
+      - reopened
+      - synchronize
+    branches:
+      - develop
+
+permissions:
+  contents: read
+
+jobs:
+  pr-body-check:
+    if: github.repository_owner == 'GameServerManagers' && github.event.pull_request.user.type != 'Bot'
+    runs-on: ubuntu-latest
+    steps:
+      - name: Check pull request body follows the template
+        uses: actions/github-script@v9
+        with:
+          script: |
+            const body = (context.payload.pull_request.body || '').replace(/<!--[\s\S]*?-->/g, '');
+            const requiredHeadings = ['# Description', '## Type of change', '## Testing', '## Checklist'];
+            const missing = requiredHeadings.filter((h) => !body.split(/\r?\n/).some((line) => line.trim() === h));
+            const errors = [];
+
+            if (missing.length > 0) {
+              errors.push(`Missing template sections: ${missing.join(', ')}. Use .github/pull_request_template.md as the pull request body.`);
+            }
+            if (/^\s*fixes #\[issue\]\s*$/im.test(body)) {
+              errors.push('Replace the "Fixes #[issue]" placeholder with the issue number, for example "Fixes #123".');
+            }
+
+            const closingKeyword = /\b(close[sd]?|fix(e[sd])?|resolve[sd]?):?\s+([\w.-]+\/[\w.-]+)?#\d+/i;
+            const relatedIssue = /\brelated to:?\s+([\w.-]+\/[\w.-]+)?#\d+/i;
+            if (!closingKeyword.test(body) && !relatedIssue.test(body)) {
+              core.warning('No closing keyword found. Add "Fixes #123" to link the issue, or "Related to #123" if this pull request does not fully resolve it.');
+            }
+
+            if (errors.length > 0) {
+              core.setFailed(errors.join('\n'));
+            }