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.

166 lines
6.8 KiB

  1. # Generate .travis.yml automatically
  2. # Configuration for Linux
  3. configs_linux = [
  4. # OS, compiler, build type
  5. ("debian-9", "gcc", "DefaultDebug"),
  6. ("debian-9", "gcc", "DefaultRelease"),
  7. ("ubuntu-17.10", "gcc", "DefaultDebugTravis"),
  8. ("ubuntu-17.10", "gcc", "DefaultReleaseTravis"),
  9. ]
  10. # Configurations for Mac
  11. configs_mac = [
  12. # OS, compiler, build type
  13. # ("osx", "clang", "DefaultDebug"),
  14. # ("osx", "clang", "DefaultRelease"),
  15. ]
  16. # Stages in travis
  17. stages = [
  18. ("Build (1st run)", "Build1"),
  19. ("Build (2nd run)", "Build2"),
  20. ("Build (3rd run)", "Build3"),
  21. ("Build (4th run)", "BuildLast"),
  22. ("Test all", "TestAll"),
  23. ]
  24. if __name__ == "__main__":
  25. s = ""
  26. # Initial config
  27. s += "#\n"
  28. s += "# General config\n"
  29. s += "#\n"
  30. s += "branches:\n"
  31. s += " only:\n"
  32. s += " - master\n"
  33. s += " - stable\n"
  34. s += "sudo: required\n"
  35. s += "dist: trusty\n"
  36. s += "language: cpp\n"
  37. s += "\n"
  38. s += "# Enable caching\n"
  39. s += "cache:\n"
  40. s += " timeout: 1000\n"
  41. s += " directories:\n"
  42. s += " - build\n"
  43. s += " - travis/mtime_cache\n"
  44. s += "\n"
  45. s += "# Enable docker support\n"
  46. s += "services:\n"
  47. s += "- docker\n"
  48. s += "\n"
  49. s += "notifications:\n"
  50. s += " email:\n"
  51. s += " on_failure: always\n"
  52. s += " on_success: change\n"
  53. s += " recipients:\n"
  54. s += ' secure: "Q9CW/PtyWkZwExDrfFFb9n1STGYsRfI6awv1bZHcGwfrDvhpXoMCuF8CwviIfilm7fFJJEoKizTtdRpY0HrOnY/8KY111xrtcFYosxdndv7xbESodIxQOUoIEFCO0mCNHwWYisoi3dAA7H3Yn661EsxluwHjzX5vY0xSbw0n229hlsFz092HwGLSU33zHl7eXpQk+BOFmBTRGlOq9obtDZ17zbHz1oXFZntHK/JDUIYP0b0uq8NvE2jM6CIVdcuSwmIkOhZJoO2L3Py3rBbPci+L2PSK4Smv2UjCPF8KusnOaFIyDB3LcNM9Jqq5ssJMrK/KaO6BiuYrOZXYWZ7KEg3Y/naC8HjOH1dzty+P7oW46sb9F03pTsufqD4R7wcK+9wROTztO6aJPDG/IPH7EWgrBTxqlOkVRwi2eYuQouZpZUW6EMClKbMHMIxCH2S8aOk/r1w2cNwmPEcunnP0nl413x/ByHr4fTPFykPj8pQxIsllYjpdWBRQfDOauKWGzk6LcrFW0qpWP+/aJ2vYu/IoZQMG5lMHbp6Y1Lg09pYm7Q983v3b7D+JvXhOXMyGq91HyPahA2wwKoG1GA4uoZ2I95/IFYNiKkelDd3WTBoFLNF9YFoEJNdCywm1fO2WY4WkyEFBuQcgDA+YpFMJJMxjTbivYk9jvHk2gji//2w="\n'
  55. s += "\n"
  56. s += "#\n"
  57. s += "# Configurations\n"
  58. s += "#\n"
  59. s += "jobs:\n"
  60. s += " include:\n"
  61. # Start with prebuilding carl for docker
  62. s += "\n"
  63. s += " ###\n"
  64. s += " # Stage: Build Carl\n"
  65. s += " ###\n"
  66. s += "\n"
  67. for config in configs_linux:
  68. linux = config[0]
  69. compiler = config[1]
  70. build_type = config[2]
  71. if "Travis" in build_type:
  72. s += " # {} - {}\n".format(linux, build_type)
  73. buildConfig = ""
  74. buildConfig += " - stage: Build Carl\n"
  75. buildConfig += " os: linux\n"
  76. buildConfig += " compiler: {}\n".format(compiler)
  77. buildConfig += " env: CONFIG={} LINUX={} COMPILER={}\n".format(build_type, linux, compiler)
  78. buildConfig += " install:\n"
  79. buildConfig += " - travis/install_linux.sh\n"
  80. buildConfig += " script:\n"
  81. buildConfig += " - travis/build_carl.sh\n"
  82. # Upload to DockerHub
  83. buildConfig += " after_success:\n"
  84. buildConfig += ' - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD";\n'
  85. if "Debug" in build_type:
  86. buildConfig += " - docker commit carl mvolk/carl:travis-debug;\n"
  87. buildConfig += " - docker push mvolk/carl:travis-debug;\n"
  88. elif "Release" in build_type:
  89. buildConfig += " - docker commit carl mvolk/carl:travis;\n"
  90. buildConfig += " - docker push mvolk/carl:travis;\n"
  91. else:
  92. assert False
  93. s += buildConfig
  94. # Generate all configurations
  95. for stage in stages:
  96. s += "\n"
  97. s += " ###\n"
  98. s += " # Stage: {}\n".format(stage[0])
  99. s += " ###\n"
  100. s += "\n"
  101. # Mac OS X
  102. for config in configs_mac:
  103. osx = config[0]
  104. compiler = config[1]
  105. build_type = config[2]
  106. s += " # {} - {}\n".format(osx, build_type)
  107. buildConfig = ""
  108. buildConfig += " - stage: {}\n".format(stage[0])
  109. buildConfig += " os: osx\n"
  110. buildConfig += " osx_image: xcode9.1\n"
  111. buildConfig += " compiler: {}\n".format(compiler)
  112. buildConfig += " env: CONFIG={} COMPILER={} STL=libc++\n".format(build_type, compiler)
  113. buildConfig += " install:\n"
  114. if stage[1] == "Build1":
  115. buildConfig += " - rm -rf build\n"
  116. buildConfig += " - travis/install_osx.sh\n"
  117. buildConfig += " script:\n"
  118. buildConfig += " - travis/build.sh {}\n".format(stage[1])
  119. buildConfig += " after_failure:\n"
  120. buildConfig += " - find build -iname '*err*.log' -type f -print -exec cat {} \;\n"
  121. s += buildConfig
  122. # Linux via Docker
  123. for config in configs_linux:
  124. linux = config[0]
  125. compiler = config[1]
  126. build_type = config[2]
  127. s += " # {} - {}\n".format(linux, build_type)
  128. buildConfig = ""
  129. buildConfig += " - stage: {}\n".format(stage[0])
  130. buildConfig += " os: linux\n"
  131. buildConfig += " compiler: {}\n".format(compiler)
  132. buildConfig += " env: CONFIG={} LINUX={} COMPILER={}\n".format(build_type, linux, compiler)
  133. buildConfig += " install:\n"
  134. if stage[1] == "Build1":
  135. buildConfig += " - rm -rf build\n"
  136. buildConfig += " - travis/install_linux.sh\n"
  137. buildConfig += " script:\n"
  138. buildConfig += " - travis/build.sh {}\n".format(stage[1])
  139. buildConfig += " before_cache:\n"
  140. buildConfig += " - docker cp storm:/opt/storm/. .\n"
  141. buildConfig += " after_failure:\n"
  142. buildConfig += " - find build -iname '*err*.log' -type f -print -exec cat {} \;\n"
  143. # Upload to DockerHub
  144. if stage[1] == "TestAll" and "Travis" in build_type:
  145. buildConfig += " after_success:\n"
  146. buildConfig += ' - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD";\n'
  147. if "Debug" in build_type:
  148. buildConfig += " - docker commit storm mvolk/storm:travis-debug;\n"
  149. buildConfig += " - docker push mvolk/storm:travis-debug;\n"
  150. elif "Release" in build_type:
  151. buildConfig += " - docker commit storm mvolk/storm:travis;\n"
  152. buildConfig += " - docker push mvolk/storm:travis;\n"
  153. else:
  154. assert False
  155. s += buildConfig
  156. print(s)