|
|
@@ -1,5 +1,6 @@ |
|
|
|
import os |
|
|
|
import re |
|
|
|
import requests |
|
|
|
import shlex |
|
|
|
import subprocess |
|
|
|
import sys |
|
|
@@ -14,19 +15,24 @@ def is_py(file): |
|
|
|
return file.endswith("py") |
|
|
|
|
|
|
|
def is_ci(file): |
|
|
|
return file.endswith("yml") or ".github" in file |
|
|
|
return ".github" in file |
|
|
|
|
|
|
|
def is_js(file): |
|
|
|
return file.endswith("js") |
|
|
|
def is_frontend_code(file): |
|
|
|
return file.endswith((".css", ".scss", ".less", ".sass", ".styl", ".js", ".ts")) |
|
|
|
|
|
|
|
def is_docs(file): |
|
|
|
regex = re.compile(r'\.(md|png|jpg|jpeg)$|^.github|LICENSE') |
|
|
|
regex = re.compile(r'\.(md|png|jpg|jpeg|csv)$|^.github|LICENSE') |
|
|
|
return bool(regex.search(file)) |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
files_list = sys.argv[1:] |
|
|
|
build_type = os.environ.get("TYPE") |
|
|
|
pr_number = os.environ.get("PR_NUMBER") |
|
|
|
|
|
|
|
if not files_list and pr_number: |
|
|
|
res = requests.get(f"https://api.github.com/repos/frappe/frappe/pulls/{pr_number}/files") |
|
|
|
files_list = [f["filename"] for f in res.json()] |
|
|
|
|
|
|
|
if not files_list: |
|
|
|
print("No files' changes detected. Build is shutting") |
|
|
@@ -34,7 +40,7 @@ if __name__ == "__main__": |
|
|
|
|
|
|
|
ci_files_changed = any(f for f in files_list if is_ci(f)) |
|
|
|
only_docs_changed = len(list(filter(is_docs, files_list))) == len(files_list) |
|
|
|
only_js_changed = len(list(filter(is_js, files_list))) == len(files_list) |
|
|
|
only_frontend_code_changed = len(list(filter(is_frontend_code, files_list))) == len(files_list) |
|
|
|
only_py_changed = len(list(filter(is_py, files_list))) == len(files_list) |
|
|
|
|
|
|
|
if ci_files_changed: |
|
|
@@ -44,8 +50,8 @@ if __name__ == "__main__": |
|
|
|
print("Only docs were updated, stopping build process.") |
|
|
|
sys.exit(0) |
|
|
|
|
|
|
|
if only_js_changed and build_type == "server": |
|
|
|
print("Only JavaScript code was updated; Stopping Python build process.") |
|
|
|
if only_frontend_code_changed and build_type == "server": |
|
|
|
print("Only Frontend code was updated; Stopping Python build process.") |
|
|
|
sys.exit(0) |
|
|
|
|
|
|
|
if only_py_changed and build_type == "ui": |
|
|
|