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.

189 lines
5.0 KiB

  1. version: 2.1
  2. orbs:
  3. ruby: circleci/ruby@1.2.0
  4. node: circleci/node@4.7.0
  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: circleci/redis:6-alpine
  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 libprotobuf-dev protobuf-compiler
  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.2.31'
  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
  126. name: Run all remaining migrations
  127. test-two-step-migrations:
  128. executor:
  129. name: default
  130. ruby-version: '3.0'
  131. steps:
  132. - checkout
  133. - install-system-dependencies
  134. - install-ruby-dependencies:
  135. ruby-version: '3.0'
  136. - wait-db
  137. - run:
  138. command: ./bin/rails db:create
  139. name: Create database
  140. - run:
  141. command: ./bin/rails db:migrate VERSION=20171010025614
  142. name: Run migrations up to v2.0.0
  143. - run:
  144. command: ./bin/rails tests:migrations:populate_v2
  145. name: Populate database with test data
  146. - run:
  147. command: ./bin/rails db:migrate
  148. name: Run all pre-deployment migrations
  149. evironment:
  150. SKIP_POST_DEPLOYMENT_MIGRATIONS: true
  151. - run:
  152. command: ./bin/rails db:migrate
  153. name: Run all post-deployment remaining migrations
  154. workflows:
  155. version: 2
  156. build-and-test:
  157. jobs:
  158. - build
  159. - test:
  160. matrix:
  161. parameters:
  162. ruby-version:
  163. - '2.7'
  164. - '3.0'
  165. name: test-ruby<< matrix.ruby-version >>
  166. requires:
  167. - build
  168. - test-migrations:
  169. requires:
  170. - build
  171. - test-two-step-migrations:
  172. requires:
  173. - build
  174. - node/run:
  175. cache-version: v1
  176. name: test-webui
  177. pkg-manager: yarn
  178. requires:
  179. - build
  180. version: lts
  181. yarn-run: test:jest