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.

156 lines
7.0 KiB

  1. # Generate .travis.yml automatically
  2. # Configuration for Linux
  3. configs = [
  4. # OS, OS version, compiler, build type, task
  5. ("ubuntu", "18.04", "gcc", "DefaultDebug", "Test"),
  6. ("ubuntu", "18.04", "gcc", "DefaultRelease", "Test"),
  7. ("debian", "9", "gcc", "DefaultDebug", "Test"),
  8. ("debian", "9", "gcc", "DefaultRelease", "Test"),
  9. ("debian", "10", "gcc", "DefaultDebug", "Test"),
  10. ("debian", "10", "gcc", "DefaultRelease", "Test"),
  11. ("ubuntu", "19.10", "gcc", "DefaultDebugTravis", "TestDocker"),
  12. ("ubuntu", "19.10", "gcc", "DefaultReleaseTravis", "TestDockerDoxygen"),
  13. # ("osx", "xcode9.3", "clang", "DefaultDebug", "Test"),
  14. # ("osx", "xcode9.3", "clang", "DefaultRelease", "Test"),
  15. ]
  16. # Stages in travis
  17. build_stages = [
  18. ("Build (1st run)", "Build1"),
  19. ("Build (2nd run)", "Build2"),
  20. ("Build (3rd run)", "Build3"),
  21. ("Build (4th run)", "BuildLast"),
  22. ("Tasks", "Tasks"),
  23. ]
  24. def get_env_string(os, os_version, compiler, build_type, task):
  25. if os == "osx":
  26. return "CONFIG={} TASK={} COMPILER={} STL=libc++\n".format(build_type, task, compiler)
  27. else:
  28. return "CONFIG={} TASK={} LINUX={} COMPILER={}\n".format(build_type, task, "{}-{}".format(os, os_version), compiler)
  29. if __name__ == "__main__":
  30. s = ""
  31. # Initial config
  32. s += "#\n"
  33. s += "# General config\n"
  34. s += "#\n"
  35. s += "branches:\n"
  36. s += " only:\n"
  37. s += " - master\n"
  38. s += " - stable\n"
  39. s += "sudo: required\n"
  40. s += "language: cpp\n"
  41. s += "\n"
  42. s += "git:\n"
  43. s += " depth: false\n"
  44. s += "\n"
  45. s += "# Enable caching\n"
  46. s += "cache:\n"
  47. s += " timeout: 1000\n"
  48. s += " directories:\n"
  49. s += " - build\n"
  50. s += " - travis/mtime_cache\n"
  51. s += "\n"
  52. s += "# Enable docker support\n"
  53. s += "services:\n"
  54. s += "- docker\n"
  55. s += "\n"
  56. s += "notifications:\n"
  57. s += " email:\n"
  58. s += " on_failure: always\n"
  59. s += " on_success: change\n"
  60. s += " recipients:\n"
  61. 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'
  62. s += "\n"
  63. s += "#\n"
  64. s += "# Configurations\n"
  65. s += "#\n"
  66. s += "jobs:\n"
  67. s += " include:\n"
  68. # Start with prebuilding carl for docker
  69. s += "\n"
  70. s += " ###\n"
  71. s += " # Stage: Build Carl\n"
  72. s += " ###\n"
  73. for config in configs:
  74. os, os_version, compiler, build_type, task = config
  75. os_type = "osx" if os == "osx" else "linux"
  76. if "Travis" in build_type:
  77. s += " # {}-{} - {}\n".format(os, os_version, build_type)
  78. buildConfig = ""
  79. buildConfig += " - stage: Build Carl\n"
  80. buildConfig += " os: {}\n".format(os_type)
  81. buildConfig += " compiler: {}\n".format(compiler)
  82. buildConfig += " env: {}".format(get_env_string(os, os_version, compiler, build_type, task))
  83. buildConfig += " before_script:\n"
  84. buildConfig += ' - python -c "import fcntl; fcntl.fcntl(1, fcntl.F_SETFL, 0)" # Workaround for nonblocking mode\n'
  85. buildConfig += " script:\n"
  86. buildConfig += " - travis/build_carl.sh\n"
  87. buildConfig += " before_cache:\n"
  88. buildConfig += " - docker cp carl:/opt/carl/. .\n"
  89. # Upload to DockerHub
  90. buildConfig += " deploy:\n"
  91. buildConfig += " - provider: script\n"
  92. buildConfig += " skip_cleanup: true\n"
  93. buildConfig += " script: bash travis/deploy_docker.sh carl\n"
  94. s += buildConfig
  95. # Generate all build configurations
  96. for stage in build_stages:
  97. s += "\n"
  98. s += " ###\n"
  99. s += " # Stage: {}\n".format(stage[0])
  100. s += " ###\n"
  101. for config in configs:
  102. os, os_version, compiler, build_type, task = config
  103. os_type = "osx" if os == "osx" else "linux"
  104. s += " # {}-{} - {}\n".format(os, os_version, build_type)
  105. buildConfig = ""
  106. buildConfig += " - stage: {}\n".format(stage[0])
  107. buildConfig += " os: {}\n".format(os_type)
  108. if os_type == "osx":
  109. buildConfig += " osx_image: {}\n".format(os_version)
  110. buildConfig += " compiler: {}\n".format(compiler)
  111. buildConfig += " env: {}".format(get_env_string(os, os_version, compiler, build_type, task))
  112. buildConfig += " install:\n"
  113. if stage[1] == "Build1":
  114. buildConfig += " - rm -rf build\n"
  115. buildConfig += " - travis/skip_test.sh\n"
  116. if os_type == "osx":
  117. buildConfig += " - travis/install_osx.sh\n"
  118. buildConfig += " before_script:\n"
  119. buildConfig += ' - python -c "import fcntl; fcntl.fcntl(1, fcntl.F_SETFL, 0)" # Workaround for nonblocking mode\n'
  120. buildConfig += " script:\n"
  121. buildConfig += " - travis/build.sh {}\n".format(stage[1])
  122. if os_type == "linux":
  123. buildConfig += " before_cache:\n"
  124. buildConfig += " - docker cp storm:/opt/storm/. .\n"
  125. buildConfig += " after_failure:\n"
  126. buildConfig += " - find build -iname '*err*.log' -type f -print -exec cat {} \;\n"
  127. # Deployment
  128. if stage[1] == "Tasks":
  129. if "Docker" in task or "Doxygen" in task:
  130. buildConfig += " deploy:\n"
  131. if "Docker" in task:
  132. buildConfig += " - provider: script\n"
  133. buildConfig += " skip_cleanup: true\n"
  134. buildConfig += " script: bash travis/deploy_docker.sh storm\n"
  135. if "Doxygen" in task:
  136. buildConfig += " - provider: pages\n"
  137. buildConfig += " skip_cleanup: true\n"
  138. buildConfig += " github_token: $GITHUB_TOKEN\n"
  139. buildConfig += " local_dir: build/doc/html/\n"
  140. buildConfig += " repo: moves-rwth/storm-doc\n"
  141. buildConfig += " target_branch: master\n"
  142. buildConfig += " on:\n"
  143. buildConfig += " branch: master\n"
  144. s += buildConfig
  145. print(s)