1
0

test-ruby.yml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  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.2'
  110. - '.ruby-version'
  111. steps:
  112. - uses: actions/checkout@v4
  113. - uses: actions/download-artifact@v4
  114. with:
  115. path: './'
  116. name: ${{ github.sha }}
  117. - name: Expand archived asset artifacts
  118. run: |
  119. tar xvzf artifacts.tar.gz
  120. - name: Set up Ruby environment
  121. uses: ./.github/actions/setup-ruby
  122. with:
  123. ruby-version: ${{ matrix.ruby-version}}
  124. additional-system-dependencies: ffmpeg imagemagick libpam-dev
  125. - name: Load database schema
  126. run: |
  127. bin/rails db:setup
  128. bin/flatware fan bin/rails db:test:prepare
  129. - name: Cache RSpec persistence file
  130. uses: actions/cache@v4
  131. with:
  132. path: |
  133. tmp/rspec/examples.txt
  134. key: rspec-persistence-${{ github.head_ref || github.ref_name }}-${{ github.sha }}
  135. restore-keys: |
  136. rspec-persistence-${{ github.head_ref || github.ref_name }}-${{ github.sha }}-${{ matrix.ruby-version }}
  137. rspec-persistence-${{ github.head_ref || github.ref_name }}-${{ github.sha }}
  138. rspec-persistence-${{ github.head_ref || github.ref_name }}
  139. rspec-persistence-main
  140. rspec-persistence
  141. - run: bin/flatware rspec -r ./spec/flatware_helper.rb
  142. - name: Upload coverage reports to Codecov
  143. if: matrix.ruby-version == '.ruby-version'
  144. uses: codecov/codecov-action@v4
  145. with:
  146. files: coverage/lcov/*.lcov
  147. env:
  148. CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
  149. test-libvips:
  150. name: Libvips tests
  151. runs-on: ubuntu-24.04
  152. needs:
  153. - build
  154. services:
  155. postgres:
  156. image: postgres:14-alpine
  157. env:
  158. POSTGRES_PASSWORD: postgres
  159. POSTGRES_USER: postgres
  160. options: >-
  161. --health-cmd pg_isready
  162. --health-interval 10ms
  163. --health-timeout 3s
  164. --health-retries 50
  165. ports:
  166. - 5432:5432
  167. redis:
  168. image: redis:7-alpine
  169. options: >-
  170. --health-cmd "redis-cli ping"
  171. --health-interval 10ms
  172. --health-timeout 3s
  173. --health-retries 50
  174. ports:
  175. - 6379:6379
  176. env:
  177. DB_HOST: localhost
  178. DB_USER: postgres
  179. DB_PASS: postgres
  180. DISABLE_SIMPLECOV: ${{ matrix.ruby-version != '.ruby-version' }}
  181. RAILS_ENV: test
  182. ALLOW_NOPAM: true
  183. PAM_ENABLED: true
  184. PAM_DEFAULT_SERVICE: pam_test
  185. PAM_CONTROLLED_SERVICE: pam_test_controlled
  186. OIDC_ENABLED: true
  187. OIDC_SCOPE: read
  188. SAML_ENABLED: true
  189. CAS_ENABLED: true
  190. BUNDLE_WITH: 'pam_authentication test'
  191. GITHUB_RSPEC: ${{ matrix.ruby-version == '.ruby-version' && github.event.pull_request && 'true' }}
  192. MASTODON_USE_LIBVIPS: true
  193. strategy:
  194. fail-fast: false
  195. matrix:
  196. ruby-version:
  197. - '3.2'
  198. - '.ruby-version'
  199. steps:
  200. - uses: actions/checkout@v4
  201. - uses: actions/download-artifact@v4
  202. with:
  203. path: './'
  204. name: ${{ github.sha }}
  205. - name: Expand archived asset artifacts
  206. run: |
  207. tar xvzf artifacts.tar.gz
  208. - name: Set up Ruby environment
  209. uses: ./.github/actions/setup-ruby
  210. with:
  211. ruby-version: ${{ matrix.ruby-version}}
  212. additional-system-dependencies: ffmpeg libpam-dev
  213. - name: Load database schema
  214. run: './bin/rails db:create db:schema:load db:seed'
  215. - run: bin/rspec --tag attachment_processing
  216. - name: Upload coverage reports to Codecov
  217. if: matrix.ruby-version == '.ruby-version'
  218. uses: codecov/codecov-action@v4
  219. with:
  220. files: coverage/lcov/mastodon.lcov
  221. env:
  222. CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
  223. test-e2e:
  224. name: End to End testing
  225. runs-on: ubuntu-latest
  226. needs:
  227. - build
  228. services:
  229. postgres:
  230. image: postgres:14-alpine
  231. env:
  232. POSTGRES_PASSWORD: postgres
  233. POSTGRES_USER: postgres
  234. options: >-
  235. --health-cmd pg_isready
  236. --health-interval 10ms
  237. --health-timeout 3s
  238. --health-retries 50
  239. ports:
  240. - 5432:5432
  241. redis:
  242. image: redis:7-alpine
  243. options: >-
  244. --health-cmd "redis-cli ping"
  245. --health-interval 10ms
  246. --health-timeout 3s
  247. --health-retries 50
  248. ports:
  249. - 6379:6379
  250. env:
  251. DB_HOST: localhost
  252. DB_USER: postgres
  253. DB_PASS: postgres
  254. DISABLE_SIMPLECOV: true
  255. RAILS_ENV: test
  256. BUNDLE_WITH: test
  257. LOCAL_DOMAIN: localhost:3000
  258. LOCAL_HTTPS: false
  259. strategy:
  260. fail-fast: false
  261. matrix:
  262. ruby-version:
  263. - '3.2'
  264. - '.ruby-version'
  265. steps:
  266. - uses: actions/checkout@v4
  267. - uses: actions/download-artifact@v4
  268. with:
  269. path: './'
  270. name: ${{ github.sha }}
  271. - name: Expand archived asset artifacts
  272. run: |
  273. tar xvzf artifacts.tar.gz
  274. - name: Set up Ruby environment
  275. uses: ./.github/actions/setup-ruby
  276. with:
  277. ruby-version: ${{ matrix.ruby-version}}
  278. additional-system-dependencies: ffmpeg imagemagick
  279. - name: Set up Javascript environment
  280. uses: ./.github/actions/setup-javascript
  281. - name: Load database schema
  282. run: './bin/rails db:create db:schema:load db:seed'
  283. - run: bin/rspec spec/system --tag streaming --tag js
  284. - name: Archive logs
  285. uses: actions/upload-artifact@v4
  286. if: failure()
  287. with:
  288. name: e2e-logs-${{ matrix.ruby-version }}
  289. path: log/
  290. - name: Archive test screenshots
  291. uses: actions/upload-artifact@v4
  292. if: failure()
  293. with:
  294. name: e2e-screenshots
  295. path: tmp/capybara/
  296. test-search:
  297. name: Elastic Search integration testing
  298. runs-on: ubuntu-latest
  299. needs:
  300. - build
  301. services:
  302. postgres:
  303. image: postgres:14-alpine
  304. env:
  305. POSTGRES_PASSWORD: postgres
  306. POSTGRES_USER: postgres
  307. options: >-
  308. --health-cmd pg_isready
  309. --health-interval 10ms
  310. --health-timeout 3s
  311. --health-retries 50
  312. ports:
  313. - 5432:5432
  314. redis:
  315. image: redis:7-alpine
  316. options: >-
  317. --health-cmd "redis-cli ping"
  318. --health-interval 10ms
  319. --health-timeout 3s
  320. --health-retries 50
  321. ports:
  322. - 6379:6379
  323. elasticsearch:
  324. image: ${{ contains(matrix.search-image, 'elasticsearch') && matrix.search-image || '' }}
  325. env:
  326. discovery.type: single-node
  327. xpack.security.enabled: false
  328. options: >-
  329. --health-cmd "curl http://localhost:9200/_cluster/health"
  330. --health-interval 2s
  331. --health-timeout 3s
  332. --health-retries 50
  333. ports:
  334. - 9200:9200
  335. opensearch:
  336. image: ${{ contains(matrix.search-image, 'opensearch') && matrix.search-image || '' }}
  337. env:
  338. discovery.type: single-node
  339. DISABLE_INSTALL_DEMO_CONFIG: true
  340. DISABLE_SECURITY_PLUGIN: true
  341. options: >-
  342. --health-cmd "curl http://localhost:9200/_cluster/health"
  343. --health-interval 2s
  344. --health-timeout 3s
  345. --health-retries 50
  346. ports:
  347. - 9200:9200
  348. env:
  349. DB_HOST: localhost
  350. DB_USER: postgres
  351. DB_PASS: postgres
  352. DISABLE_SIMPLECOV: true
  353. RAILS_ENV: test
  354. BUNDLE_WITH: test
  355. ES_ENABLED: true
  356. ES_HOST: localhost
  357. ES_PORT: 9200
  358. strategy:
  359. fail-fast: false
  360. matrix:
  361. ruby-version:
  362. - '3.2'
  363. - '.ruby-version'
  364. search-image:
  365. - docker.elastic.co/elasticsearch/elasticsearch:7.17.13
  366. include:
  367. - ruby-version: '.ruby-version'
  368. search-image: docker.elastic.co/elasticsearch/elasticsearch:8.10.2
  369. - ruby-version: '.ruby-version'
  370. search-image: opensearchproject/opensearch:2
  371. steps:
  372. - uses: actions/checkout@v4
  373. - uses: actions/download-artifact@v4
  374. with:
  375. path: './'
  376. name: ${{ github.sha }}
  377. - name: Set up Ruby environment
  378. uses: ./.github/actions/setup-ruby
  379. with:
  380. ruby-version: ${{ matrix.ruby-version}}
  381. additional-system-dependencies: ffmpeg imagemagick
  382. - name: Set up Javascript environment
  383. uses: ./.github/actions/setup-javascript
  384. - name: Load database schema
  385. run: './bin/rails db:create db:schema:load db:seed'
  386. - run: bin/rspec --tag search
  387. - name: Archive logs
  388. uses: actions/upload-artifact@v4
  389. if: failure()
  390. with:
  391. name: test-search-logs-${{ matrix.ruby-version }}
  392. path: log/
  393. - name: Archive test screenshots
  394. uses: actions/upload-artifact@v4
  395. if: failure()
  396. with:
  397. name: test-search-screenshots
  398. path: tmp/capybara/