Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

422 linhas
14 KiB

  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 -e .
  16. - run: scripts-dev/generate_sample_config.sh --check
  17. - run: scripts-dev/config-lint.sh
  18. lint:
  19. runs-on: ubuntu-latest
  20. strategy:
  21. matrix:
  22. toxenv:
  23. - "check_codestyle"
  24. - "check_isort"
  25. - "mypy"
  26. - "packaging"
  27. steps:
  28. - uses: actions/checkout@v2
  29. - uses: actions/setup-python@v2
  30. - run: pip install tox
  31. - run: tox -e ${{ matrix.toxenv }}
  32. lint-crlf:
  33. runs-on: ubuntu-latest
  34. steps:
  35. - uses: actions/checkout@v2
  36. - name: Check line endings
  37. run: scripts-dev/check_line_terminators.sh
  38. lint-newsfile:
  39. if: ${{ github.base_ref == 'develop' || contains(github.base_ref, 'release-') }}
  40. runs-on: ubuntu-latest
  41. steps:
  42. - uses: actions/checkout@v2
  43. with:
  44. ref: ${{ github.event.pull_request.head.sha }}
  45. fetch-depth: 0
  46. - uses: actions/setup-python@v2
  47. - run: "pip install 'towncrier>=18.6.0rc1'"
  48. - run: scripts-dev/check-newsfragment.sh
  49. env:
  50. PULL_REQUEST_NUMBER: ${{ github.event.number }}
  51. # Dummy step to gate other tests on without repeating the whole list
  52. linting-done:
  53. if: ${{ !cancelled() }} # Run this even if prior jobs were skipped
  54. needs: [lint, lint-crlf, lint-newsfile, check-sampleconfig]
  55. runs-on: ubuntu-latest
  56. steps:
  57. - run: "true"
  58. trial:
  59. if: ${{ !cancelled() && !failure() }} # Allow previous steps to be skipped, but not fail
  60. needs: linting-done
  61. runs-on: ubuntu-latest
  62. strategy:
  63. matrix:
  64. python-version: ["3.7", "3.8", "3.9", "3.10"]
  65. database: ["sqlite"]
  66. toxenv: ["py"]
  67. include:
  68. # Newest Python without optional deps
  69. - python-version: "3.10"
  70. toxenv: "py-noextras"
  71. # Oldest Python with PostgreSQL
  72. - python-version: "3.7"
  73. database: "postgres"
  74. postgres-version: "10"
  75. toxenv: "py"
  76. # Newest Python with newest PostgreSQL
  77. - python-version: "3.10"
  78. database: "postgres"
  79. postgres-version: "14"
  80. toxenv: "py"
  81. steps:
  82. - uses: actions/checkout@v2
  83. - run: sudo apt-get -qq install xmlsec1
  84. - name: Set up PostgreSQL ${{ matrix.postgres-version }}
  85. if: ${{ matrix.postgres-version }}
  86. run: |
  87. docker run -d -p 5432:5432 \
  88. -e POSTGRES_PASSWORD=postgres \
  89. -e POSTGRES_INITDB_ARGS="--lc-collate C --lc-ctype C --encoding UTF8" \
  90. postgres:${{ matrix.postgres-version }}
  91. - uses: actions/setup-python@v2
  92. with:
  93. python-version: ${{ matrix.python-version }}
  94. - run: pip install tox
  95. - name: Await PostgreSQL
  96. if: ${{ matrix.postgres-version }}
  97. timeout-minutes: 2
  98. run: until pg_isready -h localhost; do sleep 1; done
  99. - run: tox -e ${{ matrix.toxenv }}
  100. env:
  101. TRIAL_FLAGS: "--jobs=2"
  102. SYNAPSE_POSTGRES: ${{ matrix.database == 'postgres' || '' }}
  103. SYNAPSE_POSTGRES_HOST: localhost
  104. SYNAPSE_POSTGRES_USER: postgres
  105. SYNAPSE_POSTGRES_PASSWORD: postgres
  106. - name: Dump logs
  107. # Logs are most useful when the command fails, always include them.
  108. if: ${{ always() }}
  109. # Note: Dumps to workflow logs instead of using actions/upload-artifact
  110. # This keeps logs colocated with failing jobs
  111. # It also ignores find's exit code; this is a best effort affair
  112. run: >-
  113. find _trial_temp -name '*.log'
  114. -exec echo "::group::{}" \;
  115. -exec cat {} \;
  116. -exec echo "::endgroup::" \;
  117. || true
  118. trial-olddeps:
  119. if: ${{ !cancelled() && !failure() }} # Allow previous steps to be skipped, but not fail
  120. needs: linting-done
  121. runs-on: ubuntu-latest
  122. steps:
  123. - uses: actions/checkout@v2
  124. - name: Test with old deps
  125. uses: docker://ubuntu:focal # For old python and sqlite
  126. with:
  127. workdir: /github/workspace
  128. entrypoint: .ci/scripts/test_old_deps.sh
  129. env:
  130. TRIAL_FLAGS: "--jobs=2"
  131. - name: Dump logs
  132. # Logs are most useful when the command fails, always include them.
  133. if: ${{ always() }}
  134. # Note: Dumps to workflow logs instead of using actions/upload-artifact
  135. # This keeps logs colocated with failing jobs
  136. # It also ignores find's exit code; this is a best effort affair
  137. run: >-
  138. find _trial_temp -name '*.log'
  139. -exec echo "::group::{}" \;
  140. -exec cat {} \;
  141. -exec echo "::endgroup::" \;
  142. || true
  143. trial-pypy:
  144. # Very slow; only run if the branch name includes 'pypy'
  145. if: ${{ contains(github.ref, 'pypy') && !failure() && !cancelled() }}
  146. needs: linting-done
  147. runs-on: ubuntu-latest
  148. strategy:
  149. matrix:
  150. python-version: ["pypy-3.7"]
  151. steps:
  152. - uses: actions/checkout@v2
  153. - run: sudo apt-get -qq install xmlsec1 libxml2-dev libxslt-dev
  154. - uses: actions/setup-python@v2
  155. with:
  156. python-version: ${{ matrix.python-version }}
  157. - run: pip install tox
  158. - run: tox -e py
  159. env:
  160. TRIAL_FLAGS: "--jobs=2"
  161. - name: Dump logs
  162. # Logs are most useful when the command fails, always include them.
  163. if: ${{ always() }}
  164. # Note: Dumps to workflow logs instead of using actions/upload-artifact
  165. # This keeps logs colocated with failing jobs
  166. # It also ignores find's exit code; this is a best effort affair
  167. run: >-
  168. find _trial_temp -name '*.log'
  169. -exec echo "::group::{}" \;
  170. -exec cat {} \;
  171. -exec echo "::endgroup::" \;
  172. || true
  173. sytest:
  174. if: ${{ !failure() && !cancelled() }}
  175. needs: linting-done
  176. runs-on: ubuntu-latest
  177. container:
  178. image: matrixdotorg/sytest-synapse:${{ matrix.sytest-tag }}
  179. volumes:
  180. - ${{ github.workspace }}:/src
  181. env:
  182. SYTEST_BRANCH: ${{ github.head_ref }}
  183. POSTGRES: ${{ matrix.postgres && 1}}
  184. MULTI_POSTGRES: ${{ (matrix.postgres == 'multi-postgres') && 1}}
  185. WORKERS: ${{ matrix.workers && 1 }}
  186. REDIS: ${{ matrix.redis && 1 }}
  187. BLACKLIST: ${{ matrix.workers && 'synapse-blacklist-with-workers' }}
  188. TOP: ${{ github.workspace }}
  189. strategy:
  190. fail-fast: false
  191. matrix:
  192. include:
  193. - sytest-tag: focal
  194. - sytest-tag: focal
  195. postgres: postgres
  196. - sytest-tag: testing
  197. postgres: postgres
  198. - sytest-tag: focal
  199. postgres: multi-postgres
  200. workers: workers
  201. - sytest-tag: buster
  202. postgres: multi-postgres
  203. workers: workers
  204. - sytest-tag: buster
  205. postgres: postgres
  206. workers: workers
  207. redis: redis
  208. steps:
  209. - uses: actions/checkout@v2
  210. - name: Prepare test blacklist
  211. run: cat sytest-blacklist .ci/worker-blacklist > synapse-blacklist-with-workers
  212. - name: Run SyTest
  213. run: /bootstrap.sh synapse
  214. working-directory: /src
  215. - name: Summarise results.tap
  216. if: ${{ always() }}
  217. run: /sytest/scripts/tap_to_gha.pl /logs/results.tap
  218. - name: Upload SyTest logs
  219. uses: actions/upload-artifact@v2
  220. if: ${{ always() }}
  221. with:
  222. name: Sytest Logs - ${{ job.status }} - (${{ join(matrix.*, ', ') }})
  223. path: |
  224. /logs/results.tap
  225. /logs/**/*.log*
  226. export-data:
  227. if: ${{ !failure() && !cancelled() }} # Allow previous steps to be skipped, but not fail
  228. needs: [linting-done, portdb]
  229. runs-on: ubuntu-latest
  230. env:
  231. TOP: ${{ github.workspace }}
  232. services:
  233. postgres:
  234. image: postgres
  235. ports:
  236. - 5432:5432
  237. env:
  238. POSTGRES_PASSWORD: "postgres"
  239. POSTGRES_INITDB_ARGS: "--lc-collate C --lc-ctype C --encoding UTF8"
  240. options: >-
  241. --health-cmd pg_isready
  242. --health-interval 10s
  243. --health-timeout 5s
  244. --health-retries 5
  245. steps:
  246. - uses: actions/checkout@v2
  247. - run: sudo apt-get -qq install xmlsec1
  248. - uses: actions/setup-python@v2
  249. with:
  250. python-version: "3.9"
  251. - run: .ci/scripts/test_export_data_command.sh
  252. portdb:
  253. if: ${{ !failure() && !cancelled() }} # Allow previous steps to be skipped, but not fail
  254. needs: linting-done
  255. runs-on: ubuntu-latest
  256. env:
  257. TOP: ${{ github.workspace }}
  258. strategy:
  259. matrix:
  260. include:
  261. - python-version: "3.7"
  262. postgres-version: "10"
  263. - python-version: "3.10"
  264. postgres-version: "14"
  265. services:
  266. postgres:
  267. image: postgres:${{ matrix.postgres-version }}
  268. ports:
  269. - 5432:5432
  270. env:
  271. POSTGRES_PASSWORD: "postgres"
  272. POSTGRES_INITDB_ARGS: "--lc-collate C --lc-ctype C --encoding UTF8"
  273. options: >-
  274. --health-cmd pg_isready
  275. --health-interval 10s
  276. --health-timeout 5s
  277. --health-retries 5
  278. steps:
  279. - uses: actions/checkout@v2
  280. - run: sudo apt-get -qq install xmlsec1
  281. - uses: actions/setup-python@v2
  282. with:
  283. python-version: ${{ matrix.python-version }}
  284. - run: .ci/scripts/test_synapse_port_db.sh
  285. complement:
  286. if: ${{ !failure() && !cancelled() }}
  287. needs: linting-done
  288. runs-on: ubuntu-latest
  289. steps:
  290. # The path is set via a file given by $GITHUB_PATH. We need both Go 1.17 and GOPATH on the path to run Complement.
  291. # See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-system-path
  292. - name: "Set Go Version"
  293. run: |
  294. # Add Go 1.17 to the PATH: see https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md#environment-variables-2
  295. echo "$GOROOT_1_17_X64/bin" >> $GITHUB_PATH
  296. # Add the Go path to the PATH: We need this so we can call gotestfmt
  297. echo "~/go/bin" >> $GITHUB_PATH
  298. - name: "Install Complement Dependencies"
  299. run: |
  300. sudo apt-get update && sudo apt-get install -y libolm3 libolm-dev
  301. go get -v github.com/haveyoudebuggedit/gotestfmt/v2/cmd/gotestfmt@latest
  302. - name: Run actions/checkout@v2 for synapse
  303. uses: actions/checkout@v2
  304. with:
  305. path: synapse
  306. # Attempt to check out the same branch of Complement as the PR. If it
  307. # doesn't exist, fallback to HEAD.
  308. - name: Checkout complement
  309. shell: bash
  310. run: |
  311. mkdir -p complement
  312. # Attempt to use the version of complement which best matches the current
  313. # build. Depending on whether this is a PR or release, etc. we need to
  314. # use different fallbacks.
  315. #
  316. # 1. First check if there's a similarly named branch (GITHUB_HEAD_REF
  317. # for pull requests, otherwise GITHUB_REF).
  318. # 2. Attempt to use the base branch, e.g. when merging into release-vX.Y
  319. # (GITHUB_BASE_REF for pull requests).
  320. # 3. Use the default complement branch ("HEAD").
  321. for BRANCH_NAME in "$GITHUB_HEAD_REF" "$GITHUB_BASE_REF" "${GITHUB_REF#refs/heads/}" "HEAD"; do
  322. # Skip empty branch names and merge commits.
  323. if [[ -z "$BRANCH_NAME" || $BRANCH_NAME =~ ^refs/pull/.* ]]; then
  324. continue
  325. fi
  326. (wget -O - "https://github.com/matrix-org/complement/archive/$BRANCH_NAME.tar.gz" | tar -xz --strip-components=1 -C complement) && break
  327. done
  328. # Build initial Synapse image
  329. - run: docker build -t matrixdotorg/synapse:latest -f docker/Dockerfile .
  330. working-directory: synapse
  331. env:
  332. DOCKER_BUILDKIT: 1
  333. # Build a ready-to-run Synapse image based on the initial image above.
  334. # This new image includes a config file, keys for signing and TLS, and
  335. # other settings to make it suitable for testing under Complement.
  336. - run: docker build -t complement-synapse -f Synapse.Dockerfile .
  337. working-directory: complement/dockerfiles
  338. # Run Complement
  339. - run: |
  340. set -o pipefail
  341. go test -v -json -p 1 -tags synapse_blacklist,msc2403,msc2716,msc3030 ./tests/... 2>&1 | gotestfmt
  342. shell: bash
  343. name: Run Complement Tests
  344. env:
  345. COMPLEMENT_BASE_IMAGE: complement-synapse:latest
  346. working-directory: complement
  347. # a job which marks all the other jobs as complete, thus allowing PRs to be merged.
  348. tests-done:
  349. if: ${{ always() }}
  350. needs:
  351. - lint
  352. - lint-crlf
  353. - lint-newsfile
  354. - trial
  355. - trial-olddeps
  356. - sytest
  357. - portdb
  358. - complement
  359. runs-on: ubuntu-latest
  360. steps:
  361. - name: Set build result
  362. env:
  363. NEEDS_CONTEXT: ${{ toJSON(needs) }}
  364. # the `jq` incantation dumps out a series of "<job> <result>" lines.
  365. # we set it to an intermediate variable to avoid a pipe, which makes it
  366. # hard to set $rc.
  367. run: |
  368. rc=0
  369. results=$(jq -r 'to_entries[] | [.key,.value.result] | join(" ")' <<< $NEEDS_CONTEXT)
  370. while read job result ; do
  371. # The newsfile lint may be skipped on non PR builds
  372. if [ $result == "skipped" ] && [ $job == "lint-newsfile" ]; then
  373. continue
  374. fi
  375. if [ "$result" != "success" ]; then
  376. echo "::set-failed ::Job $job returned $result"
  377. rc=1
  378. fi
  379. done <<< $results
  380. exit $rc