test-ruby.yml 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. name: Ruby Testing
  2. on:
  3. push:
  4. branches-ignore:
  5. - 'dependabot/**'
  6. - 'renovate/**'
  7. pull_request:
  8. env:
  9. BUNDLE_CLEAN: true
  10. BUNDLE_FROZEN: true
  11. concurrency:
  12. group: ${{ github.workflow }}-${{ github.ref }}
  13. cancel-in-progress: true
  14. jobs:
  15. build:
  16. runs-on: ubuntu-latest
  17. strategy:
  18. fail-fast: true
  19. matrix:
  20. mode:
  21. - production
  22. - test
  23. env:
  24. RAILS_ENV: ${{ matrix.mode }}
  25. BUNDLE_WITH: ${{ matrix.mode }}
  26. OTP_SECRET: precompile_placeholder
  27. SECRET_KEY_BASE: precompile_placeholder
  28. steps:
  29. - uses: actions/checkout@v4
  30. - name: Set up Ruby environment
  31. uses: ./.github/actions/setup-ruby
  32. - name: Set up Javascript environment
  33. uses: ./.github/actions/setup-javascript
  34. with:
  35. onlyProduction: 'true'
  36. - name: Precompile assets
  37. # Previously had set this, but it's not supported
  38. # export NODE_OPTIONS=--openssl-legacy-provider
  39. run: |-
  40. ./bin/rails assets:precompile
  41. - name: Archive asset artifacts
  42. run: |
  43. tar --exclude={"*.br","*.gz"} -zcf artifacts.tar.gz public/assets public/packs*
  44. - uses: actions/upload-artifact@v4
  45. if: matrix.mode == 'test'
  46. with:
  47. path: |-
  48. ./artifacts.tar.gz
  49. name: ${{ github.sha }}
  50. retention-days: 0
  51. test:
  52. runs-on: ubuntu-latest
  53. needs:
  54. - build
  55. services:
  56. postgres:
  57. image: postgres:14-alpine
  58. env:
  59. POSTGRES_PASSWORD: postgres
  60. POSTGRES_USER: postgres
  61. options: >-
  62. --health-cmd pg_isready
  63. --health-interval 10s
  64. --health-timeout 5s
  65. --health-retries 5
  66. ports:
  67. - 5432:5432
  68. redis:
  69. image: redis:7-alpine
  70. options: >-
  71. --health-cmd "redis-cli ping"
  72. --health-interval 10s
  73. --health-timeout 5s
  74. --health-retries 5
  75. ports:
  76. - 6379:6379
  77. env:
  78. DB_HOST: localhost
  79. DB_USER: postgres
  80. DB_PASS: postgres
  81. DISABLE_SIMPLECOV: ${{ matrix.ruby-version != '.ruby-version' }}
  82. RAILS_ENV: test
  83. ALLOW_NOPAM: true
  84. PAM_ENABLED: true
  85. PAM_DEFAULT_SERVICE: pam_test
  86. PAM_CONTROLLED_SERVICE: pam_test_controlled
  87. OIDC_ENABLED: true
  88. OIDC_SCOPE: read
  89. SAML_ENABLED: true
  90. CAS_ENABLED: true
  91. BUNDLE_WITH: 'pam_authentication test'
  92. GITHUB_RSPEC: ${{ matrix.ruby-version == '.ruby-version' && github.event.pull_request && 'true' }}
  93. strategy:
  94. fail-fast: false
  95. matrix:
  96. ruby-version:
  97. - '3.0'
  98. - '3.1'
  99. - '.ruby-version'
  100. steps:
  101. - uses: actions/checkout@v4
  102. - uses: actions/download-artifact@v4
  103. with:
  104. path: './'
  105. name: ${{ github.sha }}
  106. - name: Expand archived asset artifacts
  107. run: |
  108. tar xvzf artifacts.tar.gz
  109. - name: Set up Ruby environment
  110. uses: ./.github/actions/setup-ruby
  111. with:
  112. ruby-version: ${{ matrix.ruby-version}}
  113. additional-system-dependencies: ffmpeg imagemagick libpam-dev
  114. - name: Load database schema
  115. run: './bin/rails db:create db:schema:load db:seed'
  116. - run: bin/rspec
  117. - name: Upload coverage reports to Codecov
  118. if: matrix.ruby-version == '.ruby-version'
  119. uses: codecov/codecov-action@v4
  120. with:
  121. files: coverage/lcov/mastodon.lcov
  122. test-e2e:
  123. name: End to End testing
  124. runs-on: ubuntu-latest
  125. needs:
  126. - build
  127. services:
  128. postgres:
  129. image: postgres:14-alpine
  130. env:
  131. POSTGRES_PASSWORD: postgres
  132. POSTGRES_USER: postgres
  133. options: >-
  134. --health-cmd pg_isready
  135. --health-interval 10s
  136. --health-timeout 5s
  137. --health-retries 5
  138. ports:
  139. - 5432:5432
  140. redis:
  141. image: redis:7-alpine
  142. options: >-
  143. --health-cmd "redis-cli ping"
  144. --health-interval 10s
  145. --health-timeout 5s
  146. --health-retries 5
  147. ports:
  148. - 6379:6379
  149. env:
  150. DB_HOST: localhost
  151. DB_USER: postgres
  152. DB_PASS: postgres
  153. DISABLE_SIMPLECOV: true
  154. RAILS_ENV: test
  155. BUNDLE_WITH: test
  156. strategy:
  157. fail-fast: false
  158. matrix:
  159. ruby-version:
  160. - '3.0'
  161. - '3.1'
  162. - '.ruby-version'
  163. steps:
  164. - uses: actions/checkout@v4
  165. - uses: actions/download-artifact@v4
  166. with:
  167. path: './public'
  168. name: ${{ github.sha }}
  169. - name: Set up Ruby environment
  170. uses: ./.github/actions/setup-ruby
  171. with:
  172. ruby-version: ${{ matrix.ruby-version}}
  173. additional-system-dependencies: ffmpeg imagemagick
  174. - name: Set up Javascript environment
  175. uses: ./.github/actions/setup-javascript
  176. - name: Load database schema
  177. run: './bin/rails db:create db:schema:load db:seed'
  178. - run: bundle exec rake spec:system
  179. - name: Archive logs
  180. uses: actions/upload-artifact@v4
  181. if: failure()
  182. with:
  183. name: e2e-logs-${{ matrix.ruby-version }}
  184. path: log/
  185. - name: Archive test screenshots
  186. uses: actions/upload-artifact@v4
  187. if: failure()
  188. with:
  189. name: e2e-screenshots
  190. path: tmp/capybara/
  191. test-search:
  192. name: Elastic Search integration testing
  193. runs-on: ubuntu-latest
  194. needs:
  195. - build
  196. services:
  197. postgres:
  198. image: postgres:14-alpine
  199. env:
  200. POSTGRES_PASSWORD: postgres
  201. POSTGRES_USER: postgres
  202. options: >-
  203. --health-cmd pg_isready
  204. --health-interval 10s
  205. --health-timeout 5s
  206. --health-retries 5
  207. ports:
  208. - 5432:5432
  209. redis:
  210. image: redis:7-alpine
  211. options: >-
  212. --health-cmd "redis-cli ping"
  213. --health-interval 10s
  214. --health-timeout 5s
  215. --health-retries 5
  216. ports:
  217. - 6379:6379
  218. search:
  219. image: ${{ matrix.search-image }}
  220. env:
  221. discovery.type: single-node
  222. xpack.security.enabled: false
  223. options: >-
  224. --health-cmd "curl http://localhost:9200/_cluster/health"
  225. --health-interval 10s
  226. --health-timeout 5s
  227. --health-retries 10
  228. ports:
  229. - 9200:9200
  230. env:
  231. DB_HOST: localhost
  232. DB_USER: postgres
  233. DB_PASS: postgres
  234. DISABLE_SIMPLECOV: true
  235. RAILS_ENV: test
  236. BUNDLE_WITH: test
  237. ES_ENABLED: true
  238. ES_HOST: localhost
  239. ES_PORT: 9200
  240. strategy:
  241. fail-fast: false
  242. matrix:
  243. ruby-version:
  244. - '3.0'
  245. - '3.1'
  246. - '.ruby-version'
  247. search-image:
  248. - docker.elastic.co/elasticsearch/elasticsearch:7.17.13
  249. include:
  250. - ruby-version: '.ruby-version'
  251. search-image: docker.elastic.co/elasticsearch/elasticsearch:8.10.2
  252. steps:
  253. - uses: actions/checkout@v4
  254. - uses: actions/download-artifact@v4
  255. with:
  256. path: './public'
  257. name: ${{ github.sha }}
  258. - name: Set up Ruby environment
  259. uses: ./.github/actions/setup-ruby
  260. with:
  261. ruby-version: ${{ matrix.ruby-version}}
  262. additional-system-dependencies: ffmpeg imagemagick
  263. - name: Set up Javascript environment
  264. uses: ./.github/actions/setup-javascript
  265. - name: Load database schema
  266. run: './bin/rails db:create db:schema:load db:seed'
  267. - run: bin/rspec --tag search
  268. - name: Archive logs
  269. uses: actions/upload-artifact@v4
  270. if: failure()
  271. with:
  272. name: test-search-logs-${{ matrix.ruby-version }}
  273. path: log/
  274. - name: Archive test screenshots
  275. uses: actions/upload-artifact@v4
  276. if: failure()
  277. with:
  278. name: test-search-screenshots
  279. path: tmp/capybara/