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.

295 lines
8.3 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. command: ./bin/rails db:migrate VERSION=20171010025614
  158. name: Run migrations up to v2.0.0
  159. - run:
  160. command: ./bin/rails tests:migrations:populate_v2
  161. name: Populate database with test data
  162. - run:
  163. command: ./bin/rails db:migrate
  164. name: Run all remaining migrations
  165. test-two-step-migrations:
  166. <<: *defaults
  167. docker:
  168. - image: circleci/ruby:2.7-buster-node
  169. environment: *ruby_environment
  170. - image: circleci/postgres:12.2
  171. environment:
  172. POSTGRES_USER: root
  173. POSTGRES_HOST_AUTH_METHOD: trust
  174. - image: circleci/redis:5-alpine
  175. steps:
  176. - *attach_workspace
  177. - *install_system_dependencies
  178. - run:
  179. command: ./bin/rails db:create
  180. name: Create database
  181. - run:
  182. command: ./bin/rails db:migrate VERSION=20171010025614
  183. name: Run migrations up to v2.0.0
  184. - run:
  185. command: ./bin/rails tests:migrations:populate_v2
  186. name: Populate database with test data
  187. - run:
  188. command: ./bin/rails db:migrate
  189. name: Run all pre-deployment migrations
  190. evironment:
  191. SKIP_POST_DEPLOYMENT_MIGRATIONS: true
  192. - run:
  193. command: ./bin/rails db:migrate
  194. name: Run all post-deployment remaining migrations
  195. test-ruby2.7:
  196. <<: *defaults
  197. docker:
  198. - image: circleci/ruby:2.7-buster-node
  199. environment: *ruby_environment
  200. - image: circleci/postgres:12.2
  201. environment:
  202. POSTGRES_USER: root
  203. POSTGRES_HOST_AUTH_METHOD: trust
  204. - image: circleci/redis:5-alpine
  205. <<: *test_steps
  206. test-ruby2.6:
  207. <<: *defaults
  208. docker:
  209. - image: circleci/ruby:2.6-buster-node
  210. environment: *ruby_environment
  211. - image: circleci/postgres:12.2
  212. environment:
  213. POSTGRES_USER: root
  214. POSTGRES_HOST_AUTH_METHOD: trust
  215. - image: circleci/redis:5-alpine
  216. <<: *test_steps
  217. test-ruby3.0:
  218. <<: *defaults
  219. docker:
  220. - image: circleci/ruby:3.0-buster-node
  221. environment: *ruby_environment
  222. - image: circleci/postgres:12.2
  223. environment:
  224. POSTGRES_USER: root
  225. POSTGRES_HOST_AUTH_METHOD: trust
  226. - image: circleci/redis:5-alpine
  227. <<: *test_steps
  228. test-webui:
  229. <<: *defaults
  230. docker:
  231. - image: circleci/node:12-buster
  232. steps:
  233. - *attach_workspace
  234. - run:
  235. name: Run jest
  236. command: yarn test:jest
  237. workflows:
  238. version: 2
  239. build-and-test:
  240. jobs:
  241. - install
  242. - install-ruby2.7:
  243. requires:
  244. - install
  245. - install-ruby2.6:
  246. requires:
  247. - install
  248. - install-ruby2.7
  249. - install-ruby3.0:
  250. requires:
  251. - install
  252. - install-ruby2.7
  253. - build:
  254. requires:
  255. - install-ruby2.7
  256. - test-migrations:
  257. requires:
  258. - install-ruby2.7
  259. - test-two-step-migrations:
  260. requires:
  261. - install-ruby2.7
  262. - test-ruby2.7:
  263. requires:
  264. - install-ruby2.7
  265. - build
  266. - test-ruby2.6:
  267. requires:
  268. - install-ruby2.6
  269. - build
  270. - test-ruby3.0:
  271. requires:
  272. - install-ruby3.0
  273. - build
  274. - test-webui:
  275. requires:
  276. - install