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.

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