config.yml 5.0 KB

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