test.yml 16 KB

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