test.yml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. name: Wagtail CI
  2. on:
  3. push:
  4. paths-ignore:
  5. - 'docs/**'
  6. pull_request:
  7. paths-ignore:
  8. - 'docs/**'
  9. concurrency:
  10. group: ${{ github.workflow }}-${{ github.ref }}
  11. cancel-in-progress: true
  12. # Our test suite should cover:
  13. # - all supported databases against current Python and Django
  14. # - at least one test run for each older supported version of Python and Django
  15. # - at least one test run for each supported Elasticsearch version
  16. # - a test run against Django's git main and active stable branch (allowing failures)
  17. # - test runs with USE_EMAIL_USER_MODEL=yes and DISABLE_TIMEZONE=yes
  18. # Current configuration:
  19. # - django 3.2, python 3.8, postgres:12, parallel
  20. # - django 3.2, python 3.9, mysql:8.0
  21. # - django 4.1, python 3.10, sqlite
  22. # - django 4.2, python 3.11, mysql:8.1, parallel
  23. # - django 4.1, python 3.11, postgres:12, parallel, USE_EMAIL_USER_MODEL=yes
  24. # - django 4.2, python 3.12, postgres:15, parallel, DISABLE_TIMEZONE=yes
  25. # - django stable/5.0.x, python 3.10, postgres (allow failures)
  26. # - django main, python 3.10, postgres:latest, parallel (allow failures)
  27. # - elasticsearch 7, django 3.2, python 3.8, postgres:latest
  28. # - opensearch 2, django 4.1, python 3.9, sqlite
  29. # - elasticsearch 8, django 4.2, python 3.10, sqlite, USE_EMAIL_USER_MODEL=yes
  30. # Some tests are run in parallel by passing --parallel to runtests.py.
  31. # When running tests in parallel, some errors cannot be pickled and result in
  32. # non-helpful tracebacks (see https://code.djangoproject.com/ticket/29023).
  33. # Thus, we keep one test run without --parallel for each supported database.
  34. # ElasticSearch tests are not run in parallel as the test suite is not thread-safe.
  35. permissions:
  36. contents: read # to fetch code (actions/checkout)
  37. jobs:
  38. test-sqlite:
  39. runs-on: ubuntu-latest
  40. strategy:
  41. matrix:
  42. include:
  43. - python: '3.10'
  44. django: 'Django>=4.1,<4.2'
  45. steps:
  46. - uses: actions/checkout@v3
  47. - name: Set up Python ${{ matrix.python }}
  48. uses: actions/setup-python@v4
  49. with:
  50. python-version: ${{ matrix.python }}
  51. cache: 'pip'
  52. - name: Install dependencies
  53. run: |
  54. python -m pip install --upgrade pip
  55. pip install -e '.[testing]' --config-settings editable_mode=strict
  56. pip install "${{ matrix.django }}"
  57. - name: Test
  58. run: |
  59. coverage run --parallel-mode --source wagtail runtests.py
  60. env:
  61. DATABASE_ENGINE: django.db.backends.sqlite3
  62. - name: Upload coverage data
  63. uses: actions/upload-artifact@v3
  64. with:
  65. name: coverage-data
  66. path: .coverage.*
  67. test-postgres:
  68. runs-on: ubuntu-latest
  69. continue-on-error: ${{ matrix.experimental }}
  70. strategy:
  71. matrix:
  72. include:
  73. - python: '3.8'
  74. django: 'Django>=3.2,<3.3'
  75. experimental: false
  76. parallel: '--parallel'
  77. - python: '3.11'
  78. django: 'Django>=4.1,<4.2'
  79. experimental: false
  80. emailuser: emailuser
  81. parallel: '--parallel'
  82. - python: '3.12'
  83. django: 'Django>=4.2,<4.3'
  84. postgres: 'postgres:15'
  85. notz: notz
  86. experimental: false
  87. parallel: '--parallel'
  88. - python: '3.10'
  89. django: 'git+https://github.com/django/django.git@stable/5.0.x#egg=Django'
  90. experimental: true
  91. - python: '3.10'
  92. django: 'git+https://github.com/django/django.git@main#egg=Django'
  93. experimental: true
  94. postgres: 'postgres:latest'
  95. parallel: '--parallel'
  96. install_extras: |
  97. pip uninstall -y django-taggit
  98. pip install \
  99. git+https://github.com/laymonage/django-taggit.git@django-5.1#egg=django-taggit
  100. services:
  101. postgres:
  102. image: ${{ matrix.postgres || 'postgres:12' }}
  103. env:
  104. POSTGRES_PASSWORD: postgres
  105. ports:
  106. - 5432:5432
  107. options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
  108. steps:
  109. - uses: actions/checkout@v3
  110. - name: Set up Python ${{ matrix.python }}
  111. uses: actions/setup-python@v4
  112. with:
  113. python-version: ${{ matrix.python }}
  114. cache: 'pip'
  115. - name: Install dependencies
  116. run: |
  117. python -m pip install --upgrade pip
  118. pip install "psycopg2>=2.6"
  119. pip install -e '.[testing]' --config-settings editable_mode=strict
  120. pip install "${{ matrix.django }}"
  121. ${{ matrix.install_extras }}
  122. - name: Test
  123. run: |
  124. coverage run --parallel-mode --source wagtail runtests.py ${{ matrix.parallel }}
  125. env:
  126. DATABASE_ENGINE: django.db.backends.postgresql
  127. DATABASE_HOST: localhost
  128. DATABASE_USER: postgres
  129. DATABASE_PASSWORD: postgres
  130. USE_EMAIL_USER_MODEL: ${{ matrix.emailuser }}
  131. DISABLE_TIMEZONE: ${{ matrix.notz }}
  132. - name: Upload coverage data
  133. uses: actions/upload-artifact@v3
  134. with:
  135. name: coverage-data
  136. path: .coverage.*
  137. test-mysql:
  138. runs-on: ubuntu-latest
  139. continue-on-error: ${{ matrix.experimental }}
  140. strategy:
  141. matrix:
  142. include:
  143. - python: '3.9'
  144. django: 'Django>=3.2,<3.3'
  145. experimental: false
  146. - python: '3.11'
  147. django: 'Django>=4.2,<4.3'
  148. experimental: false
  149. parallel: '--parallel'
  150. mysql: 'mysql:8.1'
  151. services:
  152. mysql:
  153. image: ${{ matrix.mysql || 'mysql:8.0' }}
  154. env:
  155. MYSQL_ALLOW_EMPTY_PASSWORD: yes
  156. MYSQL_DATABASE: wagtail
  157. ports:
  158. - 3306:3306
  159. options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 --cap-add=sys_nice
  160. steps:
  161. - uses: actions/checkout@v3
  162. - name: Set up Python ${{ matrix.python }}
  163. uses: actions/setup-python@v4
  164. with:
  165. python-version: ${{ matrix.python }}
  166. cache: 'pip'
  167. - name: Install dependencies
  168. run: |
  169. python -m pip install --upgrade pip
  170. pip install "mysqlclient>=1.4,<2"
  171. pip install -e '.[testing]' --config-settings editable_mode=strict
  172. pip install "${{ matrix.django }}"
  173. - name: Test
  174. run: |
  175. coverage run --parallel-mode --source wagtail runtests.py ${{ matrix.parallel }}
  176. env:
  177. DATABASE_ENGINE: django.db.backends.mysql
  178. DATABASE_HOST: '127.0.0.1'
  179. DATABASE_USER: root
  180. - name: Upload coverage data
  181. uses: actions/upload-artifact@v3
  182. with:
  183. name: coverage-data
  184. path: .coverage.*
  185. test-sqlite-elasticsearch8:
  186. runs-on: ubuntu-latest
  187. strategy:
  188. matrix:
  189. include:
  190. - python: '3.10'
  191. django: 'Django>=4.2,<4.3'
  192. emailuser: emailuser
  193. steps:
  194. - name: Configure sysctl limits
  195. run: |
  196. sudo swapoff -a
  197. sudo sysctl -w vm.swappiness=1
  198. sudo sysctl -w fs.file-max=262144
  199. sudo sysctl -w vm.max_map_count=262144
  200. - uses: getong/elasticsearch-action@v1.2
  201. with:
  202. elasticsearch version: 8.8.0
  203. host port: 9200
  204. container port: 9200
  205. host node port: 9300
  206. node port: 9300
  207. discovery type: 'single-node'
  208. - uses: actions/checkout@v3
  209. - name: Set up Python ${{ matrix.python }}
  210. uses: actions/setup-python@v4
  211. with:
  212. python-version: ${{ matrix.python }}
  213. cache: 'pip'
  214. - name: Install dependencies
  215. run: |
  216. python -m pip install --upgrade pip
  217. pip install -e '.[testing]' --config-settings editable_mode=strict
  218. pip install "${{ matrix.django }}"
  219. pip install "elasticsearch>=8,<9"
  220. pip install certifi
  221. - name: Test
  222. run: |
  223. coverage run --parallel-mode --source wagtail runtests.py wagtail.search wagtail.documents wagtail.images --elasticsearch8
  224. env:
  225. DATABASE_ENGINE: django.db.backends.sqlite3
  226. USE_EMAIL_USER_MODEL: ${{ matrix.emailuser }}
  227. - name: Upload coverage data
  228. uses: actions/upload-artifact@v3
  229. with:
  230. name: coverage-data
  231. path: .coverage.*
  232. test-postgres-elasticsearch7:
  233. runs-on: ubuntu-latest
  234. continue-on-error: ${{ matrix.experimental }}
  235. strategy:
  236. matrix:
  237. include:
  238. - python: '3.8'
  239. django: 'Django>=3.2,<3.3'
  240. experimental: false
  241. services:
  242. postgres:
  243. image: postgres:latest
  244. env:
  245. POSTGRES_PASSWORD: postgres
  246. ports:
  247. - 5432:5432
  248. options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
  249. steps:
  250. - name: Configure sysctl limits
  251. run: |
  252. sudo swapoff -a
  253. sudo sysctl -w vm.swappiness=1
  254. sudo sysctl -w fs.file-max=262144
  255. sudo sysctl -w vm.max_map_count=262144
  256. - uses: elastic/elastic-github-actions/elasticsearch@master
  257. with:
  258. stack-version: 7.6.1
  259. - uses: actions/checkout@v3
  260. - name: Set up Python ${{ matrix.python }}
  261. uses: actions/setup-python@v4
  262. with:
  263. python-version: ${{ matrix.python }}
  264. cache: 'pip'
  265. - name: Install dependencies
  266. run: |
  267. python -m pip install --upgrade pip
  268. pip install "psycopg2>=2.6"
  269. pip install -e '.[testing]' --config-settings editable_mode=strict
  270. pip install "${{ matrix.django }}"
  271. pip install "elasticsearch>=7,<8"
  272. pip install certifi
  273. - name: Test
  274. run: |
  275. coverage run --parallel-mode --source wagtail runtests.py wagtail.search wagtail.documents wagtail.images --elasticsearch7
  276. env:
  277. DATABASE_ENGINE: django.db.backends.postgresql
  278. DATABASE_HOST: localhost
  279. DATABASE_USER: postgres
  280. DATABASE_PASSWORD: postgres
  281. USE_EMAIL_USER_MODEL: ${{ matrix.emailuser }}
  282. - name: Upload coverage data
  283. uses: actions/upload-artifact@v3
  284. with:
  285. name: coverage-data
  286. path: .coverage.*
  287. test-sqlite-opensearch2:
  288. runs-on: ubuntu-latest
  289. continue-on-error: ${{ matrix.experimental }}
  290. strategy:
  291. matrix:
  292. include:
  293. - python: '3.9'
  294. django: 'Django>=4.1,<4.2'
  295. experimental: false
  296. steps:
  297. - name: Configure sysctl limits
  298. run: |
  299. sudo swapoff -a
  300. sudo sysctl -w vm.swappiness=1
  301. sudo sysctl -w fs.file-max=262144
  302. sudo sysctl -w vm.max_map_count=262144
  303. - uses: ankane/setup-opensearch@v1
  304. with:
  305. opensearch-version: 2
  306. - uses: actions/checkout@v3
  307. - name: Set up Python ${{ matrix.python }}
  308. uses: actions/setup-python@v4
  309. with:
  310. python-version: ${{ matrix.python }}
  311. cache: 'pip'
  312. - name: Install dependencies
  313. run: |
  314. python -m pip install --upgrade pip
  315. pip install -e '.[testing]' --config-settings editable_mode=strict
  316. pip install "${{ matrix.django }}"
  317. pip install "elasticsearch==7.13.4"
  318. pip install certifi
  319. - name: Test
  320. run: |
  321. coverage run --parallel-mode --source wagtail runtests.py wagtail.search wagtail.documents wagtail.images --elasticsearch7
  322. env:
  323. DATABASE_ENGINE: django.db.backends.sqlite3
  324. USE_EMAIL_USER_MODEL: ${{ matrix.emailuser }}
  325. - name: Upload coverage data
  326. uses: actions/upload-artifact@v3
  327. with:
  328. name: coverage-data
  329. path: .coverage.*
  330. coverage:
  331. needs:
  332. - test-sqlite
  333. - test-postgres
  334. - test-mysql
  335. - test-sqlite-elasticsearch8
  336. - test-postgres-elasticsearch7
  337. - test-sqlite-opensearch2
  338. runs-on: ubuntu-latest
  339. steps:
  340. - name: Check out the repo
  341. uses: actions/checkout@v3
  342. - name: Set up Python
  343. uses: actions/setup-python@v4
  344. with:
  345. python-version: '3.10'
  346. - name: Install dependencies
  347. run: |
  348. python -m pip install --upgrade pip
  349. pip install coverage
  350. - name: Download coverage data
  351. uses: actions/download-artifact@v3
  352. with:
  353. name: coverage-data
  354. - name: Combine coverage data
  355. run: |
  356. coverage combine
  357. - name: Generate coverage report
  358. run: |
  359. coverage report -m --skip-covered --skip-empty | sed 's/^/ /' >> $GITHUB_STEP_SUMMARY
  360. coverage html --skip-covered --skip-empty
  361. - name: Upload HTML report as artifact
  362. uses: actions/upload-artifact@v3
  363. with:
  364. name: coverage-report
  365. path: coverage_html_report
  366. - name: Upload coverage to Codecov
  367. uses: codecov/codecov-action@v3
  368. with:
  369. flags: backend