test-ruby.yml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. name: Ruby Testing
  2. on:
  3. merge_group:
  4. push:
  5. branches:
  6. - 'main'
  7. - 'stable-*'
  8. pull_request:
  9. env:
  10. BUNDLE_CLEAN: true
  11. BUNDLE_FROZEN: true
  12. concurrency:
  13. group: ${{ github.workflow }}-${{ github.ref }}
  14. cancel-in-progress: true
  15. jobs:
  16. build:
  17. runs-on: ubuntu-latest
  18. strategy:
  19. fail-fast: true
  20. matrix:
  21. mode:
  22. - production
  23. - test
  24. env:
  25. RAILS_ENV: ${{ matrix.mode }}
  26. BUNDLE_WITH: ${{ matrix.mode }}
  27. SECRET_KEY_BASE_DUMMY: 1
  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: Cache assets from compilation
  37. uses: actions/cache@v4
  38. with:
  39. path: |
  40. public/assets
  41. public/packs
  42. public/packs-test
  43. tmp/cache/webpacker
  44. key: ${{ matrix.mode }}-assets-${{ github.head_ref || github.ref_name }}-${{ github.sha }}
  45. restore-keys: |
  46. ${{ matrix.mode }}-assets-${{ github.head_ref || github.ref_name }}-${{ github.sha }}
  47. ${{ matrix.mode }}-assets-${{ github.head_ref || github.ref_name }}
  48. ${{ matrix.mode }}-assets-main
  49. ${{ matrix.mode }}-assets
  50. - name: Precompile assets
  51. run: |-
  52. bin/rails assets:precompile
  53. - name: Archive asset artifacts
  54. run: |
  55. tar --exclude={"*.br","*.gz"} -zcf artifacts.tar.gz public/assets public/packs*
  56. - uses: actions/upload-artifact@v4
  57. if: matrix.mode == 'test'
  58. with:
  59. path: |-
  60. ./artifacts.tar.gz
  61. name: ${{ github.sha }}
  62. retention-days: 0
  63. test:
  64. runs-on: ubuntu-latest
  65. needs:
  66. - build
  67. services:
  68. postgres:
  69. image: postgres:14-alpine
  70. env:
  71. POSTGRES_PASSWORD: postgres
  72. POSTGRES_USER: postgres
  73. options: >-
  74. --health-cmd pg_isready
  75. --health-interval 10ms
  76. --health-timeout 3s
  77. --health-retries 50
  78. ports:
  79. - 5432:5432
  80. redis:
  81. image: redis:7-alpine
  82. options: >-
  83. --health-cmd "redis-cli ping"
  84. --health-interval 10ms
  85. --health-timeout 3s
  86. --health-retries 50
  87. ports:
  88. - 6379:6379
  89. env:
  90. DB_HOST: localhost
  91. DB_USER: postgres
  92. DB_PASS: postgres
  93. DISABLE_SIMPLECOV: ${{ matrix.ruby-version != '.ruby-version' }}
  94. RAILS_ENV: test
  95. ALLOW_NOPAM: true
  96. PAM_ENABLED: true
  97. PAM_DEFAULT_SERVICE: pam_test
  98. PAM_CONTROLLED_SERVICE: pam_test_controlled
  99. OIDC_ENABLED: true
  100. OIDC_SCOPE: read
  101. SAML_ENABLED: true
  102. CAS_ENABLED: true
  103. BUNDLE_WITH: 'pam_authentication test'
  104. GITHUB_RSPEC: ${{ matrix.ruby-version == '.ruby-version' && github.event.pull_request && 'true' }}
  105. strategy:
  106. fail-fast: false
  107. matrix:
  108. ruby-version:
  109. - '3.1'
  110. - '3.2'
  111. - '.ruby-version'
  112. steps:
  113. - uses: actions/checkout@v4
  114. - uses: actions/download-artifact@v4
  115. with:
  116. path: './'
  117. name: ${{ github.sha }}
  118. - name: Expand archived asset artifacts
  119. run: |
  120. tar xvzf artifacts.tar.gz
  121. - name: Set up Ruby environment
  122. uses: ./.github/actions/setup-ruby
  123. with:
  124. ruby-version: ${{ matrix.ruby-version}}
  125. additional-system-dependencies: ffmpeg imagemagick libpam-dev
  126. - name: Load database schema
  127. run: |
  128. bin/rails db:setup
  129. bin/flatware fan bin/rails db:test:prepare
  130. - name: Cache RSpec persistence file
  131. uses: actions/cache@v4
  132. with:
  133. path: |
  134. tmp/rspec/examples.txt
  135. key: rspec-persistence-${{ github.head_ref || github.ref_name }}-${{ github.sha }}
  136. restore-keys: |
  137. rspec-persistence-${{ github.head_ref || github.ref_name }}-${{ github.sha }}-${{ matrix.ruby-version }}
  138. rspec-persistence-${{ github.head_ref || github.ref_name }}-${{ github.sha }}
  139. rspec-persistence-${{ github.head_ref || github.ref_name }}
  140. rspec-persistence-main
  141. rspec-persistence
  142. - run: bin/flatware rspec -r ./spec/flatware_helper.rb
  143. - name: Upload coverage reports to Codecov
  144. if: matrix.ruby-version == '.ruby-version'
  145. uses: codecov/codecov-action@v4
  146. with:
  147. files: coverage/lcov/*.lcov
  148. env:
  149. CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
  150. test-libvips:
  151. name: Libvips tests
  152. runs-on: ubuntu-24.04
  153. needs:
  154. - build
  155. services:
  156. postgres:
  157. image: postgres:14-alpine
  158. env:
  159. POSTGRES_PASSWORD: postgres
  160. POSTGRES_USER: postgres
  161. options: >-
  162. --health-cmd pg_isready
  163. --health-interval 10ms
  164. --health-timeout 3s
  165. --health-retries 50
  166. ports:
  167. - 5432:5432
  168. redis:
  169. image: redis:7-alpine
  170. options: >-
  171. --health-cmd "redis-cli ping"
  172. --health-interval 10ms
  173. --health-timeout 3s
  174. --health-retries 50
  175. ports:
  176. - 6379:6379
  177. env:
  178. DB_HOST: localhost
  179. DB_USER: postgres
  180. DB_PASS: postgres
  181. DISABLE_SIMPLECOV: ${{ matrix.ruby-version != '.ruby-version' }}
  182. RAILS_ENV: test
  183. ALLOW_NOPAM: true
  184. PAM_ENABLED: true
  185. PAM_DEFAULT_SERVICE: pam_test
  186. PAM_CONTROLLED_SERVICE: pam_test_controlled
  187. OIDC_ENABLED: true
  188. OIDC_SCOPE: read
  189. SAML_ENABLED: true
  190. CAS_ENABLED: true
  191. BUNDLE_WITH: 'pam_authentication test'
  192. GITHUB_RSPEC: ${{ matrix.ruby-version == '.ruby-version' && github.event.pull_request && 'true' }}
  193. MASTODON_USE_LIBVIPS: true
  194. strategy:
  195. fail-fast: false
  196. matrix:
  197. ruby-version:
  198. - '3.1'
  199. - '3.2'
  200. - '.ruby-version'
  201. steps:
  202. - uses: actions/checkout@v4
  203. - uses: actions/download-artifact@v4
  204. with:
  205. path: './'
  206. name: ${{ github.sha }}
  207. - name: Expand archived asset artifacts
  208. run: |
  209. tar xvzf artifacts.tar.gz
  210. - name: Set up Ruby environment
  211. uses: ./.github/actions/setup-ruby
  212. with:
  213. ruby-version: ${{ matrix.ruby-version}}
  214. additional-system-dependencies: ffmpeg libpam-dev
  215. - name: Load database schema
  216. run: './bin/rails db:create db:schema:load db:seed'
  217. - run: bin/rspec --tag attachment_processing
  218. - name: Upload coverage reports to Codecov
  219. if: matrix.ruby-version == '.ruby-version'
  220. uses: codecov/codecov-action@v4
  221. with:
  222. files: coverage/lcov/mastodon.lcov
  223. env:
  224. CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
  225. test-e2e:
  226. name: End to End testing
  227. runs-on: ubuntu-latest
  228. needs:
  229. - build
  230. services:
  231. postgres:
  232. image: postgres:14-alpine
  233. env:
  234. POSTGRES_PASSWORD: postgres
  235. POSTGRES_USER: postgres
  236. options: >-
  237. --health-cmd pg_isready
  238. --health-interval 10ms
  239. --health-timeout 3s
  240. --health-retries 50
  241. ports:
  242. - 5432:5432
  243. redis:
  244. image: redis:7-alpine
  245. options: >-
  246. --health-cmd "redis-cli ping"
  247. --health-interval 10ms
  248. --health-timeout 3s
  249. --health-retries 50
  250. ports:
  251. - 6379:6379
  252. env:
  253. DB_HOST: localhost
  254. DB_USER: postgres
  255. DB_PASS: postgres
  256. DISABLE_SIMPLECOV: true
  257. RAILS_ENV: test
  258. BUNDLE_WITH: test
  259. LOCAL_DOMAIN: localhost:3000
  260. LOCAL_HTTPS: false
  261. strategy:
  262. fail-fast: false
  263. matrix:
  264. ruby-version:
  265. - '3.1'
  266. - '3.2'
  267. - '.ruby-version'
  268. steps:
  269. - uses: actions/checkout@v4
  270. - uses: actions/download-artifact@v4
  271. with:
  272. path: './'
  273. name: ${{ github.sha }}
  274. - name: Expand archived asset artifacts
  275. run: |
  276. tar xvzf artifacts.tar.gz
  277. - name: Set up Ruby environment
  278. uses: ./.github/actions/setup-ruby
  279. with:
  280. ruby-version: ${{ matrix.ruby-version}}
  281. additional-system-dependencies: ffmpeg imagemagick
  282. - name: Set up Javascript environment
  283. uses: ./.github/actions/setup-javascript
  284. - name: Load database schema
  285. run: './bin/rails db:create db:schema:load db:seed'
  286. - run: bin/rspec spec/system --tag streaming --tag js
  287. - name: Archive logs
  288. uses: actions/upload-artifact@v4
  289. if: failure()
  290. with:
  291. name: e2e-logs-${{ matrix.ruby-version }}
  292. path: log/
  293. - name: Archive test screenshots
  294. uses: actions/upload-artifact@v4
  295. if: failure()
  296. with:
  297. name: e2e-screenshots
  298. path: tmp/capybara/
  299. test-search:
  300. name: Elastic Search integration testing
  301. runs-on: ubuntu-latest
  302. needs:
  303. - build
  304. services:
  305. postgres:
  306. image: postgres:14-alpine
  307. env:
  308. POSTGRES_PASSWORD: postgres
  309. POSTGRES_USER: postgres
  310. options: >-
  311. --health-cmd pg_isready
  312. --health-interval 10ms
  313. --health-timeout 3s
  314. --health-retries 50
  315. ports:
  316. - 5432:5432
  317. redis:
  318. image: redis:7-alpine
  319. options: >-
  320. --health-cmd "redis-cli ping"
  321. --health-interval 10ms
  322. --health-timeout 3s
  323. --health-retries 50
  324. ports:
  325. - 6379:6379
  326. elasticsearch:
  327. image: ${{ contains(matrix.search-image, 'elasticsearch') && matrix.search-image || '' }}
  328. env:
  329. discovery.type: single-node
  330. xpack.security.enabled: false
  331. options: >-
  332. --health-cmd "curl http://localhost:9200/_cluster/health"
  333. --health-interval 2s
  334. --health-timeout 3s
  335. --health-retries 50
  336. ports:
  337. - 9200:9200
  338. opensearch:
  339. image: ${{ contains(matrix.search-image, 'opensearch') && matrix.search-image || '' }}
  340. env:
  341. discovery.type: single-node
  342. DISABLE_INSTALL_DEMO_CONFIG: true
  343. DISABLE_SECURITY_PLUGIN: true
  344. options: >-
  345. --health-cmd "curl http://localhost:9200/_cluster/health"
  346. --health-interval 2s
  347. --health-timeout 3s
  348. --health-retries 50
  349. ports:
  350. - 9200:9200
  351. env:
  352. DB_HOST: localhost
  353. DB_USER: postgres
  354. DB_PASS: postgres
  355. DISABLE_SIMPLECOV: true
  356. RAILS_ENV: test
  357. BUNDLE_WITH: test
  358. ES_ENABLED: true
  359. ES_HOST: localhost
  360. ES_PORT: 9200
  361. strategy:
  362. fail-fast: false
  363. matrix:
  364. ruby-version:
  365. - '3.1'
  366. - '3.2'
  367. - '.ruby-version'
  368. search-image:
  369. - docker.elastic.co/elasticsearch/elasticsearch:7.17.13
  370. include:
  371. - ruby-version: '.ruby-version'
  372. search-image: docker.elastic.co/elasticsearch/elasticsearch:8.10.2
  373. - ruby-version: '.ruby-version'
  374. search-image: opensearchproject/opensearch:2
  375. steps:
  376. - uses: actions/checkout@v4
  377. - uses: actions/download-artifact@v4
  378. with:
  379. path: './'
  380. name: ${{ github.sha }}
  381. - name: Set up Ruby environment
  382. uses: ./.github/actions/setup-ruby
  383. with:
  384. ruby-version: ${{ matrix.ruby-version}}
  385. additional-system-dependencies: ffmpeg imagemagick
  386. - name: Set up Javascript environment
  387. uses: ./.github/actions/setup-javascript
  388. - name: Load database schema
  389. run: './bin/rails db:create db:schema:load db:seed'
  390. - run: bin/rspec --tag search
  391. - name: Archive logs
  392. uses: actions/upload-artifact@v4
  393. if: failure()
  394. with:
  395. name: test-search-logs-${{ matrix.ruby-version }}
  396. path: log/
  397. - name: Archive test screenshots
  398. uses: actions/upload-artifact@v4
  399. if: failure()
  400. with:
  401. name: test-search-screenshots
  402. path: tmp/capybara/