gitea源码

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. name: db-tests
  2. on:
  3. pull_request:
  4. concurrency:
  5. group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  6. cancel-in-progress: true
  7. jobs:
  8. files-changed:
  9. uses: ./.github/workflows/files-changed.yml
  10. test-pgsql:
  11. if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.actions == 'true'
  12. needs: files-changed
  13. runs-on: ubuntu-latest
  14. services:
  15. pgsql:
  16. image: postgres:14
  17. env:
  18. POSTGRES_DB: test
  19. POSTGRES_PASSWORD: postgres
  20. ports:
  21. - "5432:5432"
  22. ldap:
  23. image: gitea/test-openldap:latest
  24. ports:
  25. - "389:389"
  26. - "636:636"
  27. minio:
  28. # as github actions doesn't support "entrypoint", we need to use a non-official image
  29. # that has a custom entrypoint set to "minio server /data"
  30. image: bitnamilegacy/minio:2023.8.31
  31. env:
  32. MINIO_ROOT_USER: 123456
  33. MINIO_ROOT_PASSWORD: 12345678
  34. ports:
  35. - "9000:9000"
  36. steps:
  37. - uses: actions/checkout@v4
  38. - uses: actions/setup-go@v5
  39. with:
  40. go-version-file: go.mod
  41. check-latest: true
  42. - name: Add hosts to /etc/hosts
  43. run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 pgsql ldap minio" | sudo tee -a /etc/hosts'
  44. - run: make deps-backend
  45. - run: make backend
  46. env:
  47. TAGS: bindata
  48. - name: run migration tests
  49. run: make test-pgsql-migration
  50. - name: run tests
  51. run: make test-pgsql
  52. timeout-minutes: 50
  53. env:
  54. TAGS: bindata gogit
  55. RACE_ENABLED: true
  56. TEST_TAGS: gogit
  57. TEST_LDAP: 1
  58. USE_REPO_TEST_DIR: 1
  59. test-sqlite:
  60. if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.actions == 'true'
  61. needs: files-changed
  62. runs-on: ubuntu-latest
  63. steps:
  64. - uses: actions/checkout@v4
  65. - uses: actions/setup-go@v5
  66. with:
  67. go-version-file: go.mod
  68. check-latest: true
  69. - run: make deps-backend
  70. - run: make backend
  71. env:
  72. TAGS: bindata gogit sqlite sqlite_unlock_notify
  73. - name: run migration tests
  74. run: make test-sqlite-migration
  75. - name: run tests
  76. run: make test-sqlite
  77. timeout-minutes: 50
  78. env:
  79. TAGS: bindata gogit sqlite sqlite_unlock_notify
  80. RACE_ENABLED: true
  81. TEST_TAGS: gogit sqlite sqlite_unlock_notify
  82. USE_REPO_TEST_DIR: 1
  83. test-unit:
  84. if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.actions == 'true'
  85. needs: files-changed
  86. runs-on: ubuntu-latest
  87. services:
  88. elasticsearch:
  89. image: elasticsearch:7.5.0
  90. env:
  91. discovery.type: single-node
  92. ports:
  93. - "9200:9200"
  94. meilisearch:
  95. image: getmeili/meilisearch:v1
  96. env:
  97. MEILI_ENV: development # disable auth
  98. ports:
  99. - "7700:7700"
  100. redis:
  101. image: redis
  102. options: >- # wait until redis has started
  103. --health-cmd "redis-cli ping"
  104. --health-interval 5s
  105. --health-timeout 3s
  106. --health-retries 10
  107. ports:
  108. - 6379:6379
  109. minio:
  110. image: bitnamilegacy/minio:2021.3.17
  111. env:
  112. MINIO_ACCESS_KEY: 123456
  113. MINIO_SECRET_KEY: 12345678
  114. ports:
  115. - "9000:9000"
  116. devstoreaccount1.azurite.local: # https://github.com/Azure/Azurite/issues/1583
  117. image: mcr.microsoft.com/azure-storage/azurite:latest
  118. ports:
  119. - 10000:10000
  120. steps:
  121. - uses: actions/checkout@v4
  122. - uses: actions/setup-go@v5
  123. with:
  124. go-version-file: go.mod
  125. check-latest: true
  126. - name: Add hosts to /etc/hosts
  127. run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 minio devstoreaccount1.azurite.local mysql elasticsearch meilisearch smtpimap" | sudo tee -a /etc/hosts'
  128. - run: make deps-backend
  129. - run: make backend
  130. env:
  131. TAGS: bindata
  132. - name: unit-tests
  133. run: make unit-test-coverage test-check
  134. env:
  135. TAGS: bindata
  136. RACE_ENABLED: true
  137. GITHUB_READ_TOKEN: ${{ secrets.GITHUB_READ_TOKEN }}
  138. - name: unit-tests-gogit
  139. run: make unit-test-coverage test-check
  140. env:
  141. TAGS: bindata gogit
  142. RACE_ENABLED: true
  143. GITHUB_READ_TOKEN: ${{ secrets.GITHUB_READ_TOKEN }}
  144. test-mysql:
  145. if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.actions == 'true'
  146. needs: files-changed
  147. runs-on: ubuntu-latest
  148. services:
  149. mysql:
  150. # the bitnami mysql image has more options than the official one, it's easier to customize
  151. image: bitnamilegacy/mysql:8.0
  152. env:
  153. ALLOW_EMPTY_PASSWORD: true
  154. MYSQL_DATABASE: testgitea
  155. ports:
  156. - "3306:3306"
  157. options: >-
  158. --mount type=tmpfs,destination=/bitnami/mysql/data
  159. elasticsearch:
  160. image: elasticsearch:7.5.0
  161. env:
  162. discovery.type: single-node
  163. ports:
  164. - "9200:9200"
  165. smtpimap:
  166. image: tabascoterrier/docker-imap-devel:latest
  167. ports:
  168. - "25:25"
  169. - "143:143"
  170. - "587:587"
  171. - "993:993"
  172. steps:
  173. - uses: actions/checkout@v4
  174. - uses: actions/setup-go@v5
  175. with:
  176. go-version-file: go.mod
  177. check-latest: true
  178. - name: Add hosts to /etc/hosts
  179. run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 mysql elasticsearch smtpimap" | sudo tee -a /etc/hosts'
  180. - run: make deps-backend
  181. - run: make backend
  182. env:
  183. TAGS: bindata
  184. - name: run migration tests
  185. run: make test-mysql-migration
  186. - name: run tests
  187. # run: make integration-test-coverage (at the moment, no coverage is really handled)
  188. run: make test-mysql
  189. env:
  190. TAGS: bindata
  191. RACE_ENABLED: true
  192. USE_REPO_TEST_DIR: 1
  193. TEST_INDEXER_CODE_ES_URL: "http://elastic:changeme@elasticsearch:9200"
  194. test-mssql:
  195. if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.actions == 'true'
  196. needs: files-changed
  197. runs-on: ubuntu-latest
  198. services:
  199. mssql:
  200. image: mcr.microsoft.com/mssql/server:2019-latest
  201. env:
  202. ACCEPT_EULA: Y
  203. MSSQL_PID: Standard
  204. SA_PASSWORD: MwantsaSecurePassword1
  205. ports:
  206. - "1433:1433"
  207. devstoreaccount1.azurite.local: # https://github.com/Azure/Azurite/issues/1583
  208. image: mcr.microsoft.com/azure-storage/azurite:latest
  209. ports:
  210. - 10000:10000
  211. steps:
  212. - uses: actions/checkout@v4
  213. - uses: actions/setup-go@v5
  214. with:
  215. go-version-file: go.mod
  216. check-latest: true
  217. - name: Add hosts to /etc/hosts
  218. run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 mssql devstoreaccount1.azurite.local" | sudo tee -a /etc/hosts'
  219. - run: make deps-backend
  220. - run: make backend
  221. env:
  222. TAGS: bindata
  223. - run: make test-mssql-migration
  224. - name: run tests
  225. run: make test-mssql
  226. timeout-minutes: 50
  227. env:
  228. TAGS: bindata
  229. USE_REPO_TEST_DIR: 1