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.

189 lines
8.1 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 += " before_script:\n"
  87. buildConfig += ' - python -c "import fcntl; fcntl.fcntl(1, fcntl.F_SETFL, 0)" # Workaround for nonblocking mode\n'
  88. buildConfig += " script:\n"
  89. buildConfig += " - travis/build_carl.sh\n"
  90. # Upload to DockerHub
  91. buildConfig += " after_success:\n"
  92. buildConfig += ' - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD";\n'
  93. if "Debug" in build_type:
  94. buildConfig += " - docker commit carl movesrwth/carl:travis-debug;\n"
  95. buildConfig += " - docker push movesrwth/carl:travis-debug;\n"
  96. elif "Release" in build_type:
  97. buildConfig += " - docker commit carl movesrwth/carl:travis;\n"
  98. buildConfig += " - docker push movesrwth/carl:travis;\n"
  99. else:
  100. assert False
  101. s += buildConfig
  102. # Generate all configurations
  103. for stage in stages:
  104. s += "\n"
  105. s += " ###\n"
  106. s += " # Stage: {}\n".format(stage[0])
  107. s += " ###\n"
  108. s += "\n"
  109. # Mac OS X
  110. for config in configs_mac:
  111. osx = config[0]
  112. compiler = config[1]
  113. build_type = config[2]
  114. s += " # {} - {}\n".format(osx, build_type)
  115. buildConfig = ""
  116. buildConfig += " - stage: {}\n".format(stage[0])
  117. buildConfig += " os: osx\n"
  118. buildConfig += " osx_image: xcode9.1\n"
  119. buildConfig += " compiler: {}\n".format(compiler)
  120. buildConfig += " env: CONFIG={} COMPILER={} STL=libc++\n".format(build_type, compiler)
  121. buildConfig += " install:\n"
  122. if stage[1] == "Build1":
  123. buildConfig += " - rm -rf build\n"
  124. buildConfig += " - travis/install_osx.sh\n"
  125. buildConfig += " before_script:\n"
  126. buildConfig += ' - python -c "import fcntl; fcntl.fcntl(1, fcntl.F_SETFL, 0)" # Workaround for nonblocking mode\n'
  127. buildConfig += " script:\n"
  128. buildConfig += " - travis/build.sh {}\n".format(stage[1])
  129. buildConfig += " after_failure:\n"
  130. buildConfig += " - find build -iname '*err*.log' -type f -print -exec cat {} \;\n"
  131. s += buildConfig
  132. # Linux via Docker
  133. for config in configs_linux:
  134. allow_fail = ""
  135. linux = config[0]
  136. compiler = config[1]
  137. build_type = config[2]
  138. s += " # {} - {}\n".format(linux, build_type)
  139. buildConfig = ""
  140. buildConfig += " - stage: {}\n".format(stage[0])
  141. allow_fail += " - stage: {}\n".format(stage[0])
  142. buildConfig += " os: linux\n"
  143. allow_fail += " os: linux\n"
  144. buildConfig += " compiler: {}\n".format(compiler)
  145. buildConfig += " env: CONFIG={} LINUX={} COMPILER={}\n".format(build_type, linux, compiler)
  146. allow_fail += " env: CONFIG={} LINUX={} COMPILER={}\n".format(build_type, linux, compiler)
  147. buildConfig += " install:\n"
  148. if stage[1] == "Build1":
  149. buildConfig += " - rm -rf build\n"
  150. buildConfig += " - travis/install_linux.sh\n"
  151. buildConfig += " before_script:\n"
  152. buildConfig += ' - python -c "import fcntl; fcntl.fcntl(1, fcntl.F_SETFL, 0)" # Workaround for nonblocking mode\n'
  153. buildConfig += " script:\n"
  154. buildConfig += " - travis/build.sh {}\n".format(stage[1])
  155. buildConfig += " before_cache:\n"
  156. buildConfig += " - docker cp storm:/opt/storm/. .\n"
  157. buildConfig += " after_failure:\n"
  158. buildConfig += " - find build -iname '*err*.log' -type f -print -exec cat {} \;\n"
  159. # Upload to DockerHub
  160. if stage[1] == "TestAll" and "Travis" in build_type:
  161. buildConfig += " after_success:\n"
  162. buildConfig += ' - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD";\n'
  163. if "Debug" in build_type:
  164. buildConfig += " - docker commit storm movesrwth/storm:travis-debug;\n"
  165. buildConfig += " - docker push movesrwth/storm:travis-debug;\n"
  166. elif "Release" in build_type:
  167. buildConfig += " - docker commit storm movesrwth/storm:travis;\n"
  168. buildConfig += " - docker push movesrwth/storm:travis;\n"
  169. else:
  170. assert False
  171. s += buildConfig
  172. if "Travis" in build_type and "Release" in build_type:
  173. allow_failures.append(allow_fail)
  174. if len(allow_failures) > 0:
  175. s += " allow_failures:\n"
  176. for fail in allow_failures:
  177. s += fail
  178. print(s)