config.yml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. version: 2
  2. jobs:
  3. backend:
  4. docker:
  5. - image: cimg/python:3.12
  6. steps:
  7. - checkout
  8. - restore_cache:
  9. key: &venv-cache venv-v1-{{ checksum "setup.py" }}
  10. # Only install if .venv wasn’t cached.
  11. - run: |
  12. if [[ ! -e ".venv" ]]; then
  13. python -m venv .venv
  14. source .venv/bin/activate
  15. python -m pip install -e .[testing,docs]
  16. fi
  17. echo "source $(pwd)/.venv/bin/activate" >> $BASH_ENV
  18. - save_cache:
  19. key: *venv-cache
  20. paths:
  21. - .venv
  22. - run: ruff check .
  23. - run: ruff format --check .
  24. - run: semgrep --config .semgrep.yml --error .
  25. - run: git ls-files '*.html' | xargs djhtml --check
  26. - run: curlylint --parse-only wagtail
  27. - run: doc8 docs
  28. - run:
  29. name: Run tests
  30. command: |
  31. export PYTHONUNBUFFERED=1
  32. WAGTAIL_CHECK_TEMPLATE_NUMBER_FORMAT=1 python -u runtests.py --parallel=2
  33. frontend:
  34. docker:
  35. - image: cimg/node:22.11
  36. steps:
  37. - checkout
  38. - restore_cache:
  39. key: frontend-v1-{{ checksum "package-lock.json" }}
  40. # Only install if node_modules wasn’t cached.
  41. - run: |
  42. if [[ ! -e "node_modules" ]]; then
  43. npm install --no-save --no-optional --no-audit --no-fund --progress=false
  44. fi
  45. - save_cache:
  46. paths:
  47. - node_modules
  48. key: frontend-v1-{{ checksum "package-lock.json" }}
  49. - run: npm run build
  50. # Save static files for subsequent jobs.
  51. - persist_to_workspace:
  52. root: ~/project
  53. paths:
  54. - wagtail
  55. - run: npm run build-storybook
  56. - run: npm run lint:js
  57. - run: npm run lint:css
  58. - run: npm run lint:format
  59. - run: npm run test:unit:coverage -- --runInBand
  60. - run: bash <(curl -s https://codecov.io/bash) -F frontend
  61. ui_tests:
  62. docker:
  63. - image: cimg/python:3.12-browsers
  64. environment:
  65. DJANGO_SETTINGS_MODULE: wagtail.test.settings_ui
  66. DJANGO_DEBUG: 'true'
  67. steps:
  68. - checkout
  69. - attach_workspace:
  70. at: ~/project
  71. - restore_cache:
  72. key: &ui_tests-venv-cache ui_tests-venv-v1-{{ checksum "setup.py" }}
  73. # Only install if .venv wasn’t cached.
  74. - run: |
  75. if [[ ! -e ".venv" ]]; then
  76. python -m venv .venv
  77. source .venv/bin/activate
  78. python -m pip install -e .[testing]
  79. fi
  80. echo "source $(pwd)/.venv/bin/activate" >> $BASH_ENV
  81. - save_cache:
  82. key: *ui_tests-venv-cache
  83. paths:
  84. - .venv
  85. - restore_cache:
  86. key: &ui_tests-npm-cache ui_tests-npm_integration-v3-{{ checksum "client/tests/integration/package-lock.json" }}
  87. # Only install if node_modules wasn’t cached.
  88. - run: |
  89. if [[ ! -e "client/tests/integration/node_modules" ]]; then
  90. npm --prefix ./client/tests/integration ci
  91. fi
  92. - save_cache:
  93. key: *ui_tests-npm-cache
  94. paths:
  95. - client/tests/integration/node_modules
  96. # Also cache the global location where Puppeteer stores browsers.
  97. # https://pptr.dev/guides/configuration/#changing-the-default-cache-directory
  98. - ~/.cache/puppeteer
  99. - run: ./wagtail/test/manage.py migrate
  100. - run:
  101. command: ./wagtail/test/manage.py runserver 0:8000
  102. background: true
  103. - run: ./wagtail/test/manage.py createcachetable
  104. - run:
  105. command: ./wagtail/test/manage.py createsuperuser --noinput
  106. environment:
  107. DJANGO_SUPERUSER_EMAIL: admin@example.com
  108. DJANGO_SUPERUSER_USERNAME: admin
  109. DJANGO_SUPERUSER_PASSWORD: changeme
  110. - run:
  111. command: npm run test:integration -- --runInBand --reporters=default --reporters=jest-junit
  112. environment:
  113. JEST_JUNIT_OUTPUT_DIR: reports/jest
  114. - run:
  115. command: ./wagtail/test/manage.py collectstatic --noinput
  116. environment:
  117. DJANGO_DEBUG: 'false'
  118. STATICFILES_STORAGE: manifest
  119. - store_test_results:
  120. path: ./reports/jest
  121. nightly-build:
  122. docker:
  123. - image: cimg/python:3.12-node
  124. steps:
  125. - checkout
  126. - run: pip install --user wheel boto3
  127. - run: npm install
  128. - run: npm run build
  129. - run: PYTHONPATH=. python scripts/nightly/get_version.py > __init__.py
  130. - run: mv __init__.py wagtail/__init__.py
  131. - run: python setup.py bdist_wheel
  132. - run: python scripts/nightly/upload.py
  133. workflows:
  134. version: 2
  135. test:
  136. jobs:
  137. - backend
  138. - frontend
  139. - ui_tests:
  140. requires:
  141. - frontend
  142. nightly:
  143. jobs:
  144. - nightly-build
  145. triggers:
  146. - schedule:
  147. cron: '0 0 * * *'
  148. filters:
  149. branches:
  150. only:
  151. - main