tests.yml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. name: Tests
  2. on:
  3. push:
  4. branches: ["develop", "release-*"]
  5. pull_request:
  6. merge_group:
  7. workflow_dispatch:
  8. concurrency:
  9. group: ${{ github.workflow }}-${{ github.ref }}
  10. cancel-in-progress: true
  11. jobs:
  12. check-signoff:
  13. if: "github.event_name == 'pull_request'"
  14. uses: "matrix-org/backend-meta/.github/workflows/sign-off.yml@v2"
  15. # Job to detect what has changed so we don't run e.g. Rust checks on PRs that
  16. # don't modify Rust code.
  17. changes:
  18. runs-on: ubuntu-latest
  19. outputs:
  20. rust: ${{ !startsWith(github.ref, 'refs/pull/') || steps.filter.outputs.rust }}
  21. trial: ${{ !startsWith(github.ref, 'refs/pull/') || steps.filter.outputs.trial }}
  22. integration: ${{ !startsWith(github.ref, 'refs/pull/') || steps.filter.outputs.integration }}
  23. linting: ${{ !startsWith(github.ref, 'refs/pull/') || steps.filter.outputs.linting }}
  24. steps:
  25. - uses: dorny/paths-filter@v2
  26. id: filter
  27. # We only check on PRs
  28. if: startsWith(github.ref, 'refs/pull/')
  29. with:
  30. filters: |
  31. rust:
  32. - 'rust/**'
  33. - 'Cargo.toml'
  34. - 'Cargo.lock'
  35. - '.rustfmt.toml'
  36. - '.github/workflows/tests.yml'
  37. trial:
  38. - 'synapse/**'
  39. - 'tests/**'
  40. - 'rust/**'
  41. - '.ci/scripts/calculate_jobs.py'
  42. - 'Cargo.toml'
  43. - 'Cargo.lock'
  44. - 'pyproject.toml'
  45. - 'poetry.lock'
  46. - '.github/workflows/tests.yml'
  47. integration:
  48. - 'synapse/**'
  49. - 'rust/**'
  50. - 'docker/**'
  51. - 'Cargo.toml'
  52. - 'Cargo.lock'
  53. - 'pyproject.toml'
  54. - 'poetry.lock'
  55. - 'docker/**'
  56. - '.ci/**'
  57. - 'scripts-dev/complement.sh'
  58. - '.github/workflows/tests.yml'
  59. linting:
  60. - 'synapse/**'
  61. - 'docker/**'
  62. - 'tests/**'
  63. - 'scripts-dev/**'
  64. - 'contrib/**'
  65. - 'synmark/**'
  66. - 'stubs/**'
  67. - '.ci/**'
  68. - 'mypy.ini'
  69. - 'pyproject.toml'
  70. - 'poetry.lock'
  71. - '.github/workflows/tests.yml'
  72. check-sampleconfig:
  73. runs-on: ubuntu-latest
  74. needs: changes
  75. if: ${{ needs.changes.outputs.linting == 'true' }}
  76. steps:
  77. - uses: actions/checkout@v4
  78. - name: Install Rust
  79. uses: dtolnay/rust-toolchain@1.61.0
  80. - uses: Swatinem/rust-cache@v2
  81. - uses: matrix-org/setup-python-poetry@v1
  82. with:
  83. python-version: "3.x"
  84. poetry-version: "1.3.2"
  85. extras: "all"
  86. - run: poetry run scripts-dev/generate_sample_config.sh --check
  87. - run: poetry run scripts-dev/config-lint.sh
  88. check-schema-delta:
  89. runs-on: ubuntu-latest
  90. needs: changes
  91. if: ${{ needs.changes.outputs.linting == 'true' }}
  92. steps:
  93. - uses: actions/checkout@v4
  94. - uses: actions/setup-python@v4
  95. with:
  96. python-version: "3.x"
  97. - run: "pip install 'click==8.1.1' 'GitPython>=3.1.20'"
  98. - run: scripts-dev/check_schema_delta.py --force-colors
  99. check-lockfile:
  100. runs-on: ubuntu-latest
  101. steps:
  102. - uses: actions/checkout@v4
  103. - uses: actions/setup-python@v4
  104. with:
  105. python-version: "3.x"
  106. - run: .ci/scripts/check_lockfile.py
  107. lint:
  108. runs-on: ubuntu-latest
  109. needs: changes
  110. if: ${{ needs.changes.outputs.linting == 'true' }}
  111. steps:
  112. - name: Checkout repository
  113. uses: actions/checkout@v4
  114. - name: Setup Poetry
  115. uses: matrix-org/setup-python-poetry@v1
  116. with:
  117. install-project: "false"
  118. - name: Import order (isort)
  119. run: poetry run isort --check --diff .
  120. - name: Code style (black)
  121. run: poetry run black --check --diff .
  122. - name: Semantic checks (ruff)
  123. # --quiet suppresses the update check.
  124. run: poetry run ruff --quiet .
  125. lint-mypy:
  126. runs-on: ubuntu-latest
  127. name: Typechecking
  128. needs: changes
  129. if: ${{ needs.changes.outputs.linting == 'true' }}
  130. steps:
  131. - name: Checkout repository
  132. uses: actions/checkout@v4
  133. - name: Install Rust
  134. uses: dtolnay/rust-toolchain@1.61.0
  135. - uses: Swatinem/rust-cache@v2
  136. - name: Setup Poetry
  137. uses: matrix-org/setup-python-poetry@v1
  138. with:
  139. # We want to make use of type hints in optional dependencies too.
  140. extras: all
  141. # We have seen odd mypy failures that were resolved when we started
  142. # installing the project again:
  143. # https://github.com/matrix-org/synapse/pull/15376#issuecomment-1498983775
  144. # To make CI green, err towards caution and install the project.
  145. install-project: "true"
  146. # Cribbed from
  147. # https://github.com/AustinScola/mypy-cache-github-action/blob/85ea4f2972abed39b33bd02c36e341b28ca59213/src/restore.ts#L10-L17
  148. - name: Restore/persist mypy's cache
  149. uses: actions/cache@v3
  150. with:
  151. path: |
  152. .mypy_cache
  153. key: mypy-cache-${{ github.context.sha }}
  154. restore-keys: mypy-cache-
  155. - name: Run mypy
  156. run: poetry run mypy
  157. lint-crlf:
  158. runs-on: ubuntu-latest
  159. steps:
  160. - uses: actions/checkout@v4
  161. - name: Check line endings
  162. run: scripts-dev/check_line_terminators.sh
  163. lint-newsfile:
  164. if: ${{ (github.base_ref == 'develop' || contains(github.base_ref, 'release-')) && github.actor != 'dependabot[bot]' }}
  165. runs-on: ubuntu-latest
  166. steps:
  167. - uses: actions/checkout@v4
  168. with:
  169. ref: ${{ github.event.pull_request.head.sha }}
  170. fetch-depth: 0
  171. - uses: actions/setup-python@v4
  172. with:
  173. python-version: "3.x"
  174. - run: "pip install 'towncrier>=18.6.0rc1'"
  175. - run: scripts-dev/check-newsfragment.sh
  176. env:
  177. PULL_REQUEST_NUMBER: ${{ github.event.number }}
  178. lint-pydantic:
  179. runs-on: ubuntu-latest
  180. needs: changes
  181. if: ${{ needs.changes.outputs.linting == 'true' }}
  182. steps:
  183. - uses: actions/checkout@v4
  184. with:
  185. ref: ${{ github.event.pull_request.head.sha }}
  186. - name: Install Rust
  187. uses: dtolnay/rust-toolchain@1.61.0
  188. - uses: Swatinem/rust-cache@v2
  189. - uses: matrix-org/setup-python-poetry@v1
  190. with:
  191. poetry-version: "1.3.2"
  192. extras: "all"
  193. - run: poetry run scripts-dev/check_pydantic_models.py
  194. lint-clippy:
  195. runs-on: ubuntu-latest
  196. needs: changes
  197. if: ${{ needs.changes.outputs.rust == 'true' }}
  198. steps:
  199. - uses: actions/checkout@v4
  200. - name: Install Rust
  201. uses: dtolnay/rust-toolchain@1.61.0
  202. with:
  203. components: clippy
  204. - uses: Swatinem/rust-cache@v2
  205. - run: cargo clippy -- -D warnings
  206. # We also lint against a nightly rustc so that we can lint the benchmark
  207. # suite, which requires a nightly compiler.
  208. lint-clippy-nightly:
  209. runs-on: ubuntu-latest
  210. needs: changes
  211. if: ${{ needs.changes.outputs.rust == 'true' }}
  212. steps:
  213. - uses: actions/checkout@v4
  214. - name: Install Rust
  215. uses: dtolnay/rust-toolchain@master
  216. with:
  217. toolchain: nightly-2022-12-01
  218. components: clippy
  219. - uses: Swatinem/rust-cache@v2
  220. - run: cargo clippy --all-features -- -D warnings
  221. lint-rustfmt:
  222. runs-on: ubuntu-latest
  223. needs: changes
  224. if: ${{ needs.changes.outputs.rust == 'true' }}
  225. steps:
  226. - uses: actions/checkout@v4
  227. - name: Install Rust
  228. uses: dtolnay/rust-toolchain@master
  229. with:
  230. # We use nightly so that it correctly groups together imports
  231. toolchain: nightly-2022-12-01
  232. components: rustfmt
  233. - uses: Swatinem/rust-cache@v2
  234. - run: cargo fmt --check
  235. # Dummy step to gate other tests on without repeating the whole list
  236. linting-done:
  237. if: ${{ !cancelled() }} # Run this even if prior jobs were skipped
  238. needs:
  239. - lint
  240. - lint-mypy
  241. - lint-crlf
  242. - lint-newsfile
  243. - lint-pydantic
  244. - check-sampleconfig
  245. - check-schema-delta
  246. - check-lockfile
  247. - lint-clippy
  248. - lint-rustfmt
  249. runs-on: ubuntu-latest
  250. steps:
  251. - run: "true"
  252. calculate-test-jobs:
  253. if: ${{ !cancelled() && !failure() }} # Allow previous steps to be skipped, but not fail
  254. needs: linting-done
  255. runs-on: ubuntu-latest
  256. steps:
  257. - uses: actions/checkout@v4
  258. - uses: actions/setup-python@v4
  259. with:
  260. python-version: "3.x"
  261. - id: get-matrix
  262. run: .ci/scripts/calculate_jobs.py
  263. outputs:
  264. trial_test_matrix: ${{ steps.get-matrix.outputs.trial_test_matrix }}
  265. sytest_test_matrix: ${{ steps.get-matrix.outputs.sytest_test_matrix }}
  266. trial:
  267. if: ${{ !cancelled() && !failure() && needs.changes.outputs.trial == 'true' }} # Allow previous steps to be skipped, but not fail
  268. needs:
  269. - calculate-test-jobs
  270. - changes
  271. runs-on: ubuntu-latest
  272. strategy:
  273. matrix:
  274. job: ${{ fromJson(needs.calculate-test-jobs.outputs.trial_test_matrix) }}
  275. steps:
  276. - uses: actions/checkout@v4
  277. - run: sudo apt-get -qq install xmlsec1
  278. - name: Set up PostgreSQL ${{ matrix.job.postgres-version }}
  279. if: ${{ matrix.job.postgres-version }}
  280. # 1. Mount postgres data files onto a tmpfs in-memory filesystem to reduce overhead of docker's overlayfs layer.
  281. # 2. Expose the unix socket for postgres. This removes latency of using docker-proxy for connections.
  282. run: |
  283. docker run -d -p 5432:5432 \
  284. --tmpfs /var/lib/postgres:rw,size=6144m \
  285. --mount 'type=bind,src=/var/run/postgresql,dst=/var/run/postgresql' \
  286. -e POSTGRES_PASSWORD=postgres \
  287. -e POSTGRES_INITDB_ARGS="--lc-collate C --lc-ctype C --encoding UTF8" \
  288. postgres:${{ matrix.job.postgres-version }}
  289. - name: Install Rust
  290. uses: dtolnay/rust-toolchain@1.61.0
  291. - uses: Swatinem/rust-cache@v2
  292. - uses: matrix-org/setup-python-poetry@v1
  293. with:
  294. python-version: ${{ matrix.job.python-version }}
  295. poetry-version: "1.3.2"
  296. extras: ${{ matrix.job.extras }}
  297. - name: Await PostgreSQL
  298. if: ${{ matrix.job.postgres-version }}
  299. timeout-minutes: 2
  300. run: until pg_isready -h localhost; do sleep 1; done
  301. - run: poetry run trial --jobs=6 tests
  302. env:
  303. SYNAPSE_POSTGRES: ${{ matrix.job.database == 'postgres' || '' }}
  304. SYNAPSE_POSTGRES_HOST: /var/run/postgresql
  305. SYNAPSE_POSTGRES_USER: postgres
  306. SYNAPSE_POSTGRES_PASSWORD: postgres
  307. - name: Dump logs
  308. # Logs are most useful when the command fails, always include them.
  309. if: ${{ always() }}
  310. # Note: Dumps to workflow logs instead of using actions/upload-artifact
  311. # This keeps logs colocated with failing jobs
  312. # It also ignores find's exit code; this is a best effort affair
  313. run: >-
  314. find _trial_temp -name '*.log'
  315. -exec echo "::group::{}" \;
  316. -exec cat {} \;
  317. -exec echo "::endgroup::" \;
  318. || true
  319. trial-olddeps:
  320. # Note: sqlite only; no postgres
  321. if: ${{ !cancelled() && !failure() && needs.changes.outputs.trial == 'true' }} # Allow previous steps to be skipped, but not fail
  322. needs:
  323. - linting-done
  324. - changes
  325. runs-on: ubuntu-20.04
  326. steps:
  327. - uses: actions/checkout@v4
  328. - name: Install Rust
  329. uses: dtolnay/rust-toolchain@1.61.0
  330. - uses: Swatinem/rust-cache@v2
  331. # There aren't wheels for some of the older deps, so we need to install
  332. # their build dependencies
  333. - run: |
  334. sudo apt-get -qq update
  335. sudo apt-get -qq install build-essential libffi-dev python-dev \
  336. libxml2-dev libxslt-dev xmlsec1 zlib1g-dev libjpeg-dev libwebp-dev
  337. - uses: actions/setup-python@v4
  338. with:
  339. python-version: '3.8'
  340. - name: Prepare old deps
  341. if: steps.cache-poetry-old-deps.outputs.cache-hit != 'true'
  342. run: .ci/scripts/prepare_old_deps.sh
  343. # Note: we install using `pip` here, not poetry. `poetry install` ignores the
  344. # build-system section (https://github.com/python-poetry/poetry/issues/6154), but
  345. # we explicitly want to test that you can `pip install` using the oldest version
  346. # of poetry-core and setuptools-rust.
  347. - run: pip install .[all,test]
  348. # We nuke the local copy, as we've installed synapse into the virtualenv
  349. # (rather than use an editable install, which we no longer support). If we
  350. # don't do this then python can't find the native lib.
  351. - run: rm -rf synapse/
  352. # Sanity check we can import/run Synapse
  353. - run: python -m synapse.app.homeserver --help
  354. - run: python -m twisted.trial -j6 tests
  355. - name: Dump logs
  356. # Logs are most useful when the command fails, always include them.
  357. if: ${{ always() }}
  358. # Note: Dumps to workflow logs instead of using actions/upload-artifact
  359. # This keeps logs colocated with failing jobs
  360. # It also ignores find's exit code; this is a best effort affair
  361. run: >-
  362. find _trial_temp -name '*.log'
  363. -exec echo "::group::{}" \;
  364. -exec cat {} \;
  365. -exec echo "::endgroup::" \;
  366. || true
  367. trial-pypy:
  368. # Very slow; only run if the branch name includes 'pypy'
  369. # Note: sqlite only; no postgres. Completely untested since poetry move.
  370. if: ${{ contains(github.ref, 'pypy') && !failure() && !cancelled() && needs.changes.outputs.trial == 'true' }}
  371. needs:
  372. - linting-done
  373. - changes
  374. runs-on: ubuntu-latest
  375. strategy:
  376. matrix:
  377. python-version: ["pypy-3.8"]
  378. extras: ["all"]
  379. steps:
  380. - uses: actions/checkout@v4
  381. # Install libs necessary for PyPy to build binary wheels for dependencies
  382. - run: sudo apt-get -qq install xmlsec1 libxml2-dev libxslt-dev
  383. - uses: matrix-org/setup-python-poetry@v1
  384. with:
  385. python-version: ${{ matrix.python-version }}
  386. poetry-version: "1.3.2"
  387. extras: ${{ matrix.extras }}
  388. - run: poetry run trial --jobs=2 tests
  389. - name: Dump logs
  390. # Logs are most useful when the command fails, always include them.
  391. if: ${{ always() }}
  392. # Note: Dumps to workflow logs instead of using actions/upload-artifact
  393. # This keeps logs colocated with failing jobs
  394. # It also ignores find's exit code; this is a best effort affair
  395. run: >-
  396. find _trial_temp -name '*.log'
  397. -exec echo "::group::{}" \;
  398. -exec cat {} \;
  399. -exec echo "::endgroup::" \;
  400. || true
  401. sytest:
  402. if: ${{ !failure() && !cancelled() && needs.changes.outputs.integration == 'true' }}
  403. needs:
  404. - calculate-test-jobs
  405. - changes
  406. runs-on: ubuntu-latest
  407. container:
  408. image: matrixdotorg/sytest-synapse:${{ matrix.job.sytest-tag }}
  409. volumes:
  410. - ${{ github.workspace }}:/src
  411. env:
  412. SYTEST_BRANCH: ${{ github.head_ref }}
  413. POSTGRES: ${{ matrix.job.postgres && 1}}
  414. MULTI_POSTGRES: ${{ (matrix.job.postgres == 'multi-postgres') || '' }}
  415. ASYNCIO_REACTOR: ${{ (matrix.job.reactor == 'asyncio') || '' }}
  416. WORKERS: ${{ matrix.job.workers && 1 }}
  417. BLACKLIST: ${{ matrix.job.workers && 'synapse-blacklist-with-workers' }}
  418. TOP: ${{ github.workspace }}
  419. strategy:
  420. fail-fast: false
  421. matrix:
  422. job: ${{ fromJson(needs.calculate-test-jobs.outputs.sytest_test_matrix) }}
  423. steps:
  424. - uses: actions/checkout@v4
  425. - name: Prepare test blacklist
  426. run: cat sytest-blacklist .ci/worker-blacklist > synapse-blacklist-with-workers
  427. - name: Install Rust
  428. uses: dtolnay/rust-toolchain@1.61.0
  429. - uses: Swatinem/rust-cache@v2
  430. - name: Run SyTest
  431. run: /bootstrap.sh synapse
  432. working-directory: /src
  433. - name: Summarise results.tap
  434. if: ${{ always() }}
  435. run: /sytest/scripts/tap_to_gha.pl /logs/results.tap
  436. - name: Upload SyTest logs
  437. uses: actions/upload-artifact@v3
  438. if: ${{ always() }}
  439. with:
  440. name: Sytest Logs - ${{ job.status }} - (${{ join(matrix.job.*, ', ') }})
  441. path: |
  442. /logs/results.tap
  443. /logs/**/*.log*
  444. export-data:
  445. if: ${{ !failure() && !cancelled() && needs.changes.outputs.integration == 'true'}} # Allow previous steps to be skipped, but not fail
  446. needs: [linting-done, portdb, changes]
  447. runs-on: ubuntu-latest
  448. env:
  449. TOP: ${{ github.workspace }}
  450. services:
  451. postgres:
  452. image: postgres
  453. ports:
  454. - 5432:5432
  455. env:
  456. POSTGRES_PASSWORD: "postgres"
  457. POSTGRES_INITDB_ARGS: "--lc-collate C --lc-ctype C --encoding UTF8"
  458. options: >-
  459. --health-cmd pg_isready
  460. --health-interval 10s
  461. --health-timeout 5s
  462. --health-retries 5
  463. steps:
  464. - uses: actions/checkout@v4
  465. - run: sudo apt-get -qq install xmlsec1 postgresql-client
  466. - uses: matrix-org/setup-python-poetry@v1
  467. with:
  468. poetry-version: "1.3.2"
  469. extras: "postgres"
  470. - run: .ci/scripts/test_export_data_command.sh
  471. env:
  472. PGHOST: localhost
  473. PGUSER: postgres
  474. PGPASSWORD: postgres
  475. PGDATABASE: postgres
  476. portdb:
  477. if: ${{ !failure() && !cancelled() && needs.changes.outputs.integration == 'true'}} # Allow previous steps to be skipped, but not fail
  478. needs:
  479. - linting-done
  480. - changes
  481. runs-on: ubuntu-latest
  482. strategy:
  483. matrix:
  484. include:
  485. - python-version: "3.8"
  486. postgres-version: "11"
  487. - python-version: "3.11"
  488. postgres-version: "15"
  489. services:
  490. postgres:
  491. image: postgres:${{ matrix.postgres-version }}
  492. ports:
  493. - 5432:5432
  494. env:
  495. POSTGRES_PASSWORD: "postgres"
  496. POSTGRES_INITDB_ARGS: "--lc-collate C --lc-ctype C --encoding UTF8"
  497. options: >-
  498. --health-cmd pg_isready
  499. --health-interval 10s
  500. --health-timeout 5s
  501. --health-retries 5
  502. steps:
  503. - uses: actions/checkout@v4
  504. - name: Add PostgreSQL apt repository
  505. # We need a version of pg_dump that can handle the version of
  506. # PostgreSQL being tested against. The Ubuntu package repository lags
  507. # behind new releases, so we have to use the PostreSQL apt repository.
  508. # Steps taken from https://www.postgresql.org/download/linux/ubuntu/
  509. run: |
  510. sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
  511. wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
  512. sudo apt-get update
  513. - run: sudo apt-get -qq install xmlsec1 postgresql-client
  514. - uses: matrix-org/setup-python-poetry@v1
  515. with:
  516. python-version: ${{ matrix.python-version }}
  517. poetry-version: "1.3.2"
  518. extras: "postgres"
  519. - run: .ci/scripts/test_synapse_port_db.sh
  520. id: run_tester_script
  521. env:
  522. PGHOST: localhost
  523. PGUSER: postgres
  524. PGPASSWORD: postgres
  525. PGDATABASE: postgres
  526. - name: "Upload schema differences"
  527. uses: actions/upload-artifact@v3
  528. if: ${{ failure() && !cancelled() && steps.run_tester_script.outcome == 'failure' }}
  529. with:
  530. name: Schema dumps
  531. path: |
  532. unported.sql
  533. ported.sql
  534. schema_diff
  535. complement:
  536. if: "${{ !failure() && !cancelled() && needs.changes.outputs.integration == 'true' }}"
  537. needs:
  538. - linting-done
  539. - changes
  540. runs-on: ubuntu-latest
  541. strategy:
  542. fail-fast: false
  543. matrix:
  544. include:
  545. - arrangement: monolith
  546. database: SQLite
  547. - arrangement: monolith
  548. database: Postgres
  549. - arrangement: workers
  550. database: Postgres
  551. steps:
  552. - name: Run actions/checkout@v4 for synapse
  553. uses: actions/checkout@v4
  554. with:
  555. path: synapse
  556. - name: Install Rust
  557. uses: dtolnay/rust-toolchain@1.61.0
  558. - uses: Swatinem/rust-cache@v2
  559. - name: Prepare Complement's Prerequisites
  560. run: synapse/.ci/scripts/setup_complement_prerequisites.sh
  561. - uses: actions/setup-go@v4
  562. with:
  563. cache-dependency-path: complement/go.sum
  564. go-version-file: complement/go.mod
  565. # use p=1 concurrency as GHA boxes are underpowered and don't like running tons of synapses at once.
  566. - run: |
  567. set -o pipefail
  568. COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -p 1 -json 2>&1 | synapse/.ci/scripts/gotestfmt
  569. shell: bash
  570. env:
  571. POSTGRES: ${{ (matrix.database == 'Postgres') && 1 || '' }}
  572. WORKERS: ${{ (matrix.arrangement == 'workers') && 1 || '' }}
  573. name: Run Complement Tests
  574. cargo-test:
  575. if: ${{ needs.changes.outputs.rust == 'true' }}
  576. runs-on: ubuntu-latest
  577. needs:
  578. - linting-done
  579. - changes
  580. steps:
  581. - uses: actions/checkout@v4
  582. - name: Install Rust
  583. uses: dtolnay/rust-toolchain@1.61.0
  584. - uses: Swatinem/rust-cache@v2
  585. - run: cargo test
  586. # We want to ensure that the cargo benchmarks still compile, which requires a
  587. # nightly compiler.
  588. cargo-bench:
  589. if: ${{ needs.changes.outputs.rust == 'true' }}
  590. runs-on: ubuntu-latest
  591. needs:
  592. - linting-done
  593. - changes
  594. steps:
  595. - uses: actions/checkout@v4
  596. - name: Install Rust
  597. uses: dtolnay/rust-toolchain@master
  598. with:
  599. toolchain: nightly-2022-12-01
  600. - uses: Swatinem/rust-cache@v2
  601. - run: cargo bench --no-run
  602. # a job which marks all the other jobs as complete, thus allowing PRs to be merged.
  603. tests-done:
  604. if: ${{ always() }}
  605. needs:
  606. - trial
  607. - trial-olddeps
  608. - sytest
  609. - export-data
  610. - portdb
  611. - complement
  612. - cargo-test
  613. - cargo-bench
  614. runs-on: ubuntu-latest
  615. steps:
  616. - uses: matrix-org/done-action@v2
  617. with:
  618. needs: ${{ toJSON(needs) }}
  619. # Various bits are skipped if there was no applicable changes.
  620. # The newsfile and signoff lint may be skipped on non PR builds.
  621. skippable: |
  622. trial
  623. trial-olddeps
  624. sytest
  625. portdb
  626. export-data
  627. complement
  628. check-signoff
  629. lint-newsfile
  630. cargo-test
  631. cargo-bench