You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

248 lines
6.8 KiB

  1. version: 2
  2. aliases:
  3. - &defaults
  4. docker:
  5. - image: circleci/ruby:2.7-buster-node
  6. environment: &ruby_environment
  7. BUNDLE_JOBS: 3
  8. BUNDLE_RETRY: 3
  9. BUNDLE_APP_CONFIG: ./.bundle/
  10. BUNDLE_PATH: ./vendor/bundle/
  11. DB_HOST: localhost
  12. DB_USER: root
  13. RAILS_ENV: test
  14. ALLOW_NOPAM: true
  15. CONTINUOUS_INTEGRATION: true
  16. DISABLE_SIMPLECOV: true
  17. PAM_ENABLED: true
  18. PAM_DEFAULT_SERVICE: pam_test
  19. PAM_CONTROLLED_SERVICE: pam_test_controlled
  20. working_directory: ~/projects/mastodon/
  21. - &attach_workspace
  22. attach_workspace:
  23. at: ~/projects/
  24. - &persist_to_workspace
  25. persist_to_workspace:
  26. root: ~/projects/
  27. paths:
  28. - ./mastodon/
  29. - &restore_ruby_dependencies
  30. restore_cache:
  31. keys:
  32. - v3-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}-{{ checksum "Gemfile.lock" }}
  33. - v3-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}-
  34. - v3-ruby-dependencies-
  35. - &install_steps
  36. steps:
  37. - checkout
  38. - *attach_workspace
  39. - restore_cache:
  40. keys:
  41. - v2-node-dependencies-{{ checksum "yarn.lock" }}
  42. - v2-node-dependencies-
  43. - run:
  44. name: Install yarn dependencies
  45. command: yarn install --frozen-lockfile
  46. - save_cache:
  47. key: v2-node-dependencies-{{ checksum "yarn.lock" }}
  48. paths:
  49. - ./node_modules/
  50. - *persist_to_workspace
  51. - &install_system_dependencies
  52. run:
  53. name: Install system dependencies
  54. command: |
  55. sudo apt-get update
  56. sudo apt-get install -y libicu-dev libidn11-dev libprotobuf-dev protobuf-compiler
  57. - &install_ruby_dependencies
  58. steps:
  59. - *attach_workspace
  60. - *install_system_dependencies
  61. - run:
  62. name: Set Ruby version
  63. command: ruby -e 'puts RUBY_VERSION' | tee /tmp/.ruby-version
  64. - *restore_ruby_dependencies
  65. - run:
  66. name: Set bundler settings
  67. command: |
  68. bundle config clean 'true'
  69. bundle config deployment 'true'
  70. bundle config with 'pam_authentication'
  71. bundle config without 'development production'
  72. bundle config frozen 'true'
  73. - run:
  74. name: Install bundler dependencies
  75. command: bundle check || (bundle install && bundle clean)
  76. - save_cache:
  77. key: v3-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}-{{ checksum "Gemfile.lock" }}
  78. paths:
  79. - ./.bundle/
  80. - ./vendor/bundle/
  81. - persist_to_workspace:
  82. root: ~/projects/
  83. paths:
  84. - ./mastodon/.bundle/
  85. - ./mastodon/vendor/bundle/
  86. - &test_steps
  87. parallelism: 4
  88. steps:
  89. - *attach_workspace
  90. - *install_system_dependencies
  91. - run:
  92. name: Install FFMPEG
  93. command: sudo apt-get install -y ffmpeg
  94. - run:
  95. name: Load database schema
  96. command: ./bin/rails db:create db:schema:load db:seed
  97. - run:
  98. name: Run rspec in parallel
  99. command: |
  100. bundle exec rspec --profile 10 \
  101. --format RspecJunitFormatter \
  102. --out test_results/rspec.xml \
  103. --format progress \
  104. $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
  105. - store_test_results:
  106. path: test_results
  107. jobs:
  108. install:
  109. <<: *defaults
  110. <<: *install_steps
  111. install-ruby2.7:
  112. <<: *defaults
  113. <<: *install_ruby_dependencies
  114. install-ruby2.6:
  115. <<: *defaults
  116. docker:
  117. - image: circleci/ruby:2.6-buster-node
  118. environment: *ruby_environment
  119. <<: *install_ruby_dependencies
  120. build:
  121. <<: *defaults
  122. steps:
  123. - *attach_workspace
  124. - *install_system_dependencies
  125. - run:
  126. name: Precompile assets
  127. command: ./bin/rails assets:precompile
  128. - persist_to_workspace:
  129. root: ~/projects/
  130. paths:
  131. - ./mastodon/public/assets
  132. - ./mastodon/public/packs-test/
  133. test-migrations:
  134. <<: *defaults
  135. docker:
  136. - image: circleci/ruby:2.7-buster-node
  137. environment: *ruby_environment
  138. - image: circleci/postgres:12.2
  139. environment:
  140. POSTGRES_USER: root
  141. POSTGRES_HOST_AUTH_METHOD: trust
  142. - image: circleci/redis:5-alpine
  143. steps:
  144. - *attach_workspace
  145. - *install_system_dependencies
  146. - run:
  147. name: Create database
  148. command: ./bin/rails db:create
  149. - run:
  150. name: Run migrations
  151. command: ./bin/rails db:migrate
  152. test-ruby2.7:
  153. <<: *defaults
  154. docker:
  155. - image: circleci/ruby:2.7-buster-node
  156. environment: *ruby_environment
  157. - image: circleci/postgres:12.2
  158. environment:
  159. POSTGRES_USER: root
  160. POSTGRES_HOST_AUTH_METHOD: trust
  161. - image: circleci/redis:5-alpine
  162. <<: *test_steps
  163. test-ruby2.6:
  164. <<: *defaults
  165. docker:
  166. - image: circleci/ruby:2.6-buster-node
  167. environment: *ruby_environment
  168. - image: circleci/postgres:12.2
  169. environment:
  170. POSTGRES_USER: root
  171. POSTGRES_HOST_AUTH_METHOD: trust
  172. - image: circleci/redis:5-alpine
  173. <<: *test_steps
  174. test-webui:
  175. <<: *defaults
  176. docker:
  177. - image: circleci/node:12-buster
  178. steps:
  179. - *attach_workspace
  180. - run:
  181. name: Run jest
  182. command: yarn test:jest
  183. check-i18n:
  184. <<: *defaults
  185. steps:
  186. - *attach_workspace
  187. - *install_system_dependencies
  188. - run:
  189. name: Check locale file normalization
  190. command: bundle exec i18n-tasks check-normalized
  191. - run:
  192. name: Check for unused strings
  193. command: bundle exec i18n-tasks unused -l en
  194. - run:
  195. name: Check for wrong string interpolations
  196. command: bundle exec i18n-tasks check-consistent-interpolations
  197. - run:
  198. name: Check that all required locale files exist
  199. command: bundle exec rake repo:check_locales_files
  200. workflows:
  201. version: 2
  202. build-and-test:
  203. jobs:
  204. - install
  205. - install-ruby2.7:
  206. requires:
  207. - install
  208. - install-ruby2.6:
  209. requires:
  210. - install
  211. - install-ruby2.7
  212. - build:
  213. requires:
  214. - install-ruby2.7
  215. - test-migrations:
  216. requires:
  217. - install-ruby2.7
  218. - test-ruby2.7:
  219. requires:
  220. - install-ruby2.7
  221. - build
  222. - test-ruby2.6:
  223. requires:
  224. - install-ruby2.6
  225. - build
  226. - test-webui:
  227. requires:
  228. - install
  229. - check-i18n:
  230. requires:
  231. - install-ruby2.7