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.

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