test.yml 16 KB

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