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.

128 lines
3.3 KiB

  1. version: 2.1
  2. orbs:
  3. ruby: circleci/ruby@2.0.0
  4. node: circleci/node@5.0.3
  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.5
  21. environment:
  22. POSTGRES_USER: root
  23. POSTGRES_HOST_AUTH_METHOD: trust
  24. - image: cimg/redis:7.0
  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.26'
  46. key: ruby<< parameters.ruby-version >>-gems-v2
  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.2-node
  56. environment:
  57. RAILS_ENV: test
  58. steps:
  59. - checkout
  60. - install-system-dependencies
  61. - install-ruby-dependencies:
  62. ruby-version: '3.2'
  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 libmagickcore-dev libmagickwand-dev libjpeg-dev libpng-dev libtiff-dev libwebp-dev 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. workflows:
  108. version: 2
  109. build-and-test:
  110. jobs:
  111. - build
  112. - test:
  113. matrix:
  114. parameters:
  115. ruby-version:
  116. - '2.7'
  117. - '3.0'
  118. - '3.1'
  119. - '3.2'
  120. name: test-ruby<< matrix.ruby-version >>
  121. requires:
  122. - build