test.yml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  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 4.2, python 3.11, mariadb:10.5
  22. # - django 5.0, python 3.11, sqlite, WAGTAIL_CHECK_TEMPLATE_NUMBER_FORMAT=1
  23. # - django 5.1, python 3.12, mysql:8.4, parallel, USE_EMAIL_USER_MODEL=yes
  24. # - django 5.1, python 3.12, mariadb:11.4, USE_EMAIL_USER_MODEL=yes
  25. # - django 5.1, python 3.13, sqlite, parallel, USE_EMAIL_USER_MODEL=yes
  26. # - django 5.1, python 3.13, postgres:15, psycopg 3, parallel, DISABLE_TIMEZONE=yes
  27. # - django stable/5.1.x, python 3.11, postgres:15, psycopg 3 (allow failures)
  28. # - django main, python 3.13, postgres:latest, psycopg 3, parallel (allow failures)
  29. # - elasticsearch 7, django 4.2, python 3.9, postgres:latest, psycopg 2
  30. # - opensearch 2, django 5.0, python 3.10, sqlite
  31. # - elasticsearch 8, django 5.1, python 3.13, sqlite, USE_EMAIL_USER_MODEL=yes
  32. # Some tests are run in parallel by passing --parallel to runtests.py.
  33. # When running tests in parallel, some errors cannot be pickled and result in
  34. # non-helpful tracebacks (see https://code.djangoproject.com/ticket/29023).
  35. # Thus, we keep one test run without --parallel for each supported database.
  36. # ElasticSearch tests are not run in parallel as the test suite is not thread-safe.
  37. permissions:
  38. contents: read # to fetch code (actions/checkout)
  39. jobs:
  40. test-sqlite:
  41. runs-on: ubuntu-latest
  42. strategy:
  43. matrix:
  44. include:
  45. - python: '3.11'
  46. django: 'Django>=5.0,<5.1'
  47. check_template_number_format: '1'
  48. - python: '3.13'
  49. django: 'Django>=5.1,<5.2'
  50. emailuser: emailuser
  51. parallel: '--parallel'
  52. steps:
  53. - uses: actions/checkout@v4
  54. - name: Set up Python ${{ matrix.python }}
  55. uses: actions/setup-python@v5
  56. with:
  57. python-version: ${{ matrix.python }}
  58. cache: 'pip'
  59. - name: Install dependencies
  60. run: |
  61. python -m pip install --upgrade pip
  62. pip install -e '.[testing]' --config-settings editable_mode=strict
  63. pip install "${{ matrix.django }}"
  64. - name: Test
  65. run: |
  66. WAGTAIL_FAIL_ON_VERSIONED_STATIC=1 DJANGO_SETTINGS_MODULE=wagtail.test.settings django-admin check
  67. coverage run --parallel-mode --source wagtail runtests.py ${{ matrix.parallel }}
  68. env:
  69. DATABASE_ENGINE: django.db.backends.sqlite3
  70. USE_EMAIL_USER_MODEL: ${{ matrix.emailuser }}
  71. WAGTAIL_CHECK_TEMPLATE_NUMBER_FORMAT: ${{ matrix.check_template_number_format }}
  72. - name: Upload coverage data
  73. uses: actions/upload-artifact@v4
  74. with:
  75. name: coverage-data-${{ github.job }}-${{ strategy.job-index }}
  76. path: .coverage.*
  77. include-hidden-files: true
  78. test-postgres:
  79. runs-on: ubuntu-latest
  80. continue-on-error: ${{ matrix.experimental }}
  81. strategy:
  82. matrix:
  83. include:
  84. - python: '3.9'
  85. django: 'Django>=4.2,<4.3'
  86. psycopg: 'psycopg2>=2.6'
  87. experimental: false
  88. parallel: '--parallel'
  89. - python: '3.13'
  90. django: 'Django>=5.0,<5.1'
  91. psycopg: 'psycopg>=3.1.8'
  92. postgres: 'postgres:15'
  93. notz: notz
  94. experimental: false
  95. parallel: '--parallel'
  96. - python: '3.11'
  97. django: 'git+https://github.com/django/django.git@stable/5.1.x#egg=Django'
  98. psycopg: 'psycopg>=3.1.8'
  99. postgres: 'postgres:15'
  100. experimental: true
  101. - python: '3.13'
  102. django: 'git+https://github.com/django/django.git@main#egg=Django'
  103. psycopg: 'psycopg>=3.1.8'
  104. experimental: true
  105. postgres: 'postgres:latest'
  106. parallel: '--parallel'
  107. services:
  108. postgres:
  109. image: ${{ matrix.postgres || 'postgres:12' }}
  110. env:
  111. POSTGRES_PASSWORD: postgres
  112. ports:
  113. - 5432:5432
  114. options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
  115. steps:
  116. - uses: actions/checkout@v4
  117. - name: Set up Python ${{ matrix.python }}
  118. uses: actions/setup-python@v5
  119. with:
  120. python-version: ${{ matrix.python }}
  121. cache: 'pip'
  122. - name: Install dependencies
  123. run: |
  124. python -m pip install --upgrade pip
  125. pip install "${{ matrix.psycopg }}"
  126. pip install -e '.[testing]' --config-settings editable_mode=strict
  127. pip install "${{ matrix.django }}"
  128. ${{ matrix.install_extras }}
  129. - name: Test
  130. run: |
  131. WAGTAIL_FAIL_ON_VERSIONED_STATIC=1 DJANGO_SETTINGS_MODULE=wagtail.test.settings django-admin check
  132. coverage run --parallel-mode --source wagtail runtests.py ${{ matrix.parallel }}
  133. env:
  134. DATABASE_ENGINE: django.db.backends.postgresql
  135. DATABASE_HOST: localhost
  136. DATABASE_USER: postgres
  137. DATABASE_PASSWORD: postgres
  138. USE_EMAIL_USER_MODEL: ${{ matrix.emailuser }}
  139. DISABLE_TIMEZONE: ${{ matrix.notz }}
  140. - name: Upload coverage data
  141. uses: actions/upload-artifact@v4
  142. with:
  143. name: coverage-data-${{ github.job }}-${{ strategy.job-index }}
  144. path: .coverage.*
  145. include-hidden-files: true
  146. - name: Test project template
  147. if: ${{ matrix.experimental }}
  148. env:
  149. PYTHONWARNINGS: error
  150. run: |
  151. wagtail start testproject
  152. cd testproject
  153. tee -a testproject/settings/local.py << EOF
  154. from warnings import filterwarnings
  155. SILENCED_SYSTEM_CHECKS = ["wagtailadmin.W001"]
  156. # Remove when l18n dependency is updated or removed
  157. filterwarnings(
  158. "ignore", "'locale.getdefaultlocale' is deprecated .*"
  159. )
  160. # Remove when all experimental jobs use Django >= 6.0
  161. filterwarnings(
  162. "ignore", "The FORMS_URLFIELD_ASSUME_HTTPS transitional setting is deprecated."
  163. )
  164. FORMS_URLFIELD_ASSUME_HTTPS = True
  165. EOF
  166. python manage.py makemigrations --check --dry-run
  167. python manage.py migrate
  168. python manage.py check --fail-level WARNING
  169. test-mysql:
  170. runs-on: ubuntu-latest
  171. continue-on-error: ${{ matrix.experimental }}
  172. strategy:
  173. matrix:
  174. include:
  175. - python: '3.10'
  176. django: 'Django>=4.2,<4.3'
  177. experimental: false
  178. - python: '3.11'
  179. django: 'Django>=4.2,<4.3'
  180. experimental: false
  181. mysql: 'mariadb:10.5'
  182. - python: '3.12'
  183. django: 'Django>=5.1,<5.2'
  184. experimental: false
  185. mysql: 'mariadb:11.4'
  186. emailuser: emailuser
  187. - python: '3.12'
  188. django: 'Django>=5.1,<5.2'
  189. experimental: false
  190. parallel: '--parallel'
  191. mysql: 'mysql:8.4'
  192. emailuser: emailuser
  193. services:
  194. mysql:
  195. image: ${{ matrix.mysql || 'mysql:8.0' }}
  196. env:
  197. MARIADB_ROOT_PASSWORD: root
  198. MYSQL_ROOT_PASSWORD: root
  199. MYSQL_ALLOW_EMPTY_PASSWORD: yes
  200. MYSQL_DATABASE: wagtail
  201. HEALTH_CMD: ${{ startsWith(matrix.mysql, 'mariadb') && 'healthcheck.sh --connect --innodb_initialized' || 'mysqladmin --protocol=tcp ping' }}
  202. ports:
  203. - 3306:3306
  204. options: --health-cmd=$HEALTH_CMD --health-interval=10s --health-timeout=5s --health-retries=3 --cap-add=sys_nice
  205. steps:
  206. - uses: actions/checkout@v4
  207. - name: Set up Python ${{ matrix.python }}
  208. uses: actions/setup-python@v5
  209. with:
  210. python-version: ${{ matrix.python }}
  211. cache: 'pip'
  212. - name: Install dependencies
  213. run: |
  214. python -m pip install --upgrade pip
  215. pip install "mysqlclient>=1.4,<2"
  216. pip install -e '.[testing]' --config-settings editable_mode=strict
  217. pip install "${{ matrix.django }}"
  218. - name: Test
  219. run: |
  220. WAGTAIL_FAIL_ON_VERSIONED_STATIC=1 DJANGO_SETTINGS_MODULE=wagtail.test.settings django-admin check
  221. coverage run --parallel-mode --source wagtail runtests.py ${{ matrix.parallel }}
  222. env:
  223. DATABASE_ENGINE: django.db.backends.mysql
  224. DATABASE_HOST: '127.0.0.1'
  225. DATABASE_USER: root
  226. DATABASE_PASSWORD: root
  227. USE_EMAIL_USER_MODEL: ${{ matrix.emailuser }}
  228. DISABLE_TIMEZONE: ${{ matrix.notz }}
  229. - name: Upload coverage data
  230. uses: actions/upload-artifact@v4
  231. with:
  232. name: coverage-data-${{ github.job }}-${{ strategy.job-index }}
  233. path: .coverage.*
  234. include-hidden-files: true
  235. test-sqlite-elasticsearch8:
  236. runs-on: ubuntu-latest
  237. strategy:
  238. matrix:
  239. include:
  240. - python: '3.13'
  241. django: 'Django>=5.1,<5.2'
  242. emailuser: emailuser
  243. steps:
  244. - name: Configure sysctl limits
  245. run: |
  246. sudo swapoff -a
  247. sudo sysctl -w vm.swappiness=1
  248. sudo sysctl -w fs.file-max=262144
  249. sudo sysctl -w vm.max_map_count=262144
  250. - uses: getong/elasticsearch-action@v1.3
  251. with:
  252. elasticsearch version: 8.8.0
  253. host port: 9200
  254. container port: 9200
  255. host node port: 9300
  256. node port: 9300
  257. discovery type: 'single-node'
  258. - uses: actions/checkout@v4
  259. - name: Set up Python ${{ matrix.python }}
  260. uses: actions/setup-python@v5
  261. with:
  262. python-version: ${{ matrix.python }}
  263. cache: 'pip'
  264. - name: Install dependencies
  265. run: |
  266. python -m pip install --upgrade pip
  267. pip install -e '.[testing]' --config-settings editable_mode=strict
  268. pip install "${{ matrix.django }}"
  269. pip install "elasticsearch>=8,<9"
  270. pip install certifi
  271. - name: Test
  272. run: |
  273. coverage run --parallel-mode --source wagtail runtests.py wagtail.search wagtail.documents wagtail.images --elasticsearch8
  274. env:
  275. DATABASE_ENGINE: django.db.backends.sqlite3
  276. USE_EMAIL_USER_MODEL: ${{ matrix.emailuser }}
  277. - name: Upload coverage data
  278. uses: actions/upload-artifact@v4
  279. with:
  280. name: coverage-data-${{ github.job }}-${{ strategy.job-index }}
  281. path: .coverage.*
  282. include-hidden-files: true
  283. test-postgres-elasticsearch7:
  284. runs-on: ubuntu-latest
  285. continue-on-error: ${{ matrix.experimental }}
  286. strategy:
  287. matrix:
  288. include:
  289. - python: '3.9'
  290. django: 'Django>=4.2,<4.3'
  291. experimental: false
  292. services:
  293. postgres:
  294. image: postgres:latest
  295. env:
  296. POSTGRES_PASSWORD: postgres
  297. ports:
  298. - 5432:5432
  299. options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
  300. steps:
  301. - name: Configure sysctl limits
  302. run: |
  303. sudo swapoff -a
  304. sudo sysctl -w vm.swappiness=1
  305. sudo sysctl -w fs.file-max=262144
  306. sudo sysctl -w vm.max_map_count=262144
  307. - uses: elastic/elastic-github-actions/elasticsearch@master
  308. with:
  309. stack-version: 7.6.1
  310. - uses: actions/checkout@v4
  311. - name: Set up Python ${{ matrix.python }}
  312. uses: actions/setup-python@v5
  313. with:
  314. python-version: ${{ matrix.python }}
  315. cache: 'pip'
  316. - name: Install dependencies
  317. run: |
  318. python -m pip install --upgrade pip
  319. pip install "psycopg2>=2.6"
  320. pip install -e '.[testing]' --config-settings editable_mode=strict
  321. pip install "${{ matrix.django }}"
  322. pip install "elasticsearch>=7,<8"
  323. pip install certifi
  324. - name: Test
  325. run: |
  326. coverage run --parallel-mode --source wagtail runtests.py wagtail.search wagtail.documents wagtail.images --elasticsearch7
  327. env:
  328. DATABASE_ENGINE: django.db.backends.postgresql
  329. DATABASE_HOST: localhost
  330. DATABASE_USER: postgres
  331. DATABASE_PASSWORD: postgres
  332. USE_EMAIL_USER_MODEL: ${{ matrix.emailuser }}
  333. - name: Upload coverage data
  334. uses: actions/upload-artifact@v4
  335. with:
  336. name: coverage-data-${{ github.job }}-${{ strategy.job-index }}
  337. path: .coverage.*
  338. include-hidden-files: true
  339. test-sqlite-opensearch2:
  340. runs-on: ubuntu-latest
  341. continue-on-error: ${{ matrix.experimental }}
  342. strategy:
  343. matrix:
  344. include:
  345. - python: '3.10'
  346. django: 'Django>=5.0,<5.1'
  347. experimental: false
  348. steps:
  349. - name: Configure sysctl limits
  350. run: |
  351. sudo swapoff -a
  352. sudo sysctl -w vm.swappiness=1
  353. sudo sysctl -w fs.file-max=262144
  354. sudo sysctl -w vm.max_map_count=262144
  355. - uses: ankane/setup-opensearch@v1
  356. with:
  357. opensearch-version: 2
  358. - uses: actions/checkout@v4
  359. - name: Set up Python ${{ matrix.python }}
  360. uses: actions/setup-python@v5
  361. with:
  362. python-version: ${{ matrix.python }}
  363. cache: 'pip'
  364. - name: Install dependencies
  365. run: |
  366. python -m pip install --upgrade pip
  367. pip install -e '.[testing]' --config-settings editable_mode=strict
  368. pip install "${{ matrix.django }}"
  369. pip install "elasticsearch==7.13.4"
  370. pip install certifi
  371. - name: Test
  372. run: |
  373. coverage run --parallel-mode --source wagtail runtests.py wagtail.search wagtail.documents wagtail.images --elasticsearch7
  374. env:
  375. DATABASE_ENGINE: django.db.backends.sqlite3
  376. USE_EMAIL_USER_MODEL: ${{ matrix.emailuser }}
  377. - name: Upload coverage data
  378. uses: actions/upload-artifact@v4
  379. with:
  380. name: coverage-data-${{ github.job }}-${{ strategy.job-index }}
  381. path: .coverage.*
  382. include-hidden-files: true
  383. coverage:
  384. needs:
  385. - test-sqlite
  386. - test-postgres
  387. - test-mysql
  388. - test-sqlite-elasticsearch8
  389. - test-postgres-elasticsearch7
  390. - test-sqlite-opensearch2
  391. runs-on: ubuntu-latest
  392. steps:
  393. - name: Check out the repo
  394. uses: actions/checkout@v4
  395. - name: Set up Python
  396. uses: actions/setup-python@v5
  397. with:
  398. python-version: '3.10'
  399. - name: Install dependencies
  400. run: |
  401. python -m pip install --upgrade pip
  402. pip install coverage
  403. - name: Download coverage data
  404. uses: actions/download-artifact@v4
  405. with:
  406. pattern: coverage-data-*
  407. merge-multiple: true
  408. - name: Combine coverage data
  409. run: |
  410. coverage combine
  411. - name: Generate coverage report
  412. run: |
  413. coverage report -m --skip-covered --skip-empty | sed 's/^/ /' >> $GITHUB_STEP_SUMMARY
  414. coverage html --skip-covered --skip-empty
  415. - name: Upload HTML report as artifact
  416. uses: actions/upload-artifact@v4
  417. with:
  418. name: coverage-report
  419. path: coverage_html_report
  420. include-hidden-files: true
  421. - name: Upload coverage to Codecov
  422. uses: codecov/codecov-action@v3
  423. with:
  424. flags: backend
  425. token: ${{ secrets.CODECOV_TOKEN }}