twisted_trunk.yml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. name: Twisted Trunk
  2. on:
  3. schedule:
  4. - cron: 0 8 * * *
  5. workflow_dispatch:
  6. # NB: inputs are only present when this workflow is dispatched manually.
  7. # (The default below is the default field value in the form to trigger
  8. # a manual dispatch). Otherwise the inputs will evaluate to null.
  9. inputs:
  10. twisted_ref:
  11. description: Commit, branch or tag to checkout from upstream Twisted.
  12. required: false
  13. default: 'trunk'
  14. type: string
  15. concurrency:
  16. group: ${{ github.workflow }}-${{ github.ref }}
  17. cancel-in-progress: true
  18. jobs:
  19. check_repo:
  20. # Prevent this workflow from running on any fork of Synapse other than matrix-org/synapse, as it is
  21. # only useful to the Synapse core team.
  22. # All other workflow steps depend on this one, thus if 'should_run_workflow' is not 'true', the rest
  23. # of the workflow will be skipped as well.
  24. if: github.repository == 'matrix-org/synapse'
  25. runs-on: ubuntu-latest
  26. outputs:
  27. should_run_workflow: ${{ steps.check_condition.outputs.should_run_workflow }}
  28. steps:
  29. - id: check_condition
  30. run: echo "should_run_workflow=${{ github.repository == 'matrix-org/synapse' }}" >> "$GITHUB_OUTPUT"
  31. mypy:
  32. needs: check_repo
  33. if: needs.check_repo.outputs.should_run_workflow == 'true'
  34. runs-on: ubuntu-latest
  35. steps:
  36. - uses: actions/checkout@v3
  37. - name: Install Rust
  38. uses: dtolnay/rust-toolchain@stable
  39. - uses: Swatinem/rust-cache@v2
  40. - uses: matrix-org/setup-python-poetry@v1
  41. with:
  42. python-version: "3.x"
  43. extras: "all"
  44. - run: |
  45. poetry remove twisted
  46. poetry add --extras tls git+https://github.com/twisted/twisted.git#${{ inputs.twisted_ref || 'trunk' }}
  47. poetry install --no-interaction --extras "all test"
  48. - name: Remove unhelpful options from mypy config
  49. run: sed -e '/warn_unused_ignores = True/d' -e '/warn_redundant_casts = True/d' -i mypy.ini
  50. - run: poetry run mypy
  51. trial:
  52. needs: check_repo
  53. if: needs.check_repo.outputs.should_run_workflow == 'true'
  54. runs-on: ubuntu-latest
  55. steps:
  56. - uses: actions/checkout@v3
  57. - run: sudo apt-get -qq install xmlsec1
  58. - name: Install Rust
  59. uses: dtolnay/rust-toolchain@stable
  60. - uses: Swatinem/rust-cache@v2
  61. - uses: matrix-org/setup-python-poetry@v1
  62. with:
  63. python-version: "3.x"
  64. extras: "all test"
  65. - run: |
  66. poetry remove twisted
  67. poetry add --extras tls git+https://github.com/twisted/twisted.git#trunk
  68. poetry install --no-interaction --extras "all test"
  69. - run: poetry run trial --jobs 2 tests
  70. - name: Dump logs
  71. # Logs are most useful when the command fails, always include them.
  72. if: ${{ always() }}
  73. # Note: Dumps to workflow logs instead of using actions/upload-artifact
  74. # This keeps logs colocated with failing jobs
  75. # It also ignores find's exit code; this is a best effort affair
  76. run: >-
  77. find _trial_temp -name '*.log'
  78. -exec echo "::group::{}" \;
  79. -exec cat {} \;
  80. -exec echo "::endgroup::" \;
  81. || true
  82. sytest:
  83. needs: check_repo
  84. if: needs.check_repo.outputs.should_run_workflow == 'true'
  85. runs-on: ubuntu-latest
  86. container:
  87. # We're using ubuntu:focal because it uses Python 3.8 which is our minimum supported Python version.
  88. # This job is a canary to warn us about unreleased twisted changes that would cause problems for us if
  89. # they were to be released immediately. For simplicity's sake (and to save CI runners) we use the oldest
  90. # version, assuming that any incompatibilities on newer versions would also be present on the oldest.
  91. image: matrixdotorg/sytest-synapse:focal
  92. volumes:
  93. - ${{ github.workspace }}:/src
  94. steps:
  95. - uses: actions/checkout@v3
  96. - name: Install Rust
  97. uses: dtolnay/rust-toolchain@stable
  98. - uses: Swatinem/rust-cache@v2
  99. - name: Patch dependencies
  100. # Note: The poetry commands want to create a virtualenv in /src/.venv/,
  101. # but the sytest-synapse container expects it to be in /venv/.
  102. # We symlink it before running poetry so that poetry actually
  103. # ends up installing to `/venv`.
  104. run: |
  105. ln -s -T /venv /src/.venv
  106. poetry remove twisted
  107. poetry add --extras tls git+https://github.com/twisted/twisted.git#trunk
  108. poetry install --no-interaction --extras "all test"
  109. working-directory: /src
  110. - name: Run SyTest
  111. run: /bootstrap.sh synapse
  112. working-directory: /src
  113. env:
  114. # Use offline mode to avoid reinstalling the pinned version of
  115. # twisted.
  116. OFFLINE: 1
  117. - name: Summarise results.tap
  118. if: ${{ always() }}
  119. run: /sytest/scripts/tap_to_gha.pl /logs/results.tap
  120. - name: Upload SyTest logs
  121. uses: actions/upload-artifact@v3
  122. if: ${{ always() }}
  123. with:
  124. name: Sytest Logs - ${{ job.status }} - (${{ join(matrix.*, ', ') }})
  125. path: |
  126. /logs/results.tap
  127. /logs/**/*.log*
  128. complement:
  129. needs: check_repo
  130. if: "!failure() && !cancelled() && needs.check_repo.outputs.should_run_workflow == 'true'"
  131. runs-on: ubuntu-latest
  132. strategy:
  133. fail-fast: false
  134. matrix:
  135. include:
  136. - arrangement: monolith
  137. database: SQLite
  138. - arrangement: monolith
  139. database: Postgres
  140. - arrangement: workers
  141. database: Postgres
  142. steps:
  143. - name: Run actions/checkout@v3 for synapse
  144. uses: actions/checkout@v3
  145. with:
  146. path: synapse
  147. - uses: actions/setup-go@v4
  148. - name: Prepare Complement's Prerequisites
  149. run: synapse/.ci/scripts/setup_complement_prerequisites.sh
  150. # This step is specific to the 'Twisted trunk' test run:
  151. - name: Patch dependencies
  152. run: |
  153. set -x
  154. DEBIAN_FRONTEND=noninteractive sudo apt-get install -yqq python3 pipx
  155. pipx install poetry==1.3.2
  156. poetry remove -n twisted
  157. poetry add -n --extras tls git+https://github.com/twisted/twisted.git#trunk
  158. poetry lock --no-update
  159. working-directory: synapse
  160. - run: |
  161. set -o pipefail
  162. TEST_ONLY_SKIP_DEP_HASH_VERIFICATION=1 POSTGRES=${{ (matrix.database == 'Postgres') && 1 || '' }} WORKERS=${{ (matrix.arrangement == 'workers') && 1 || '' }} COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -json 2>&1 | synapse/.ci/scripts/gotestfmt
  163. shell: bash
  164. name: Run Complement Tests
  165. # open an issue if the build fails, so we know about it.
  166. open-issue:
  167. if: failure() && needs.check_repo.outputs.should_run_workflow == 'true'
  168. needs:
  169. - mypy
  170. - trial
  171. - sytest
  172. - complement
  173. runs-on: ubuntu-latest
  174. steps:
  175. - uses: actions/checkout@v3
  176. - uses: JasonEtco/create-an-issue@e27dddc79c92bc6e4562f268fffa5ed752639abd # v2.9.1
  177. env:
  178. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  179. with:
  180. update_existing: true
  181. filename: .ci/twisted_trunk_build_failed_issue_template.md