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.

255 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. install-ruby3.0:
  122. <<: *defaults
  123. docker:
  124. - image: circleci/ruby:3.0-buster-node
  125. environment: *ruby_environment
  126. <<: *install_ruby_dependencies
  127. build:
  128. <<: *defaults
  129. steps:
  130. - *attach_workspace
  131. - *install_system_dependencies
  132. - run:
  133. name: Precompile assets
  134. command: ./bin/rails assets:precompile
  135. - persist_to_workspace:
  136. root: ~/projects/
  137. paths:
  138. - ./mastodon/public/assets
  139. - ./mastodon/public/packs-test/
  140. test-migrations:
  141. <<: *defaults
  142. docker:
  143. - image: circleci/ruby:2.7-buster-node
  144. environment: *ruby_environment
  145. - image: circleci/postgres:12.2
  146. environment:
  147. POSTGRES_USER: root
  148. POSTGRES_HOST_AUTH_METHOD: trust
  149. - image: circleci/redis:5-alpine
  150. steps:
  151. - *attach_workspace
  152. - *install_system_dependencies
  153. - run:
  154. name: Create database
  155. command: ./bin/rails db:create
  156. - run:
  157. name: Run migrations
  158. command: ./bin/rails db:migrate
  159. test-ruby2.7:
  160. <<: *defaults
  161. docker:
  162. - image: circleci/ruby:2.7-buster-node
  163. environment: *ruby_environment
  164. - image: circleci/postgres:12.2
  165. environment:
  166. POSTGRES_USER: root
  167. POSTGRES_HOST_AUTH_METHOD: trust
  168. - image: circleci/redis:5-alpine
  169. <<: *test_steps
  170. test-ruby2.6:
  171. <<: *defaults
  172. docker:
  173. - image: circleci/ruby:2.6-buster-node
  174. environment: *ruby_environment
  175. - image: circleci/postgres:12.2
  176. environment:
  177. POSTGRES_USER: root
  178. POSTGRES_HOST_AUTH_METHOD: trust
  179. - image: circleci/redis:5-alpine
  180. <<: *test_steps
  181. test-ruby3.0:
  182. <<: *defaults
  183. docker:
  184. - image: circleci/ruby:3.0-buster-node
  185. environment: *ruby_environment
  186. - image: circleci/postgres:12.2
  187. environment:
  188. POSTGRES_USER: root
  189. POSTGRES_HOST_AUTH_METHOD: trust
  190. - image: circleci/redis:5-alpine
  191. <<: *test_steps
  192. test-webui:
  193. <<: *defaults
  194. docker:
  195. - image: circleci/node:12-buster
  196. steps:
  197. - *attach_workspace
  198. - run:
  199. name: Run jest
  200. command: yarn test:jest
  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. - install-ruby3.0:
  214. requires:
  215. - install
  216. - install-ruby2.7
  217. - build:
  218. requires:
  219. - install-ruby2.7
  220. - test-migrations:
  221. requires:
  222. - install-ruby2.7
  223. - test-ruby2.7:
  224. requires:
  225. - install-ruby2.7
  226. - build
  227. - test-ruby2.6:
  228. requires:
  229. - install-ruby2.6
  230. - build
  231. - test-ruby3.0:
  232. requires:
  233. - install-ruby3.0
  234. - build
  235. - test-webui:
  236. requires:
  237. - install