From 0a8609da9424cea855753c02d39d61a25a87487a Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Wed, 9 Oct 2024 11:52:47 +0100 Subject: [PATCH] chore: add validation for PR description and checklist --- .github/scripts/validate_pr.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/scripts/validate_pr.py b/.github/scripts/validate_pr.py index 10959c7fe0..7bd22473fe 100644 --- a/.github/scripts/validate_pr.py +++ b/.github/scripts/validate_pr.py @@ -24,20 +24,20 @@ print("PR Body:", pr_body) # Check for 'Proposed changes' section -proposed_changes_match = re.search(r"### Proposed changes\s+(.+)", pr_body, re.DOTALL) +proposed_changes_match = re.search(r"### Proposed changes\s*(.+?)\s*(### Checklist|$)", pr_body, re.DOTALL) if proposed_changes_match: proposed_changes_text = proposed_changes_match.group(1).strip() + print(f"Extracted 'Proposed changes' text: {proposed_changes_text}") # Debugging line word_count = len(proposed_changes_text.split()) if word_count <= 10: print(f"Error: 'Proposed changes' section should have more than 10 words. Found {word_count} words.") sys.exit(1) else: - print("Error: 'Proposed changes' section is missing.") + print("Error: 'Proposed changes' section is missing or not detected correctly.") sys.exit(1) # Check if the first two checklist items are selected -# Use simpler patterns: "I have read" and "I have run" contrib_checked = re.search(r"- \[\s*[xX]\s*\] I have read", pr_body) install_checked = re.search(r"- \[\s*[xX]\s*\] I have run", pr_body)