test.yml 14 KB

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