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.
 
 
 
 
 
 

55 linhas
1.7 KiB

  1. # if the script ends with exit code 0, then no tests are run further, else all tests are run
  2. import os
  3. import re
  4. import shlex
  5. import subprocess
  6. import sys
  7. def get_output(command, shell=True):
  8. print(command)
  9. command = shlex.split(command)
  10. return subprocess.check_output(command, shell=shell, encoding="utf8").strip()
  11. def is_py(file):
  12. return file.endswith("py")
  13. def is_js(file):
  14. return file.endswith("js")
  15. def is_docs(file):
  16. regex = re.compile('\.(md|png|jpg|jpeg)$|^.github|LICENSE')
  17. return bool(regex.search(file))
  18. if __name__ == "__main__":
  19. build_type = os.environ.get("TYPE")
  20. commit_range = os.environ.get("TRAVIS_COMMIT_RANGE")
  21. print("Build Type: {}".format(build_type))
  22. print("Commit Range: {}".format(commit_range))
  23. try:
  24. files_changed = get_output("git diff --name-only {}".format(commit_range), shell=False)
  25. except Exception:
  26. sys.exit(2)
  27. if "fatal" not in files_changed:
  28. files_list = files_changed.split()
  29. only_docs_changed = len(list(filter(is_docs, files_list))) == len(files_list)
  30. only_js_changed = len(list(filter(is_js, files_list))) == len(files_list)
  31. only_py_changed = len(list(filter(is_py, files_list))) == len(files_list)
  32. if only_docs_changed:
  33. print("Only docs were updated, stopping build process.")
  34. sys.exit(0)
  35. if only_js_changed and build_type == "server":
  36. print("Only JavaScript code was updated; Stopping Python build process.")
  37. sys.exit(0)
  38. if only_py_changed and build_type == "ui":
  39. print("Only Python code was updated, stopping Cypress build process.")
  40. sys.exit(0)
  41. sys.exit(2)