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.

BuildDemos.py 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #coding=UTF-8
  2. # See BuildArchetypes for details on environment
  3. # BuildDemos needs git in PATH and depends on gitpython library
  4. # gitpython can be installed with python installer script "pip":
  5. # pip install gitpython
  6. #
  7. # Deployment dependency: requests
  8. # pip install requests
  9. # Deploy depends on .deployUrl and .deployCredentials files in home folder
  10. import sys, os, pickle
  11. from os.path import join, isfile
  12. from fnmatch import fnmatch
  13. from xml.etree.ElementTree import ElementTree
  14. # Validated demos. name -> git url
  15. demos = {
  16. "dashboard" : "https://github.com/vaadin/dashboard-demo.git",
  17. "addressbook" : "https://github.com/vaadin/addressbook.git",
  18. "framework8-demo" : "https://github.com/vaadin/framework8-demo",
  19. "sampler" : "demos/sampler"
  20. # "my-demo" : ("my_demo_url_or_path", "my-demo-dev-branch")
  21. }
  22. status_dump = {"messages": []}
  23. def dump_status(error_occurred):
  24. status_dump["error"] = error_occurred
  25. pickle.dump(status_dump, open("result/demo_validation_status.pickle", "wb"))
  26. def log_status(log_string):
  27. status_dump["messages"].append(log_string)
  28. print(log_string)
  29. def checkout(folder, url, repoBranch = "master"):
  30. Repo.clone_from(url, join(resultPath, folder), branch = repoBranch)
  31. if __name__ == "__main__":
  32. # Do imports.
  33. try:
  34. from git import Repo
  35. except:
  36. log_status("BuildDemos depends on gitpython. Install it with `pip install gitpython`")
  37. dump_status(True)
  38. sys.exit(1)
  39. from BuildHelpers import updateRepositories, mavenValidate, copyWarFiles, getLogFile, removeDir, getArgs, mavenInstall, resultPath, readPomFile, parser
  40. from DeployHelpers import deployWar
  41. # Add command line agrument for ignoring failing demos
  42. parser.add_argument("--ignore", type=str, help="Ignored demos", default="")
  43. args = getArgs()
  44. demosFailed = False
  45. ignoredDemos = args.ignore.split(",")
  46. wars = []
  47. for demo in demos:
  48. print("Validating demo %s" % (demo))
  49. try:
  50. repo = demos[demo]
  51. if (isinstance(repo, tuple)):
  52. checkout(demo, repo[0], repo[1])
  53. else:
  54. checkout(demo, repo)
  55. if hasattr(args, "fwRepo") and args.fwRepo is not None:
  56. updateRepositories(join(resultPath, demo), args.fwRepo)
  57. if hasattr(args, "pluginRepo") and args.pluginRepo is not None:
  58. updateRepositories(join(resultPath, demo), args.pluginRepo, postfix="plugin")
  59. mavenValidate(demo, logFile=getLogFile(demo))
  60. wars.extend(copyWarFiles(demo))
  61. log_status("%s demo validation succeeded!" % (demo))
  62. except Exception as e:
  63. log_status("%s demo validation failed: %s" % (demo, e))
  64. if demo not in ignoredDemos:
  65. demosFailed = True
  66. except EnvironmentError as e:
  67. log_status("%s demo validation failed: %s" % (demo, e))
  68. if demo not in ignoredDemos:
  69. demosFailed = True
  70. try:
  71. removeDir(demo)
  72. except:
  73. pass
  74. print("")
  75. for war in wars:
  76. try:
  77. deployWar(war)
  78. except Exception as e:
  79. log_status("War %s failed to deploy: %s" % (war, e))
  80. demosFailed = True
  81. if demosFailed:
  82. dump_status(True)
  83. sys.exit(1)
  84. dump_status(False)