1
0

tests.yml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. name: Tests
  2. on:
  3. push:
  4. branches: ["develop", "release-*"]
  5. pull_request:
  6. concurrency:
  7. group: ${{ github.workflow }}-${{ github.ref }}
  8. cancel-in-progress: true
  9. jobs:
  10. check-sampleconfig:
  11. runs-on: ubuntu-latest
  12. steps:
  13. - uses: actions/checkout@v2
  14. - uses: actions/setup-python@v2
  15. - run: pip install .
  16. - run: scripts-dev/generate_sample_config.sh --check
  17. - run: scripts-dev/config-lint.sh
  18. check-schema-delta:
  19. runs-on: ubuntu-latest
  20. steps:
  21. - uses: actions/checkout@v2
  22. - uses: actions/setup-python@v2
  23. - run: "pip install 'click==8.1.1' 'GitPython>=3.1.20'"
  24. - run: scripts-dev/check_schema_delta.py --force-colors
  25. lint:
  26. uses: "matrix-org/backend-meta/.github/workflows/python-poetry-ci.yml@v1"
  27. with:
  28. typechecking-extras: "all"
  29. lint-crlf:
  30. runs-on: ubuntu-latest
  31. steps:
  32. - uses: actions/checkout@v2
  33. - name: Check line endings
  34. run: scripts-dev/check_line_terminators.sh
  35. lint-newsfile:
  36. if: ${{ github.base_ref == 'develop' || contains(github.base_ref, 'release-') }}
  37. runs-on: ubuntu-latest
  38. steps:
  39. - uses: actions/checkout@v2
  40. with:
  41. ref: ${{ github.event.pull_request.head.sha }}
  42. fetch-depth: 0
  43. - uses: actions/setup-python@v2
  44. - run: "pip install 'towncrier>=18.6.0rc1'"
  45. - run: scripts-dev/check-newsfragment.sh
  46. env:
  47. PULL_REQUEST_NUMBER: ${{ github.event.number }}
  48. lint-pydantic:
  49. runs-on: ubuntu-latest
  50. steps:
  51. - uses: actions/checkout@v2
  52. with:
  53. ref: ${{ github.event.pull_request.head.sha }}
  54. fetch-depth: 0
  55. - uses: matrix-org/setup-python-poetry@v1
  56. with:
  57. extras: "all"
  58. - run: poetry run scripts-dev/check_pydantic_models.py
  59. # Dummy step to gate other tests on without repeating the whole list
  60. linting-done:
  61. if: ${{ !cancelled() }} # Run this even if prior jobs were skipped
  62. needs: [lint, lint-crlf, lint-newsfile, lint-pydantic, check-sampleconfig, check-schema-delta]
  63. runs-on: ubuntu-latest
  64. steps:
  65. - run: "true"
  66. trial:
  67. if: ${{ !cancelled() && !failure() }} # Allow previous steps to be skipped, but not fail
  68. needs: linting-done
  69. runs-on: ubuntu-latest
  70. strategy:
  71. matrix:
  72. python-version: ["3.7", "3.8", "3.9", "3.10"]
  73. database: ["sqlite"]
  74. extras: ["all"]
  75. include:
  76. # Newest Python without optional deps
  77. - python-version: "3.10"
  78. extras: ""
  79. # Oldest Python with PostgreSQL
  80. - python-version: "3.7"
  81. database: "postgres"
  82. postgres-version: "10"
  83. extras: "all"
  84. # Newest Python with newest PostgreSQL
  85. - python-version: "3.10"
  86. database: "postgres"
  87. postgres-version: "14"
  88. extras: "all"
  89. steps:
  90. - uses: actions/checkout@v2
  91. - run: sudo apt-get -qq install xmlsec1
  92. - name: Set up PostgreSQL ${{ matrix.postgres-version }}
  93. if: ${{ matrix.postgres-version }}
  94. run: |
  95. docker run -d -p 5432:5432 \
  96. -e POSTGRES_PASSWORD=postgres \
  97. -e POSTGRES_INITDB_ARGS="--lc-collate C --lc-ctype C --encoding UTF8" \
  98. postgres:${{ matrix.postgres-version }}
  99. - uses: matrix-org/setup-python-poetry@v1
  100. with:
  101. python-version: ${{ matrix.python-version }}
  102. extras: ${{ matrix.extras }}
  103. - name: Await PostgreSQL
  104. if: ${{ matrix.postgres-version }}
  105. timeout-minutes: 2
  106. run: until pg_isready -h localhost; do sleep 1; done
  107. - run: poetry run trial --jobs=2 tests
  108. env:
  109. SYNAPSE_POSTGRES: ${{ matrix.database == 'postgres' || '' }}
  110. SYNAPSE_POSTGRES_HOST: localhost
  111. SYNAPSE_POSTGRES_USER: postgres
  112. SYNAPSE_POSTGRES_PASSWORD: postgres
  113. - name: Dump logs
  114. # Logs are most useful when the command fails, always include them.
  115. if: ${{ always() }}
  116. # Note: Dumps to workflow logs instead of using actions/upload-artifact
  117. # This keeps logs colocated with failing jobs
  118. # It also ignores find's exit code; this is a best effort affair
  119. run: >-
  120. find _trial_temp -name '*.log'
  121. -exec echo "::group::{}" \;
  122. -exec cat {} \;
  123. -exec echo "::endgroup::" \;
  124. || true
  125. trial-olddeps:
  126. # Note: sqlite only; no postgres
  127. if: ${{ !cancelled() && !failure() }} # Allow previous steps to be skipped, but not fail
  128. needs: linting-done
  129. runs-on: ubuntu-latest
  130. steps:
  131. - uses: actions/checkout@v2
  132. - name: Test with old deps
  133. uses: docker://ubuntu:focal # For old python and sqlite
  134. # Note: focal seems to be using 3.8, but the oldest is 3.7?
  135. # See https://github.com/matrix-org/synapse/issues/12343
  136. with:
  137. workdir: /github/workspace
  138. entrypoint: .ci/scripts/test_old_deps.sh
  139. - name: Dump logs
  140. # Logs are most useful when the command fails, always include them.
  141. if: ${{ always() }}
  142. # Note: Dumps to workflow logs instead of using actions/upload-artifact
  143. # This keeps logs colocated with failing jobs
  144. # It also ignores find's exit code; this is a best effort affair
  145. run: >-
  146. find _trial_temp -name '*.log'
  147. -exec echo "::group::{}" \;
  148. -exec cat {} \;
  149. -exec echo "::endgroup::" \;
  150. || true
  151. trial-pypy:
  152. # Very slow; only run if the branch name includes 'pypy'
  153. # Note: sqlite only; no postgres. Completely untested since poetry move.
  154. if: ${{ contains(github.ref, 'pypy') && !failure() && !cancelled() }}
  155. needs: linting-done
  156. runs-on: ubuntu-latest
  157. strategy:
  158. matrix:
  159. python-version: ["pypy-3.7"]
  160. extras: ["all"]
  161. steps:
  162. - uses: actions/checkout@v2
  163. # Install libs necessary for PyPy to build binary wheels for dependencies
  164. - run: sudo apt-get -qq install xmlsec1 libxml2-dev libxslt-dev
  165. - uses: matrix-org/setup-python-poetry@v1
  166. with:
  167. python-version: ${{ matrix.python-version }}
  168. extras: ${{ matrix.extras }}
  169. - run: poetry run trial --jobs=2 tests
  170. - name: Dump logs
  171. # Logs are most useful when the command fails, always include them.
  172. if: ${{ always() }}
  173. # Note: Dumps to workflow logs instead of using actions/upload-artifact
  174. # This keeps logs colocated with failing jobs
  175. # It also ignores find's exit code; this is a best effort affair
  176. run: >-
  177. find _trial_temp -name '*.log'
  178. -exec echo "::group::{}" \;
  179. -exec cat {} \;
  180. -exec echo "::endgroup::" \;
  181. || true
  182. sytest:
  183. if: ${{ !failure() && !cancelled() }}
  184. needs: linting-done
  185. runs-on: ubuntu-latest
  186. container:
  187. image: matrixdotorg/sytest-synapse:${{ matrix.sytest-tag }}
  188. volumes:
  189. - ${{ github.workspace }}:/src
  190. env:
  191. SYTEST_BRANCH: ${{ github.head_ref }}
  192. POSTGRES: ${{ matrix.postgres && 1}}
  193. MULTI_POSTGRES: ${{ (matrix.postgres == 'multi-postgres') && 1}}
  194. WORKERS: ${{ matrix.workers && 1 }}
  195. REDIS: ${{ matrix.redis && 1 }}
  196. BLACKLIST: ${{ matrix.workers && 'synapse-blacklist-with-workers' }}
  197. TOP: ${{ github.workspace }}
  198. strategy:
  199. fail-fast: false
  200. matrix:
  201. include:
  202. - sytest-tag: focal
  203. - sytest-tag: focal
  204. postgres: postgres
  205. - sytest-tag: testing
  206. postgres: postgres
  207. - sytest-tag: focal
  208. postgres: multi-postgres
  209. workers: workers
  210. - sytest-tag: buster
  211. postgres: multi-postgres
  212. workers: workers
  213. - sytest-tag: buster
  214. postgres: postgres
  215. workers: workers
  216. redis: redis
  217. steps:
  218. - uses: actions/checkout@v2
  219. - name: Prepare test blacklist
  220. run: cat sytest-blacklist .ci/worker-blacklist > synapse-blacklist-with-workers
  221. - name: Run SyTest
  222. run: /bootstrap.sh synapse
  223. working-directory: /src
  224. - name: Summarise results.tap
  225. if: ${{ always() }}
  226. run: /sytest/scripts/tap_to_gha.pl /logs/results.tap
  227. - name: Upload SyTest logs
  228. uses: actions/upload-artifact@v2
  229. if: ${{ always() }}
  230. with:
  231. name: Sytest Logs - ${{ job.status }} - (${{ join(matrix.*, ', ') }})
  232. path: |
  233. /logs/results.tap
  234. /logs/**/*.log*
  235. export-data:
  236. if: ${{ !failure() && !cancelled() }} # Allow previous steps to be skipped, but not fail
  237. needs: [linting-done, portdb]
  238. runs-on: ubuntu-latest
  239. env:
  240. TOP: ${{ github.workspace }}
  241. services:
  242. postgres:
  243. image: postgres
  244. ports:
  245. - 5432:5432
  246. env:
  247. POSTGRES_PASSWORD: "postgres"
  248. POSTGRES_INITDB_ARGS: "--lc-collate C --lc-ctype C --encoding UTF8"
  249. options: >-
  250. --health-cmd pg_isready
  251. --health-interval 10s
  252. --health-timeout 5s
  253. --health-retries 5
  254. steps:
  255. - uses: actions/checkout@v2
  256. - run: sudo apt-get -qq install xmlsec1
  257. - uses: matrix-org/setup-python-poetry@v1
  258. with:
  259. python-version: ${{ matrix.python-version }}
  260. extras: "postgres"
  261. - run: .ci/scripts/test_export_data_command.sh
  262. portdb:
  263. if: ${{ !failure() && !cancelled() }} # Allow previous steps to be skipped, but not fail
  264. needs: linting-done
  265. runs-on: ubuntu-latest
  266. env:
  267. TOP: ${{ github.workspace }}
  268. strategy:
  269. matrix:
  270. include:
  271. - python-version: "3.7"
  272. postgres-version: "10"
  273. - python-version: "3.10"
  274. postgres-version: "14"
  275. services:
  276. postgres:
  277. image: postgres:${{ matrix.postgres-version }}
  278. ports:
  279. - 5432:5432
  280. env:
  281. POSTGRES_PASSWORD: "postgres"
  282. POSTGRES_INITDB_ARGS: "--lc-collate C --lc-ctype C --encoding UTF8"
  283. options: >-
  284. --health-cmd pg_isready
  285. --health-interval 10s
  286. --health-timeout 5s
  287. --health-retries 5
  288. steps:
  289. - uses: actions/checkout@v2
  290. - run: sudo apt-get -qq install xmlsec1
  291. - uses: matrix-org/setup-python-poetry@v1
  292. with:
  293. python-version: ${{ matrix.python-version }}
  294. extras: "postgres"
  295. - run: .ci/scripts/test_synapse_port_db.sh
  296. complement:
  297. if: "${{ !failure() && !cancelled() }}"
  298. needs: linting-done
  299. runs-on: ubuntu-latest
  300. strategy:
  301. fail-fast: false
  302. matrix:
  303. include:
  304. - arrangement: monolith
  305. database: SQLite
  306. - arrangement: monolith
  307. database: Postgres
  308. - arrangement: workers
  309. database: Postgres
  310. steps:
  311. - name: Run actions/checkout@v2 for synapse
  312. uses: actions/checkout@v2
  313. with:
  314. path: synapse
  315. - name: Prepare Complement's Prerequisites
  316. run: synapse/.ci/scripts/setup_complement_prerequisites.sh
  317. - run: |
  318. set -o pipefail
  319. POSTGRES=${{ (matrix.database == 'Postgres') && 1 || '' }} WORKERS=${{ (matrix.arrangement == 'workers') && 1 || '' }} COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -json 2>&1 | gotestfmt
  320. shell: bash
  321. name: Run Complement Tests
  322. # a job which marks all the other jobs as complete, thus allowing PRs to be merged.
  323. tests-done:
  324. if: ${{ always() }}
  325. needs:
  326. - check-sampleconfig
  327. - lint
  328. - lint-crlf
  329. - lint-newsfile
  330. - trial
  331. - trial-olddeps
  332. - sytest
  333. - export-data
  334. - portdb
  335. - complement
  336. runs-on: ubuntu-latest
  337. steps:
  338. - uses: matrix-org/done-action@v2
  339. with:
  340. needs: ${{ toJSON(needs) }}
  341. # The newsfile lint may be skipped on non PR builds
  342. skippable:
  343. lint-newsfile