Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

BuildDemos.py 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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","7.7"),
  17. "parking" : ("https://github.com/vaadin/parking-demo.git", "7.7"),
  18. "addressbook" : ("https://github.com/vaadin/addressbook.git", "7.7"),
  19. "grid-gwt" : ("https://github.com/vaadin/grid-gwt.git", "7.7"),
  20. "sampler" : ("demos/sampler", "7.7")
  21. # "my-demo" : ("my_demo_url_or_path", "my-demo-dev-branch")
  22. }
  23. status_dump = {"messages": []}
  24. def dump_status(error_occurred):
  25. status_dump["error"] = error_occurred
  26. pickle.dump(status_dump, open("result/demo_validation_status.pickle", "wb"))
  27. def log_status(log_string):
  28. status_dump["messages"].append(log_string)
  29. print(log_string)
  30. def checkout(folder, url, repoBranch = "master"):
  31. Repo.clone_from(url, join(resultPath, folder), branch = repoBranch)
  32. if __name__ == "__main__":
  33. # Do imports.
  34. try:
  35. from git import Repo
  36. except:
  37. log_status("BuildDemos depends on gitpython. Install it with `pip install gitpython`")
  38. dump_status(True)
  39. sys.exit(1)
  40. from BuildHelpers import updateRepositories, mavenValidate, copyWarFiles, getLogFile, removeDir, getArgs, mavenInstall, resultPath, readPomFile, parser
  41. from DeployHelpers import deployWar
  42. # Add command line agrument for ignoring failing demos
  43. parser.add_argument("--ignore", type=str, help="Ignored demos", default="")
  44. args = getArgs()
  45. demosFailed = False
  46. ignoredDemos = args.ignore.split(",")
  47. wars = []
  48. for demo in demos:
  49. print("Validating demo %s" % (demo))
  50. try:
  51. repo = demos[demo]
  52. if (isinstance(repo, tuple)):
  53. checkout(demo, repo[0], repo[1])
  54. else:
  55. checkout(demo, repo)
  56. if hasattr(args, "fwRepo") and args.fwRepo is not None:
  57. updateRepositories(join(resultPath, demo), args.fwRepo)
  58. if hasattr(args, "pluginRepo") and args.pluginRepo is not None:
  59. updateRepositories(join(resultPath, demo), args.pluginRepo, postfix="plugin")
  60. mavenValidate(demo, logFile=getLogFile(demo))
  61. wars.extend(copyWarFiles(demo))
  62. log_status("%s demo validation succeeded!" % (demo))
  63. except Exception as e:
  64. log_status("%s demo validation failed: %s" % (demo, e))
  65. if demo not in ignoredDemos:
  66. demosFailed = True
  67. except EnvironmentError as e:
  68. log_status("%s demo validation failed: %s" % (demo, e))
  69. if demo not in ignoredDemos:
  70. demosFailed = True
  71. try:
  72. removeDir(demo)
  73. except:
  74. pass
  75. print("")
  76. for war in wars:
  77. try:
  78. deployWar(war)
  79. except Exception as e:
  80. log_status("War %s failed to deploy: %s" % (war, e))
  81. demosFailed = True
  82. if demosFailed:
  83. dump_status(True)
  84. sys.exit(1)
  85. dump_status(False)