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.

193 lines
5.0 KiB

  1. version: 2
  2. aliases:
  3. - &defaults
  4. docker:
  5. - image: circleci/ruby:2.5.1-stretch-node
  6. environment: &ruby_environment
  7. BUNDLE_APP_CONFIG: ./.bundle/
  8. DB_HOST: localhost
  9. DB_USER: root
  10. RAILS_ENV: test
  11. PARALLEL_TEST_PROCESSORS: 4
  12. ALLOW_NOPAM: true
  13. CONTINUOUS_INTEGRATION: true
  14. DISABLE_SIMPLECOV: true
  15. working_directory: ~/projects/mastodon/
  16. - &attach_workspace
  17. attach_workspace:
  18. at: ~/projects/
  19. - &persist_to_workspace
  20. persist_to_workspace:
  21. root: ~/projects/
  22. paths:
  23. - ./mastodon/
  24. - &restore_ruby_dependencies
  25. restore_cache:
  26. keys:
  27. - v2-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}-{{ checksum "Gemfile.lock" }}
  28. - v2-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}-
  29. - v2-ruby-dependencies-
  30. - &install_steps
  31. steps:
  32. - checkout
  33. - *attach_workspace
  34. - restore_cache:
  35. keys:
  36. - v1-node-dependencies-{{ checksum "yarn.lock" }}
  37. - v1-node-dependencies-
  38. - run: yarn install --frozen-lockfile
  39. - save_cache:
  40. key: v1-node-dependencies-{{ checksum "yarn.lock" }}
  41. paths:
  42. - ./node_modules/
  43. - *persist_to_workspace
  44. - &install_system_dependencies
  45. run:
  46. name: Install system dependencies
  47. command: |
  48. sudo apt-get update
  49. sudo apt-get install -y libicu-dev libidn11-dev libprotobuf-dev protobuf-compiler
  50. - &install_ruby_dependencies
  51. steps:
  52. - *attach_workspace
  53. - *install_system_dependencies
  54. - run: ruby -e 'puts RUBY_VERSION' | tee /tmp/.ruby-version
  55. - *restore_ruby_dependencies
  56. - run: bundle install --clean --jobs 16 --path ./vendor/bundle/ --retry 3 --with pam_authentication --without development production
  57. - save_cache:
  58. key: v2-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}-{{ checksum "Gemfile.lock" }}
  59. paths:
  60. - ./.bundle/
  61. - ./vendor/bundle/
  62. - &test_steps
  63. steps:
  64. - *attach_workspace
  65. - *install_system_dependencies
  66. - run: sudo apt-get install -y ffmpeg
  67. - run: ruby -e 'puts RUBY_VERSION' | tee /tmp/.ruby-version
  68. - *restore_ruby_dependencies
  69. - restore_cache:
  70. keys:
  71. - precompiled-assets-{{ .Branch }}-{{ .Revision }}
  72. - precompiled-assets-{{ .Branch }}-
  73. - precompiled-assets-
  74. - run:
  75. name: Prepare Tests
  76. command: ./bin/rails parallel:create parallel:load_schema parallel:prepare
  77. - run:
  78. name: Run Tests
  79. command: ./bin/retry bundle exec parallel_test ./spec/ --group-by filesize --type rspec
  80. jobs:
  81. install:
  82. <<: *defaults
  83. <<: *install_steps
  84. install-ruby2.5:
  85. <<: *defaults
  86. <<: *install_ruby_dependencies
  87. install-ruby2.4:
  88. <<: *defaults
  89. docker:
  90. - image: circleci/ruby:2.4.4-stretch-node
  91. environment: *ruby_environment
  92. <<: *install_ruby_dependencies
  93. build:
  94. <<: *defaults
  95. steps:
  96. - *attach_workspace
  97. - *install_system_dependencies
  98. - run: ruby -e 'puts RUBY_VERSION' | tee /tmp/.ruby-version
  99. - *restore_ruby_dependencies
  100. - run: ./bin/rails assets:precompile
  101. - save_cache:
  102. key: precompiled-assets-{{ .Branch }}-{{ .Revision }}
  103. paths:
  104. - ./public/assets
  105. - ./public/packs-test/
  106. test-ruby2.5:
  107. <<: *defaults
  108. docker:
  109. - image: circleci/ruby:2.5.1-stretch-node
  110. environment: *ruby_environment
  111. - image: circleci/postgres:10.3-alpine
  112. environment:
  113. POSTGRES_USER: root
  114. - image: circleci/redis:4.0.9-alpine
  115. <<: *test_steps
  116. test-ruby2.4:
  117. <<: *defaults
  118. docker:
  119. - image: circleci/ruby:2.4.4-stretch-node
  120. environment: *ruby_environment
  121. - image: circleci/postgres:10.3-alpine
  122. environment:
  123. POSTGRES_USER: root
  124. - image: circleci/redis:4.0.9-alpine
  125. <<: *test_steps
  126. test-webui:
  127. <<: *defaults
  128. docker:
  129. - image: circleci/node:8.11.1-stretch
  130. steps:
  131. - *attach_workspace
  132. - run: ./bin/retry yarn test:jest
  133. check-i18n:
  134. <<: *defaults
  135. steps:
  136. - *attach_workspace
  137. - run: ruby -e 'puts RUBY_VERSION' | tee /tmp/.ruby-version
  138. - *restore_ruby_dependencies
  139. - run: bundle exec i18n-tasks check-normalized
  140. - run: bundle exec i18n-tasks unused
  141. workflows:
  142. version: 2
  143. build-and-test:
  144. jobs:
  145. - install
  146. - install-ruby2.5:
  147. requires:
  148. - install
  149. - install-ruby2.4:
  150. requires:
  151. - install
  152. - build:
  153. requires:
  154. - install-ruby2.5
  155. - test-ruby2.5:
  156. requires:
  157. - install-ruby2.5
  158. - build
  159. - test-ruby2.4:
  160. requires:
  161. - install-ruby2.4
  162. - build
  163. - test-webui:
  164. requires:
  165. - install
  166. - check-i18n:
  167. requires:
  168. - install-ruby2.5