test.yml 14 KB

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