You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

47 line
1.2 KiB

  1. import sys
  2. import requests
  3. from urllib.parse import urlparse
  4. def uri_validator(x):
  5. result = urlparse(x)
  6. return all([result.scheme, result.netloc, result.path])
  7. def docs_link_exists(body):
  8. for line in body.splitlines():
  9. for word in line.split():
  10. if word.startswith('http') and uri_validator(word):
  11. parsed_url = urlparse(word)
  12. if parsed_url.netloc == "github.com":
  13. parts = parsed_url.path.split('/')
  14. if len(parts) == 5 and parts[1] == "frappe" and parts[2] == "hrms":
  15. return True
  16. elif parsed_url.netloc == "frappehr.com":
  17. return True
  18. if __name__ == "__main__":
  19. pr = sys.argv[1]
  20. response = requests.get("https://api.github.com/repos/frappe/hrms/pulls/{}".format(pr))
  21. if response.ok:
  22. payload = response.json()
  23. title = (payload.get("title") or "").lower().strip()
  24. head_sha = (payload.get("head") or {}).get("sha")
  25. body = (payload.get("body") or "").lower()
  26. if (title.startswith("feat")
  27. and head_sha
  28. and "no-docs" not in body
  29. and "backport" not in body
  30. ):
  31. if docs_link_exists(body):
  32. print("Documentation Link Found. You're Awesome! 🎉")
  33. else:
  34. print("Documentation Link Not Found! ⚠️")
  35. sys.exit(1)
  36. else:
  37. print("Skipping documentation checks... 🏃")