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.

181 lines
9.3 KiB

  1. name: Build Test
  2. # Builds and tests storm on various platforms
  3. # also deploys images to Dockerhub
  4. on:
  5. schedule:
  6. # run daily
  7. - cron: '0 6 * * *'
  8. # needed to trigger the workflow manually
  9. workflow_dispatch:
  10. pull_request:
  11. env:
  12. CARL_BRANCH: "master14"
  13. CARL_GIT_URL: "https://github.com/smtrat/carl.git"
  14. STORM_GIT_URL: "${{ github.server_url }}/${{ github.repository }}.git"
  15. STORM_BRANCH: "${{ github.ref }}"
  16. # github runners currently have two cores
  17. NR_JOBS: "2"
  18. # cmake arguments
  19. CMAKE_DEBUG: "-DCMAKE_BUILD_TYPE=Debug -DSTORM_DEVELOPER=ON -DSTORM_PORTABLE=ON"
  20. CMAKE_RELEASE: "-DCMAKE_BUILD_TYPE=Release -DSTORM_DEVELOPER=OFF -DSTORM_PORTABLE=ON"
  21. CARL_CMAKE_DEBUG: "-DCMAKE_BUILD_TYPE=Debug -DUSE_CLN_NUMBERS=ON -DUSE_GINAC=ON -DTHREAD_SAFE=ON -DBUILD_ADDONS=ON -DBUILD_ADDON_PARSER=ON"
  22. CARL_CMAKE_RELEASE: "-DCMAKE_BUILD_TYPE=Release -DUSE_CLN_NUMBERS=ON -DUSE_GINAC=ON -DTHREAD_SAFE=ON -DBUILD_ADDONS=ON -DBUILD_ADDON_PARSER=ON"
  23. jobs:
  24. noDeploy:
  25. name: Build and Test
  26. runs-on: ubuntu-latest
  27. strategy:
  28. matrix:
  29. distro: ["ubuntu-18.04", "debian-10", "debian-9", "ubuntu-20.04"]
  30. debugOrRelease: ["debug", "release"]
  31. steps:
  32. - name: Setup cmake arguments
  33. # this is strangely the best way to implement environment variables based on the value of another
  34. # GITHUB_ENV is a magic variable pointing to a file; if a line with format {NAME}={VALUE}
  35. # then the env variable with name NAME will be created/updated with VALUE
  36. run: |
  37. ([[ ${{ matrix.debugOrRelease }} == "debug" ]] && echo "CMAKE_ARGS=${CMAKE_DEBUG}" || echo "CMAKE_ARGS=${CMAKE_RELEASE}") >> $GITHUB_ENV
  38. - name: Init Docker
  39. run: sudo docker run -d -it --name storm --privileged movesrwth/storm-basesystem:${{ matrix.distro }}
  40. - name: Git clone
  41. # git clone cannot clone individual commits based on a sha and some other refs
  42. # this workaround fixes this and fetches only one commit
  43. run: |
  44. sudo docker exec storm bash -c "mkdir /opt/storm; cd /opt/storm; git init && git remote add origin ${STORM_GIT_URL} && git fetch --depth 1 origin ${STORM_BRANCH} && git checkout FETCH_HEAD"
  45. - name: Run cmake
  46. run: sudo docker exec storm bash -c "mkdir /opt/storm/build; cd /opt/storm/build; cmake .. ${CMAKE_ARGS}"
  47. - name: Build storm
  48. run: sudo docker exec storm bash -c "cd /opt/storm/build; make -j ${NR_JOBS}"
  49. # A bit hacky... but its usefullnes has been proven in production
  50. - name: Check release makeflags
  51. if: matrix.debugOrRelease == 'release'
  52. run: |
  53. sudo docker exec storm bash -c "/opt/storm/build/bin/storm --version | grep 'with flags .* -O3' || (echo \"Error: Missing flag \'-O3\' for release build.\" && false)"
  54. sudo docker exec storm bash -c "/opt/storm/build/bin/storm --version | grep 'with flags .* -DNDEBUG' || (echo \"Error: Missing flag \'-DNDEBUG\' for release build.\" && false)"
  55. - name: Check debug makeflags
  56. if: matrix.debugOrRelease == 'debug'
  57. run: |
  58. sudo docker exec storm bash -c "/opt/storm/build/bin/storm --version | grep 'with flags .* -g' || (echo \"Error: Missing flag \'-g\' for debug build.\" && false)"
  59. - name: Run unit tests
  60. run: sudo docker exec storm bash -c "cd /opt/storm/build; ctest test --output-on-failure"
  61. deploy:
  62. name: Build, Test and Deploy
  63. runs-on: ubuntu-latest
  64. env:
  65. DISTRO: "ubuntu-20.10"
  66. strategy:
  67. matrix:
  68. debugOrRelease: ["debug", "release"]
  69. steps:
  70. - name: Setup cmake arguments
  71. # this is strangely the best way to implement environment variables based on the value of another
  72. # GITHUB_ENV is a magic variable pointing to a file; if a line with format {NAME}={VALUE}
  73. # then the env variable with name NAME will be created/updated with VALUE
  74. run: |
  75. ([[ ${{ matrix.debugOrRelease }} == "debug" ]] && echo "CMAKE_ARGS=${CMAKE_DEBUG}" || echo "CMAKE_ARGS=${CMAKE_RELEASE}") >> $GITHUB_ENV
  76. ([[ ${{ matrix.debugOrRelease }} == "debug" ]] && echo "CARL_CMAKE_ARGS=${CARL_CMAKE_DEBUG}" || echo "CARL_CMAKE_ARGS=${CARL_CMAKE_RELEASE}") >> $GITHUB_ENV
  77. - name: Login into docker
  78. # Only login if using master on original repo (and not for pull requests or forks)
  79. if: github.repository_owner == 'moves-rwth' && github.ref == 'refs/heads/master'
  80. run: echo "${{ secrets.STORM_CI_DOCKER_PASSWORD }}" | sudo docker login -u "${{ secrets.STORM_CI_DOCKER_USERNAME }}" --password-stdin
  81. - name: Init Docker
  82. run: sudo docker run -d -it --name storm --privileged movesrwth/storm-basesystem:${DISTRO}
  83. #####
  84. # Build & DEPLOY CARL
  85. #####
  86. # We should not do partial updates :/
  87. # but we need to install some dependencies
  88. # Surely we can find a better way to do this at some point
  89. - name: Update base system
  90. run: |
  91. sudo docker exec storm apt-get update
  92. sudo docker exec storm apt-get upgrade -qqy
  93. - name: install dependencies
  94. run: sudo docker exec storm apt-get install -qq -y uuid-dev pkg-config
  95. - name: Git clone carl
  96. run: sudo docker exec storm git clone --depth 1 --branch $CARL_BRANCH $CARL_GIT_URL /opt/carl
  97. - name: Run cmake for carl
  98. run: sudo docker exec storm bash -c "mkdir /opt/carl/build; cd /opt/carl/build; cmake .. ${CARL_CMAKE_ARGS}"
  99. - name: Build carl
  100. run: sudo docker exec storm bash -c "cd /opt/carl/build; make lib_carl -j ${NR_JOBS}"
  101. - name: Deploy carl
  102. # Only deploy if using master on original repo (and not for pull requests or forks)
  103. if: github.repository_owner == 'moves-rwth' && github.ref == 'refs/heads/master'
  104. run: |
  105. sudo docker commit storm movesrwth/carl:ci-${{ matrix.debugOrRelease }}
  106. sudo docker push movesrwth/carl:ci-${{ matrix.debugOrRelease }}
  107. #####
  108. # Build & TEST & DEPLOY STORM
  109. #####
  110. - name: Git shallow clone
  111. # Only clone shallow if not using master on original repo (and not for pull requests or forks)
  112. if: ${{ !(github.repository_owner == 'moves-rwth' && github.ref == 'refs/heads/master') }}
  113. run: |
  114. # git clone cannot clone individual commits based on a sha and some other refs
  115. sudo docker exec storm bash -c "mkdir /opt/storm; cd /opt/storm; git init && git remote add origin ${STORM_GIT_URL} && git fetch --depth 1 origin ${STORM_BRANCH} && git checkout FETCH_HEAD"
  116. - name: Git deep clone
  117. # needed for versioning for now on deployment
  118. if: github.repository_owner == 'moves-rwth' && github.ref == 'refs/heads/master'
  119. run: |
  120. sudo docker exec storm git clone --branch master $STORM_GIT_URL /opt/storm
  121. - name: Run cmake
  122. run: sudo docker exec storm bash -c "mkdir /opt/storm/build; cd /opt/storm/build; cmake .. ${CMAKE_ARGS}"
  123. - name: Build storm
  124. run: sudo docker exec storm bash -c "cd /opt/storm/build; make -j ${NR_JOBS}"
  125. # A bit hacky... but its usefulness has been proven in production
  126. - name: Check release makeflags
  127. if: matrix.debugOrRelease == 'release'
  128. run: |
  129. sudo docker exec storm bash -c "/opt/storm/build/bin/storm --version | grep 'with flags .* -O3' || (echo \"Error: Missing flag \'-O3\' for release build.\" && false)"
  130. sudo docker exec storm bash -c "/opt/storm/build/bin/storm --version | grep 'with flags .* -DNDEBUG' || (echo \"Error: Missing flag \'-DNDEBUG\' for release build.\" && false)"
  131. - name: Check debug makeflags
  132. if: matrix.debugOrRelease == 'debug'
  133. run: |
  134. sudo docker exec storm bash -c "/opt/storm/build/bin/storm --version | grep 'with flags .* -g' || (echo \"Error: Missing flag \'-g\' for debug build.\" && false)"
  135. - name: Run unit tests
  136. run: sudo docker exec storm bash -c "cd /opt/storm/build; ctest test --output-on-failure"
  137. - name: Deploy storm
  138. # Only deploy if using master on original repo (and not for pull requests or forks)
  139. if: github.repository_owner == 'moves-rwth' && github.ref == 'refs/heads/master'
  140. run: |
  141. sudo docker commit storm movesrwth/storm:ci-${{ matrix.debugOrRelease }}
  142. sudo docker push movesrwth/storm:ci-${{ matrix.debugOrRelease }}
  143. notify:
  144. name: Email notification
  145. runs-on: ubuntu-latest
  146. needs: [noDeploy, deploy]
  147. # Only run in main repo and even if previous step failed
  148. if: github.repository_owner == 'moves-rwth' && always()
  149. steps:
  150. - uses: technote-space/workflow-conclusion-action@v2
  151. - uses: dawidd6/action-send-mail@v2
  152. with:
  153. server_address: ${{ secrets.STORM_CI_MAIL_SERVER }}
  154. server_port: 587
  155. username: ${{ secrets.STORM_CI_MAIL_USERNAME }}
  156. password: ${{ secrets.STORM_CI_MAIL_PASSWORD }}
  157. subject: "[You broke it] CI run failed for ${{ github.repository }}"
  158. body:
  159. "CI job of ${{ github.repository }} has failed for commit ${{ github.sha }}.\n\
  160. The error type is: ${{ env.WORKFLOW_CONCLUSION }}.\n\n\
  161. For more information, see https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
  162. to: ${{ secrets.STORM_CI_MAIL_RECIPIENTS }}
  163. from: Github Actions <you-broke-it@stormchecker.org>
  164. if: env.WORKFLOW_CONCLUSION != 'success' # notify only if failure