config.yml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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: |
  68. export NODE_OPTIONS=--openssl-legacy-provider
  69. ./bin/rails assets:precompile
  70. name: Precompile assets
  71. - persist_to_workspace:
  72. paths:
  73. - public/assets
  74. - public/packs-test
  75. root: .
  76. test:
  77. parameters:
  78. ruby-version:
  79. type: string
  80. executor:
  81. name: default
  82. ruby-version: << parameters.ruby-version >>
  83. environment:
  84. ALLOW_NOPAM: true
  85. PAM_ENABLED: true
  86. PAM_DEFAULT_SERVICE: pam_test
  87. PAM_CONTROLLED_SERVICE: pam_test_controlled
  88. parallelism: 4
  89. steps:
  90. - checkout
  91. - install-system-dependencies
  92. - run:
  93. command: sudo apt-get install -y ffmpeg imagemagick libpam-dev
  94. name: Install additional system dependencies
  95. - run:
  96. command: bundle config with 'pam_authentication'
  97. name: Enable PAM authentication
  98. - install-ruby-dependencies:
  99. ruby-version: << parameters.ruby-version >>
  100. - attach_workspace:
  101. at: .
  102. - wait-db
  103. - run:
  104. command: ./bin/rails db:create db:schema:load db:seed
  105. name: Load database schema
  106. - ruby/rspec-test
  107. test-migrations:
  108. executor:
  109. name: default
  110. ruby-version: '3.0'
  111. steps:
  112. - checkout
  113. - install-system-dependencies
  114. - install-ruby-dependencies:
  115. ruby-version: '3.0'
  116. - wait-db
  117. - run:
  118. command: ./bin/rails db:create
  119. name: Create database
  120. - run:
  121. command: ./bin/rails db:migrate VERSION=20171010025614
  122. name: Run migrations up to v2.0.0
  123. - run:
  124. command: ./bin/rails tests:migrations:populate_v2
  125. name: Populate database with test data
  126. - run:
  127. command: ./bin/rails db:migrate VERSION=20180514140000
  128. name: Run migrations up to v2.4.0
  129. - run:
  130. command: ./bin/rails tests:migrations:populate_v2_4
  131. name: Populate database with test data
  132. - run:
  133. command: ./bin/rails db:migrate VERSION=20180707154237
  134. name: Run migrations up to v2.4.3
  135. - run:
  136. command: ./bin/rails tests:migrations:populate_v2_4_3
  137. name: Populate database with test data
  138. - run:
  139. command: ./bin/rails db:migrate
  140. name: Run all remaining migrations
  141. - run:
  142. command: ./bin/rails tests:migrations:check_database
  143. name: Check migration result
  144. test-two-step-migrations:
  145. executor:
  146. name: default
  147. ruby-version: '3.0'
  148. steps:
  149. - checkout
  150. - install-system-dependencies
  151. - install-ruby-dependencies:
  152. ruby-version: '3.0'
  153. - wait-db
  154. - run:
  155. command: ./bin/rails db:create
  156. name: Create database
  157. - run:
  158. command: ./bin/rails db:migrate VERSION=20171010025614
  159. name: Run migrations up to v2.0.0
  160. - run:
  161. command: ./bin/rails tests:migrations:populate_v2
  162. name: Populate database with test data
  163. - run:
  164. command: ./bin/rails db:migrate VERSION=20180514140000
  165. name: Run pre-deployment migrations up to v2.4.0
  166. environment:
  167. SKIP_POST_DEPLOYMENT_MIGRATIONS: true
  168. - run:
  169. command: ./bin/rails tests:migrations:populate_v2_4
  170. name: Populate database with test data
  171. - run:
  172. command: ./bin/rails db:migrate VERSION=20180707154237
  173. name: Run migrations up to v2.4.3
  174. environment:
  175. SKIP_POST_DEPLOYMENT_MIGRATIONS: true
  176. - run:
  177. command: ./bin/rails tests:migrations:populate_v2_4_3
  178. name: Populate database with test data
  179. - run:
  180. command: ./bin/rails db:migrate
  181. name: Run all remaining pre-deployment migrations
  182. environment:
  183. SKIP_POST_DEPLOYMENT_MIGRATIONS: true
  184. - run:
  185. command: ./bin/rails db:migrate
  186. name: Run all post-deployment migrations
  187. - run:
  188. command: ./bin/rails tests:migrations:check_database
  189. name: Check migration result
  190. workflows:
  191. version: 2
  192. build-and-test:
  193. jobs:
  194. - build
  195. - test:
  196. matrix:
  197. parameters:
  198. ruby-version:
  199. - '2.7'
  200. - '3.0'
  201. name: test-ruby<< matrix.ruby-version >>
  202. requires:
  203. - build
  204. - test-migrations:
  205. requires:
  206. - build
  207. - test-two-step-migrations:
  208. requires:
  209. - build
  210. - node/run:
  211. cache-version: v1
  212. name: test-webui
  213. pkg-manager: yarn
  214. requires:
  215. - build
  216. version: lts
  217. yarn-run: test:jest