Skip to content

Commit

Permalink
chore: add validation for PR description and checklist
Browse files Browse the repository at this point in the history
  • Loading branch information
oCHRISo committed Oct 9, 2024
1 parent 154e011 commit 0a8609d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .github/scripts/validate_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 0a8609d

Please sign in to comment.