Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

51 linhas
1.3 KiB

  1. import sys
  2. from urllib.parse import urlparse
  3. import requests
  4. docs_repos = [
  5. "xhiveframework_docs",
  6. "xhiveerp_documentation",
  7. "xhiveerp_com",
  8. "xhiveframework_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] == "xhiveframework" and parts[2] in docs_repos:
  21. return True
  22. if parsed_url.netloc in ["docs.xhiveerp.co", "xhiveframework.co"]:
  23. return True
  24. if __name__ == "__main__":
  25. pr = sys.argv[1]
  26. response = requests.get(f"https://api.github.com/repos/xhiveframework/xhiveframework/pulls/{pr}")
  27. if response.ok:
  28. payload = response.json()
  29. title = (payload.get("title") or "").lower()
  30. head_sha = (payload.get("head") or {}).get("sha")
  31. body = (payload.get("body") or "").lower()
  32. if title.startswith("feat") and head_sha and "no-docs" not in body:
  33. if docs_link_exists(body):
  34. print("Documentation Link Found. You're Awesome! 🎉")
  35. else:
  36. print("Documentation Link Not Found! ⚠️")
  37. sys.exit(1)
  38. else:
  39. print("Skipping documentation checks... 🏃")