Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

55 righe
1.3 KiB

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