config.yml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. version: 2.1
  2. orbs:
  3. ruby: circleci/ruby@1.4.1
  4. node: circleci/node@5.0.1
  5. executors:
  6. default:
  7. parameters:
  8. ruby-version:
  9. type: string
  10. docker:
  11. - image: cimg/ruby:<< parameters.ruby-version >>
  12. environment:
  13. BUNDLE_JOBS: 3
  14. BUNDLE_RETRY: 3
  15. CONTINUOUS_INTEGRATION: true
  16. DB_HOST: localhost
  17. DB_USER: root
  18. DISABLE_SIMPLECOV: true
  19. RAILS_ENV: test
  20. - image: cimg/postgres:14.0
  21. environment:
  22. POSTGRES_USER: root
  23. POSTGRES_HOST_AUTH_METHOD: trust
  24. - image: cimg/redis:6.2
  25. commands:
  26. install-system-dependencies:
  27. steps:
  28. - run:
  29. name: Install system dependencies
  30. command: |
  31. sudo apt-get update
  32. sudo apt-get install -y libicu-dev libidn11-dev
  33. install-ruby-dependencies:
  34. parameters:
  35. ruby-version:
  36. type: string
  37. steps:
  38. - run:
  39. command: |
  40. bundle config clean 'true'
  41. bundle config frozen 'true'
  42. bundle config without 'development production'
  43. name: Set bundler settings
  44. - ruby/install-deps:
  45. bundler-version: '2.3.8'
  46. key: ruby<< parameters.ruby-version >>-gems-v1
  47. wait-db:
  48. steps:
  49. - run:
  50. command: dockerize -wait tcp://localhost:5432 -wait tcp://localhost:6379 -timeout 1m
  51. name: Wait for PostgreSQL and Redis
  52. jobs:
  53. build:
  54. docker:
  55. - image: cimg/ruby:3.0-node
  56. environment:
  57. RAILS_ENV: test
  58. steps:
  59. - checkout
  60. - install-system-dependencies
  61. - install-ruby-dependencies:
  62. ruby-version: '3.0'
  63. - node/install-packages:
  64. cache-version: v1
  65. pkg-manager: yarn
  66. - run:
  67. command: ./bin/rails assets:precompile
  68. name: Precompile assets
  69. - persist_to_workspace:
  70. paths:
  71. - public/assets
  72. - public/packs-test
  73. root: .
  74. test:
  75. parameters:
  76. ruby-version:
  77. type: string
  78. executor:
  79. name: default
  80. ruby-version: << parameters.ruby-version >>
  81. environment:
  82. ALLOW_NOPAM: true
  83. PAM_ENABLED: true
  84. PAM_DEFAULT_SERVICE: pam_test
  85. PAM_CONTROLLED_SERVICE: pam_test_controlled
  86. parallelism: 4
  87. steps:
  88. - checkout
  89. - install-system-dependencies
  90. - run:
  91. command: sudo apt-get install -y ffmpeg imagemagick libpam-dev
  92. name: Install additional system dependencies
  93. - run:
  94. command: bundle config with 'pam_authentication'
  95. name: Enable PAM authentication
  96. - install-ruby-dependencies:
  97. ruby-version: << parameters.ruby-version >>
  98. - attach_workspace:
  99. at: .
  100. - wait-db
  101. - run:
  102. command: ./bin/rails db:create db:schema:load db:seed
  103. name: Load database schema
  104. - ruby/rspec-test
  105. test-migrations:
  106. executor:
  107. name: default
  108. ruby-version: '3.0'
  109. steps:
  110. - checkout
  111. - install-system-dependencies
  112. - install-ruby-dependencies:
  113. ruby-version: '3.0'
  114. - wait-db
  115. - run:
  116. command: ./bin/rails db:create
  117. name: Create database
  118. - run:
  119. command: ./bin/rails db:migrate VERSION=20171010025614
  120. name: Run migrations up to v2.0.0
  121. - run:
  122. command: ./bin/rails tests:migrations:populate_v2
  123. name: Populate database with test data
  124. - run:
  125. command: ./bin/rails db:migrate VERSION=20180514140000
  126. name: Run migrations up to v2.4.0
  127. - run:
  128. command: ./bin/rails tests:migrations:populate_v2_4
  129. name: Populate database with test data
  130. - run:
  131. command: ./bin/rails db:migrate VERSION=20180707154237
  132. name: Run migrations up to v2.4.3
  133. - run:
  134. command: ./bin/rails tests:migrations:populate_v2_4_3
  135. name: Populate database with test data
  136. - run:
  137. command: ./bin/rails db:migrate
  138. name: Run all remaining migrations
  139. - run:
  140. command: ./bin/rails tests:migrations:check_database
  141. name: Check migration result
  142. test-two-step-migrations:
  143. executor:
  144. name: default
  145. ruby-version: '3.0'
  146. steps:
  147. - checkout
  148. - install-system-dependencies
  149. - install-ruby-dependencies:
  150. ruby-version: '3.0'
  151. - wait-db
  152. - run:
  153. command: ./bin/rails db:create
  154. name: Create database
  155. - run:
  156. command: ./bin/rails db:migrate VERSION=20171010025614
  157. name: Run migrations up to v2.0.0
  158. - run:
  159. command: ./bin/rails tests:migrations:populate_v2
  160. name: Populate database with test data
  161. - run:
  162. command: ./bin/rails db:migrate VERSION=20180514140000
  163. name: Run pre-deployment migrations up to v2.4.0
  164. environment:
  165. SKIP_POST_DEPLOYMENT_MIGRATIONS: true
  166. - run:
  167. command: ./bin/rails tests:migrations:populate_v2_4
  168. name: Populate database with test data
  169. - run:
  170. command: ./bin/rails db:migrate VERSION=20180707154237
  171. name: Run migrations up to v2.4.3
  172. environment:
  173. SKIP_POST_DEPLOYMENT_MIGRATIONS: true
  174. - run:
  175. command: ./bin/rails tests:migrations:populate_v2_4_3
  176. name: Populate database with test data
  177. - run:
  178. command: ./bin/rails db:migrate
  179. name: Run all remaining pre-deployment migrations
  180. environment:
  181. SKIP_POST_DEPLOYMENT_MIGRATIONS: true
  182. - run:
  183. command: ./bin/rails db:migrate
  184. name: Run all post-deployment migrations
  185. - run:
  186. command: ./bin/rails tests:migrations:check_database
  187. name: Check migration result
  188. workflows:
  189. version: 2
  190. build-and-test:
  191. jobs:
  192. - build
  193. - test:
  194. matrix:
  195. parameters:
  196. ruby-version:
  197. - '2.7'
  198. - '3.0'
  199. name: test-ruby<< matrix.ruby-version >>
  200. requires:
  201. - build
  202. - test-migrations:
  203. requires:
  204. - build
  205. - test-two-step-migrations:
  206. requires:
  207. - build
  208. - node/run:
  209. cache-version: v1
  210. name: test-webui
  211. pkg-manager: yarn
  212. requires:
  213. - build
  214. version: lts
  215. yarn-run: test:jest