test.yml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  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, 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. mysql: 'mysql:8.4'
  190. emailuser: emailuser
  191. services:
  192. mysql:
  193. image: ${{ matrix.mysql || 'mysql:8.0' }}
  194. env:
  195. MARIADB_ROOT_PASSWORD: root
  196. MYSQL_ROOT_PASSWORD: root
  197. MYSQL_ALLOW_EMPTY_PASSWORD: yes
  198. MYSQL_DATABASE: wagtail
  199. HEALTH_CMD: ${{ startsWith(matrix.mysql, 'mariadb') && 'healthcheck.sh --connect --innodb_initialized' || 'mysqladmin --protocol=tcp ping' }}
  200. ports:
  201. - 3306:3306
  202. options: --health-cmd=$HEALTH_CMD --health-interval=10s --health-timeout=5s --health-retries=3 --cap-add=sys_nice
  203. steps:
  204. - uses: actions/checkout@v4
  205. with:
  206. persist-credentials: false
  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. with:
  260. persist-credentials: false
  261. - name: Set up Python ${{ matrix.python }}
  262. uses: actions/setup-python@v5
  263. with:
  264. python-version: ${{ matrix.python }}
  265. cache: 'pip'
  266. - name: Install dependencies
  267. run: |
  268. python -m pip install --upgrade pip
  269. pip install -e '.[testing]' --config-settings editable_mode=strict
  270. pip install "${{ matrix.django }}"
  271. pip install "elasticsearch>=8,<9"
  272. pip install certifi
  273. - name: Test
  274. run: |
  275. coverage run --parallel-mode --source wagtail runtests.py wagtail.search wagtail.documents wagtail.images --elasticsearch8
  276. env:
  277. DATABASE_ENGINE: django.db.backends.sqlite3
  278. USE_EMAIL_USER_MODEL: ${{ matrix.emailuser }}
  279. - name: Upload coverage data
  280. uses: actions/upload-artifact@v4
  281. with:
  282. name: coverage-data-${{ github.job }}-${{ strategy.job-index }}
  283. path: .coverage.*
  284. include-hidden-files: true
  285. test-postgres-elasticsearch7:
  286. runs-on: ubuntu-latest
  287. continue-on-error: ${{ matrix.experimental }}
  288. strategy:
  289. matrix:
  290. include:
  291. - python: '3.9'
  292. django: 'Django>=4.2,<4.3'
  293. experimental: false
  294. services:
  295. postgres:
  296. image: postgres:latest
  297. env:
  298. POSTGRES_PASSWORD: postgres
  299. ports:
  300. - 5432:5432
  301. options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
  302. steps:
  303. - name: Configure sysctl limits
  304. run: |
  305. sudo swapoff -a
  306. sudo sysctl -w vm.swappiness=1
  307. sudo sysctl -w fs.file-max=262144
  308. sudo sysctl -w vm.max_map_count=262144
  309. - uses: elastic/elastic-github-actions/elasticsearch@master
  310. with:
  311. stack-version: 7.6.1
  312. - uses: actions/checkout@v4
  313. with:
  314. persist-credentials: false
  315. - name: Set up Python ${{ matrix.python }}
  316. uses: actions/setup-python@v5
  317. with:
  318. python-version: ${{ matrix.python }}
  319. cache: 'pip'
  320. - name: Install dependencies
  321. run: |
  322. python -m pip install --upgrade pip
  323. pip install "psycopg2>=2.6"
  324. pip install -e '.[testing]' --config-settings editable_mode=strict
  325. pip install "${{ matrix.django }}"
  326. pip install "elasticsearch>=7,<8"
  327. pip install certifi
  328. - name: Test
  329. run: |
  330. coverage run --parallel-mode --source wagtail runtests.py wagtail.search wagtail.documents wagtail.images --elasticsearch7
  331. env:
  332. DATABASE_ENGINE: django.db.backends.postgresql
  333. DATABASE_HOST: localhost
  334. DATABASE_USER: postgres
  335. DATABASE_PASSWORD: postgres
  336. USE_EMAIL_USER_MODEL: ${{ matrix.emailuser }}
  337. - name: Upload coverage data
  338. uses: actions/upload-artifact@v4
  339. with:
  340. name: coverage-data-${{ github.job }}-${{ strategy.job-index }}
  341. path: .coverage.*
  342. include-hidden-files: true
  343. test-sqlite-opensearch2:
  344. runs-on: ubuntu-latest
  345. continue-on-error: ${{ matrix.experimental }}
  346. strategy:
  347. matrix:
  348. include:
  349. - python: '3.10'
  350. django: 'Django>=5.1,<5.2'
  351. experimental: false
  352. steps:
  353. - name: Configure sysctl limits
  354. run: |
  355. sudo swapoff -a
  356. sudo sysctl -w vm.swappiness=1
  357. sudo sysctl -w fs.file-max=262144
  358. sudo sysctl -w vm.max_map_count=262144
  359. - uses: ankane/setup-opensearch@v1
  360. with:
  361. opensearch-version: 2
  362. - uses: actions/checkout@v4
  363. with:
  364. persist-credentials: false
  365. - name: Set up Python ${{ matrix.python }}
  366. uses: actions/setup-python@v5
  367. with:
  368. python-version: ${{ matrix.python }}
  369. cache: 'pip'
  370. - name: Install dependencies
  371. run: |
  372. python -m pip install --upgrade pip
  373. pip install -e '.[testing]' --config-settings editable_mode=strict
  374. pip install "${{ matrix.django }}"
  375. pip install "elasticsearch==7.13.4"
  376. pip install certifi
  377. - name: Test
  378. run: |
  379. coverage run --parallel-mode --source wagtail runtests.py wagtail.search wagtail.documents wagtail.images --elasticsearch7
  380. env:
  381. DATABASE_ENGINE: django.db.backends.sqlite3
  382. USE_EMAIL_USER_MODEL: ${{ matrix.emailuser }}
  383. - name: Upload coverage data
  384. uses: actions/upload-artifact@v4
  385. with:
  386. name: coverage-data-${{ github.job }}-${{ strategy.job-index }}
  387. path: .coverage.*
  388. include-hidden-files: true
  389. coverage:
  390. needs:
  391. - test-sqlite
  392. - test-postgres
  393. - test-mysql
  394. - test-sqlite-elasticsearch8
  395. - test-postgres-elasticsearch7
  396. - test-sqlite-opensearch2
  397. runs-on: ubuntu-latest
  398. steps:
  399. - name: Check out the repo
  400. uses: actions/checkout@v4
  401. with:
  402. persist-credentials: false
  403. - name: Set up Python
  404. uses: actions/setup-python@v5
  405. with:
  406. python-version: '3.10'
  407. - name: Install dependencies
  408. run: |
  409. python -m pip install --upgrade pip
  410. pip install coverage
  411. - name: Download coverage data
  412. uses: actions/download-artifact@v4
  413. with:
  414. pattern: coverage-data-*
  415. merge-multiple: true
  416. - name: Combine coverage data
  417. run: |
  418. coverage combine
  419. - name: Generate coverage report
  420. run: |
  421. coverage report -m --skip-covered --skip-empty | sed 's/^/ /' >> $GITHUB_STEP_SUMMARY
  422. coverage html --skip-covered --skip-empty
  423. - name: Upload HTML report as artifact
  424. uses: actions/upload-artifact@v4
  425. with:
  426. name: coverage-report
  427. path: coverage_html_report
  428. include-hidden-files: true
  429. - name: Upload coverage to Codecov
  430. uses: codecov/codecov-action@v3
  431. with:
  432. flags: backend
  433. token: ${{ secrets.CODECOV_TOKEN }}