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.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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
  11. try:
  12. from git import Repo
  13. except:
  14. print("BuildDemos depends on gitpython. Install it with `pip install gitpython`")
  15. sys.exit(1)
  16. from BuildHelpers import updateRepositories, mavenValidate, copyWarFiles, getLogFile, removeDir, getArgs, mavenInstall
  17. from DeployHelpers import deployWar
  18. from os.path import join, isfile
  19. from fnmatch import fnmatch
  20. # Validated demos. name -> git url
  21. demos = {
  22. "dashboard" : "https://github.com/vaadin/dashboard-demo.git",
  23. "parking" : "https://github.com/vaadin/parking-demo.git",
  24. "addressbook" : "https://github.com/vaadin/addressbook.git",
  25. "grid-gwt" : "https://github.com/vaadin/grid-gwt.git"
  26. }
  27. def checkout(folder, url):
  28. Repo.clone_from(url, folder)
  29. if __name__ == "__main__":
  30. if hasattr(getArgs(), "artifactPath") and getArgs().artifactPath is not None:
  31. basePath = getArgs().artifactPath
  32. poms = []
  33. for root, dirs, files in os.walk(basePath):
  34. for name in files:
  35. if fnmatch(name, "*.pom"):
  36. poms.append(join(root, name))
  37. for pom in poms:
  38. jarFile = pom.replace(".pom", ".jar")
  39. if isfile(jarFile):
  40. mavenInstall(pom, jarFile)
  41. else:
  42. mavenInstall(pom)
  43. demosFailed = False
  44. for demo in demos:
  45. print("Validating demo %s" % (demo))
  46. try:
  47. checkout(demo, demos[demo])
  48. updateRepositories(demo)
  49. mavenValidate(demo, logFile=getLogFile(demo))
  50. resultWars = copyWarFiles(demo)
  51. for war in resultWars:
  52. try:
  53. deployWar(war)
  54. except Exception as e:
  55. print("War %s failed to deploy: %s" % (war, e))
  56. demosFailed = True
  57. print("%s demo validation succeeded!" % (demo))
  58. except Exception as e:
  59. print("%s demo validation failed: %s" % (demo, e))
  60. demosFailed = True
  61. removeDir(demo)
  62. print("")
  63. if demosFailed:
  64. sys.exit(1)