Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

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