fix: check for nonexistent requirements section
Updated the PR script to handle cases where the application requirements are missing or unchecked more effectively. Added checks for the 'keep-open' label and improved messaging for maintainers.
This commit is contained in:
64
.github/workflows/unmet-pr-close.yml
generated
vendored
64
.github/workflows/unmet-pr-close.yml
generated
vendored
@@ -1,41 +1,40 @@
|
||||
name: PR Script Requirements Check
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [opened, edited, synchronize]
|
||||
|
||||
permissions:
|
||||
pull-requests: write
|
||||
contents: read
|
||||
issues: write
|
||||
|
||||
jobs:
|
||||
validate-script-requirements:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Validate new script requirements
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
// Skip entirely if the PR is flagged keep-open.
|
||||
const prLabels = (context.payload.pull_request.labels || []).map(l => l.name);
|
||||
if (prLabels.includes("keep-open")) {
|
||||
console.log("PR has keep-open label — skipping requirement check.");
|
||||
return;
|
||||
}
|
||||
|
||||
const body = context.payload.pull_request.body || "";
|
||||
const lines = body.split("\n");
|
||||
|
||||
function checkboxChecked(line) {
|
||||
return /\[\s*x\s*\]/i.test(line);
|
||||
}
|
||||
|
||||
function findLine(text) {
|
||||
return lines.find(l => l.includes(text));
|
||||
}
|
||||
|
||||
// detect if "New script" is checked
|
||||
const newScriptLine = findLine("🆕 **New script**");
|
||||
if (!newScriptLine || !checkboxChecked(newScriptLine)) {
|
||||
console.log("Not a new script PR — skipping requirement check.");
|
||||
return;
|
||||
}
|
||||
|
||||
const requirements = [
|
||||
"The application is **at least 6 months old**",
|
||||
"The application is **actively maintained**",
|
||||
@@ -44,22 +43,56 @@ jobs:
|
||||
"I understand that not all scripts will be accepted"
|
||||
];
|
||||
|
||||
const missing = [];
|
||||
|
||||
// Split the two cases: "line not present at all" vs "line present but unchecked".
|
||||
const absent = [];
|
||||
const unchecked = [];
|
||||
for (const req of requirements) {
|
||||
const line = findLine(req);
|
||||
if (!line || !checkboxChecked(line)) {
|
||||
missing.push(req);
|
||||
if (!line) {
|
||||
absent.push(req);
|
||||
} else if (!checkboxChecked(line)) {
|
||||
unchecked.push(req);
|
||||
}
|
||||
}
|
||||
|
||||
if (missing.length > 0) {
|
||||
// Case 1: zero requirement lines found in the body → wrong PR template was used.
|
||||
if (absent.length === requirements.length) {
|
||||
const message =
|
||||
"❌ **Pull Request Closed – Wrong PR Template**\n\n" +
|
||||
"This pull request is marked as **🆕 New script**, but the **📦 Application Requirements** section is missing from the PR description.\n\n" +
|
||||
"It looks like this PR was opened using the **main repo's** PR template instead of the ProxmoxVED template. " +
|
||||
"New script submissions require the additional **Application Requirements** checklist that is only present in the ProxmoxVED template.\n\n" +
|
||||
"### What to do\n" +
|
||||
"1. Open a **new PR** in this repository.\n" +
|
||||
"2. When the PR form loads, make sure the description contains the **📦 Application Requirements** section (with the 5 checkboxes for age, maintenance, stars, tarballs, and acceptance criteria). If it doesn't, clear the description and reload, or copy the template manually from " +
|
||||
"[`.github/pull_request_template.md`](https://github.com/community-scripts/ProxmoxVED/blob/main/.github/pull_request_template.md).\n" +
|
||||
"3. Fill out the checklist and confirm each requirement before submitting.\n\n" +
|
||||
"---\n\n" +
|
||||
"⚠ **Maintainer note**\n\n" +
|
||||
"**Please do not ping or repeatedly contact maintainers to reopen this PR.** Open a fresh PR with the correct template instead.";
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
body: message
|
||||
});
|
||||
await github.rest.pulls.update({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: context.issue.number,
|
||||
state: "closed"
|
||||
});
|
||||
core.setFailed("New script PR opened with the wrong template (Application Requirements section missing).");
|
||||
return;
|
||||
}
|
||||
|
||||
// Case 2: correct template, but some boxes unchecked (or a partial template edit).
|
||||
const missing = [...absent, ...unchecked];
|
||||
if (missing.length > 0) {
|
||||
let list = "";
|
||||
for (const m of missing) {
|
||||
list += "- " + m + "\n";
|
||||
}
|
||||
|
||||
const message =
|
||||
"❌ **Pull Request Closed – Application Requirements Not Met**\n\n" +
|
||||
"This pull request is marked as **🆕 New script**, but the required application criteria were not confirmed.\n\n" +
|
||||
@@ -71,20 +104,17 @@ jobs:
|
||||
"⚠ **Maintainer note**\n\n" +
|
||||
"The team periodically reviews closed submissions. If a project is still considered valuable to the ecosystem, maintainers may reopen the PR even if it does not fully meet the thresholds.\n\n" +
|
||||
"**Please do not ping or repeatedly contact maintainers to reopen PRs.**";
|
||||
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
body: message
|
||||
});
|
||||
|
||||
await github.rest.pulls.update({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: context.issue.number,
|
||||
state: "closed"
|
||||
});
|
||||
|
||||
core.setFailed("Application requirements checklist incomplete.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user