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.

249 lines
6.9 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 --local clean 'true'
  69. bundle config --local deployment 'true'
  70. bundle config --local with 'pam_authentication'
  71. bundle config --local without 'development production'
  72. bundle config --local frozen 'true'
  73. bundle config --local path $BUNDLE_PATH
  74. - run:
  75. name: Install bundler dependencies
  76. command: bundle check || (bundle install && bundle clean)
  77. - save_cache:
  78. key: v3-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}-{{ checksum "Gemfile.lock" }}
  79. paths:
  80. - ./.bundle/
  81. - ./vendor/bundle/
  82. - persist_to_workspace:
  83. root: ~/projects/
  84. paths:
  85. - ./mastodon/.bundle/
  86. - ./mastodon/vendor/bundle/
  87. - &test_steps
  88. parallelism: 4
  89. steps:
  90. - *attach_workspace
  91. - *install_system_dependencies
  92. - run:
  93. name: Install FFMPEG
  94. command: sudo apt-get install -y ffmpeg
  95. - run:
  96. name: Load database schema
  97. command: ./bin/rails db:create db:schema:load db:seed
  98. - run:
  99. name: Run rspec in parallel
  100. command: |
  101. bundle exec rspec --profile 10 \
  102. --format RspecJunitFormatter \
  103. --out test_results/rspec.xml \
  104. --format progress \
  105. $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
  106. - store_test_results:
  107. path: test_results
  108. jobs:
  109. install:
  110. <<: *defaults
  111. <<: *install_steps
  112. install-ruby2.7:
  113. <<: *defaults
  114. <<: *install_ruby_dependencies
  115. install-ruby2.6:
  116. <<: *defaults
  117. docker:
  118. - image: circleci/ruby:2.6-buster-node
  119. environment: *ruby_environment
  120. <<: *install_ruby_dependencies
  121. build:
  122. <<: *defaults
  123. steps:
  124. - *attach_workspace
  125. - *install_system_dependencies
  126. - run:
  127. name: Precompile assets
  128. command: ./bin/rails assets:precompile
  129. - persist_to_workspace:
  130. root: ~/projects/
  131. paths:
  132. - ./mastodon/public/assets
  133. - ./mastodon/public/packs-test/
  134. test-migrations:
  135. <<: *defaults
  136. docker:
  137. - image: circleci/ruby:2.7-buster-node
  138. environment: *ruby_environment
  139. - image: circleci/postgres:12.2
  140. environment:
  141. POSTGRES_USER: root
  142. POSTGRES_HOST_AUTH_METHOD: trust
  143. - image: circleci/redis:5-alpine
  144. steps:
  145. - *attach_workspace
  146. - *install_system_dependencies
  147. - run:
  148. name: Create database
  149. command: ./bin/rails db:create
  150. - run:
  151. name: Run migrations
  152. command: ./bin/rails db:migrate
  153. test-ruby2.7:
  154. <<: *defaults
  155. docker:
  156. - image: circleci/ruby:2.7-buster-node
  157. environment: *ruby_environment
  158. - image: circleci/postgres:12.2
  159. environment:
  160. POSTGRES_USER: root
  161. POSTGRES_HOST_AUTH_METHOD: trust
  162. - image: circleci/redis:5-alpine
  163. <<: *test_steps
  164. test-ruby2.6:
  165. <<: *defaults
  166. docker:
  167. - image: circleci/ruby:2.6-buster-node
  168. environment: *ruby_environment
  169. - image: circleci/postgres:12.2
  170. environment:
  171. POSTGRES_USER: root
  172. POSTGRES_HOST_AUTH_METHOD: trust
  173. - image: circleci/redis:5-alpine
  174. <<: *test_steps
  175. test-webui:
  176. <<: *defaults
  177. docker:
  178. - image: circleci/node:12-buster
  179. steps:
  180. - *attach_workspace
  181. - run:
  182. name: Run jest
  183. command: yarn test:jest
  184. check-i18n:
  185. <<: *defaults
  186. steps:
  187. - *attach_workspace
  188. - *install_system_dependencies
  189. - run:
  190. name: Check locale file normalization
  191. command: bundle exec i18n-tasks check-normalized
  192. - run:
  193. name: Check for unused strings
  194. command: bundle exec i18n-tasks unused -l en
  195. - run:
  196. name: Check for wrong string interpolations
  197. command: bundle exec i18n-tasks check-consistent-interpolations
  198. - run:
  199. name: Check that all required locale files exist
  200. command: bundle exec rake repo:check_locales_files
  201. workflows:
  202. version: 2
  203. build-and-test:
  204. jobs:
  205. - install
  206. - install-ruby2.7:
  207. requires:
  208. - install
  209. - install-ruby2.6:
  210. requires:
  211. - install
  212. - install-ruby2.7
  213. - build:
  214. requires:
  215. - install-ruby2.7
  216. - test-migrations:
  217. requires:
  218. - install-ruby2.7
  219. - test-ruby2.7:
  220. requires:
  221. - install-ruby2.7
  222. - build
  223. - test-ruby2.6:
  224. requires:
  225. - install-ruby2.6
  226. - build
  227. - test-webui:
  228. requires:
  229. - install
  230. - check-i18n:
  231. requires:
  232. - install-ruby2.7