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.

155 lines
6.9 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", "20.04", "gcc", "DefaultDebugTravis", "TestDocker"),
  12. ("ubuntu", "20.04", "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)", "BuildLast"),
  21. ("Tasks", "Tasks"),
  22. ]
  23. def get_env_string(os, os_version, compiler, build_type, task):
  24. if os == "osx":
  25. return "CONFIG={} TASK={} COMPILER={} STL=libc++\n".format(build_type, task, compiler)
  26. else:
  27. return "CONFIG={} TASK={} LINUX={} COMPILER={}\n".format(build_type, task, "{}-{}".format(os, os_version), compiler)
  28. if __name__ == "__main__":
  29. s = ""
  30. # Initial config
  31. s += "#\n"
  32. s += "# General config\n"
  33. s += "#\n"
  34. s += "branches:\n"
  35. s += " only:\n"
  36. s += " - master\n"
  37. s += " - stable\n"
  38. s += "sudo: required\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. for config in configs:
  73. os, os_version, compiler, build_type, task = config
  74. os_type = "osx" if os == "osx" else "linux"
  75. if "Travis" in build_type:
  76. s += " # {}-{} - {}\n".format(os, os_version, build_type)
  77. buildConfig = ""
  78. buildConfig += " - stage: Build Carl\n"
  79. buildConfig += " os: {}\n".format(os_type)
  80. buildConfig += " compiler: {}\n".format(compiler)
  81. buildConfig += " env: {}".format(get_env_string(os, os_version, compiler, build_type, task))
  82. buildConfig += " before_script:\n"
  83. buildConfig += ' - python -c "import fcntl; fcntl.fcntl(1, fcntl.F_SETFL, 0)" # Workaround for nonblocking mode\n'
  84. buildConfig += " script:\n"
  85. buildConfig += " - travis/build_carl.sh\n"
  86. buildConfig += " before_cache:\n"
  87. buildConfig += " - docker cp carl:/opt/carl/. .\n"
  88. # Upload to DockerHub
  89. buildConfig += " deploy:\n"
  90. buildConfig += " - provider: script\n"
  91. buildConfig += " skip_cleanup: true\n"
  92. buildConfig += " script: bash travis/deploy_docker.sh carl\n"
  93. s += buildConfig
  94. # Generate all build configurations
  95. for stage in build_stages:
  96. s += "\n"
  97. s += " ###\n"
  98. s += " # Stage: {}\n".format(stage[0])
  99. s += " ###\n"
  100. for config in configs:
  101. os, os_version, compiler, build_type, task = config
  102. os_type = "osx" if os == "osx" else "linux"
  103. s += " # {}-{} - {}\n".format(os, os_version, build_type)
  104. buildConfig = ""
  105. buildConfig += " - stage: {}\n".format(stage[0])
  106. buildConfig += " os: {}\n".format(os_type)
  107. if os_type == "osx":
  108. buildConfig += " osx_image: {}\n".format(os_version)
  109. buildConfig += " compiler: {}\n".format(compiler)
  110. buildConfig += " env: {}".format(get_env_string(os, os_version, compiler, build_type, task))
  111. buildConfig += " install:\n"
  112. if stage[1] == "Build1":
  113. buildConfig += " - rm -rf build\n"
  114. buildConfig += " - travis/skip_test.sh\n"
  115. if os_type == "osx":
  116. buildConfig += " - travis/install_osx.sh\n"
  117. buildConfig += " before_script:\n"
  118. buildConfig += ' - python -c "import fcntl; fcntl.fcntl(1, fcntl.F_SETFL, 0)" # Workaround for nonblocking mode\n'
  119. buildConfig += " script:\n"
  120. buildConfig += " - travis/build.sh {}\n".format(stage[1])
  121. if os_type == "linux":
  122. buildConfig += " before_cache:\n"
  123. buildConfig += " - docker cp storm:/opt/storm/. .\n"
  124. buildConfig += " after_failure:\n"
  125. buildConfig += " - find build -iname '*err*.log' -type f -print -exec cat {} \;\n"
  126. # Deployment
  127. if stage[1] == "Tasks":
  128. if "Docker" in task or "Doxygen" in task:
  129. buildConfig += " deploy:\n"
  130. if "Docker" in task:
  131. buildConfig += " - provider: script\n"
  132. buildConfig += " skip_cleanup: true\n"
  133. buildConfig += " script: bash travis/deploy_docker.sh storm\n"
  134. if "Doxygen" in task:
  135. buildConfig += " - provider: pages\n"
  136. buildConfig += " skip_cleanup: true\n"
  137. buildConfig += " github_token: $GITHUB_TOKEN\n"
  138. buildConfig += " local_dir: build/doc/html/\n"
  139. buildConfig += " repo: moves-rwth/storm-doc\n"
  140. buildConfig += " target_branch: master\n"
  141. buildConfig += " on:\n"
  142. buildConfig += " branch: master\n"
  143. s += buildConfig
  144. print(s)