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.

183 lines
7.5 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-18.04", "gcc", "DefaultDebugTravis"),
  8. ("ubuntu-18.04", "gcc", "DefaultReleaseTravis"),
  9. ("ubuntu-18.04", "gcc", "DefaultDebug"),
  10. ("ubuntu-18.04", "gcc", "DefaultRelease"),
  11. ]
  12. # Configurations for Mac
  13. configs_mac = [
  14. # OS, compiler, build type
  15. # ("osx", "clang", "DefaultDebug"),
  16. # ("osx", "clang", "DefaultRelease"),
  17. ]
  18. # Stages in travis
  19. stages = [
  20. ("Build (1st run)", "Build1"),
  21. ("Build (2nd run)", "Build2"),
  22. ("Build (3rd run)", "Build3"),
  23. ("Build (4th run)", "BuildLast"),
  24. ("Test all", "TestAll"),
  25. ]
  26. if __name__ == "__main__":
  27. allow_failures = []
  28. s = ""
  29. # Initial config
  30. s += "#\n"
  31. s += "# General config\n"
  32. s += "#\n"
  33. s += "branches:\n"
  34. s += " only:\n"
  35. s += " - master\n"
  36. s += " - stable\n"
  37. s += "sudo: required\n"
  38. s += "dist: trusty\n"
  39. s += "language: cpp\n"
  40. s += "\n"
  41. s += "git:\n"
  42. s += " depth: false\n"
  43. s += "\n"
  44. s += "# Enable caching\n"
  45. s += "cache:\n"
  46. s += " timeout: 1000\n"
  47. s += " directories:\n"
  48. s += " - build\n"
  49. s += " - travis/mtime_cache\n"
  50. s += "\n"
  51. s += "# Enable docker support\n"
  52. s += "services:\n"
  53. s += "- docker\n"
  54. s += "\n"
  55. s += "notifications:\n"
  56. s += " email:\n"
  57. s += " on_failure: always\n"
  58. s += " on_success: change\n"
  59. s += " recipients:\n"
  60. s += ' - secure: "VWnsiQkt1xjgRo1hfNiNQqvLSr0fshFmLV7jJlUixhCr094mgD0U2bNKdUfebm28Byg9UyDYPbOFDC0sx7KydKiL1q7FKKXkyZH0k04wUu8XiNw+fYkDpmPnQs7G2n8oJ/GFJnr1Wp/1KI3qX5LX3xot4cJfx1I5iFC2O+p+ng6v/oSX+pewlMv4i7KL16ftHHHMo80N694v3g4B2NByn4GU2/bjVQcqlBp/TiVaUa5Nqu9DxZi/n9CJqGEaRHOblWyMO3EyTZsn45BNSWeQ3DtnMwZ73rlIr9CaEgCeuArc6RGghUAVqRI5ao+N5apekIaILwTgL6AJn+Lw/+NRPa8xclgd0rKqUQJMJCDZKjKz2lmIs3bxfELOizxJ3FJQ5R95FAxeAZ6rb/j40YqVVTw2IMBDnEE0J5ZmpUYNUtPti/Adf6GD9Fb2y8sLo0XDJzkI8OxYhfgjSy5KYmRj8O5MXcP2MAE8LQauNO3MaFnL9VMVOTZePJrPozQUgM021uyahf960+QNI06Uqlmg+PwWkSdllQlxHHplOgW7zClFhtSUpnJxcsUBzgg4kVg80gXUwAQkaDi7A9Wh2bs+TvMlmHzBwg+2SaAfWDgjeJIeOaipDkF1uSGzC+EHAiiKYMLd4Aahoi8SuelJUucoyJyLAq00WdUFQIh/izVhM4Y="\n'
  61. s += "\n"
  62. s += "#\n"
  63. s += "# Configurations\n"
  64. s += "#\n"
  65. s += "jobs:\n"
  66. s += " include:\n"
  67. # Start with prebuilding carl for docker
  68. s += "\n"
  69. s += " ###\n"
  70. s += " # Stage: Build Carl\n"
  71. s += " ###\n"
  72. s += "\n"
  73. for config in configs_linux:
  74. linux = config[0]
  75. compiler = config[1]
  76. build_type = config[2]
  77. if "Travis" in build_type:
  78. s += " # {} - {}\n".format(linux, build_type)
  79. buildConfig = ""
  80. buildConfig += " - stage: Build Carl\n"
  81. buildConfig += " os: linux\n"
  82. buildConfig += " compiler: {}\n".format(compiler)
  83. buildConfig += " env: CONFIG={} LINUX={} COMPILER={}\n".format(build_type, linux, compiler)
  84. buildConfig += " install:\n"
  85. buildConfig += " - travis/install_linux.sh\n"
  86. buildConfig += " script:\n"
  87. buildConfig += " - travis/build_carl.sh\n"
  88. # Upload to DockerHub
  89. buildConfig += " after_success:\n"
  90. buildConfig += ' - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD";\n'
  91. if "Debug" in build_type:
  92. buildConfig += " - docker commit carl movesrwth/carl:travis-debug;\n"
  93. buildConfig += " - docker push movesrwth/carl:travis-debug;\n"
  94. elif "Release" in build_type:
  95. buildConfig += " - docker commit carl movesrwth/carl:travis;\n"
  96. buildConfig += " - docker push movesrwth/carl:travis;\n"
  97. else:
  98. assert False
  99. s += buildConfig
  100. # Generate all configurations
  101. for stage in stages:
  102. s += "\n"
  103. s += " ###\n"
  104. s += " # Stage: {}\n".format(stage[0])
  105. s += " ###\n"
  106. s += "\n"
  107. # Mac OS X
  108. for config in configs_mac:
  109. osx = config[0]
  110. compiler = config[1]
  111. build_type = config[2]
  112. s += " # {} - {}\n".format(osx, build_type)
  113. buildConfig = ""
  114. buildConfig += " - stage: {}\n".format(stage[0])
  115. buildConfig += " os: osx\n"
  116. buildConfig += " osx_image: xcode9.1\n"
  117. buildConfig += " compiler: {}\n".format(compiler)
  118. buildConfig += " env: CONFIG={} COMPILER={} STL=libc++\n".format(build_type, compiler)
  119. buildConfig += " install:\n"
  120. if stage[1] == "Build1":
  121. buildConfig += " - rm -rf build\n"
  122. buildConfig += " - travis/install_osx.sh\n"
  123. buildConfig += " script:\n"
  124. buildConfig += " - travis/build.sh {}\n".format(stage[1])
  125. buildConfig += " after_failure:\n"
  126. buildConfig += " - find build -iname '*err*.log' -type f -print -exec cat {} \;\n"
  127. s += buildConfig
  128. # Linux via Docker
  129. for config in configs_linux:
  130. allow_fail = ""
  131. linux = config[0]
  132. compiler = config[1]
  133. build_type = config[2]
  134. s += " # {} - {}\n".format(linux, build_type)
  135. buildConfig = ""
  136. buildConfig += " - stage: {}\n".format(stage[0])
  137. allow_fail += " - stage: {}\n".format(stage[0])
  138. buildConfig += " os: linux\n"
  139. allow_fail += " os: linux\n"
  140. buildConfig += " compiler: {}\n".format(compiler)
  141. buildConfig += " env: CONFIG={} LINUX={} COMPILER={}\n".format(build_type, linux, compiler)
  142. allow_fail += " env: CONFIG={} LINUX={} COMPILER={}\n".format(build_type, linux, compiler)
  143. buildConfig += " install:\n"
  144. if stage[1] == "Build1":
  145. buildConfig += " - rm -rf build\n"
  146. buildConfig += " - travis/install_linux.sh\n"
  147. buildConfig += " script:\n"
  148. buildConfig += " - travis/build.sh {}\n".format(stage[1])
  149. buildConfig += " before_cache:\n"
  150. buildConfig += " - docker cp storm:/opt/storm/. .\n"
  151. buildConfig += " after_failure:\n"
  152. buildConfig += " - find build -iname '*err*.log' -type f -print -exec cat {} \;\n"
  153. # Upload to DockerHub
  154. if stage[1] == "TestAll" and "Travis" in build_type:
  155. buildConfig += " after_success:\n"
  156. buildConfig += ' - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD";\n'
  157. if "Debug" in build_type:
  158. buildConfig += " - docker commit storm movesrwth/storm:travis-debug;\n"
  159. buildConfig += " - docker push movesrwth/storm:travis-debug;\n"
  160. elif "Release" in build_type:
  161. buildConfig += " - docker commit storm movesrwth/storm:travis;\n"
  162. buildConfig += " - docker push movesrwth/storm:travis;\n"
  163. else:
  164. assert False
  165. s += buildConfig
  166. if "Travis" in build_type and "Release" in build_type:
  167. allow_failures.append(allow_fail)
  168. if len(allow_failures) > 0:
  169. s += " allow_failures:\n"
  170. for fail in allow_failures:
  171. s += fail
  172. print(s)