integration-test.disabled 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. name: Integration Test
  2. on:
  3. push:
  4. branches:
  5. - main
  6. - dev
  7. pull_request:
  8. branches:
  9. - main
  10. - dev
  11. jobs:
  12. cypress-run:
  13. name: Run Cypress Integration Tests
  14. runs-on: ubuntu-latest
  15. steps:
  16. - name: Maximize build space
  17. uses: AdityaGarg8/remove-unwanted-software@v4.1
  18. with:
  19. remove-android: 'true'
  20. remove-haskell: 'true'
  21. remove-codeql: 'true'
  22. - name: Checkout Repository
  23. uses: actions/checkout@v4
  24. - name: Build and run Compose Stack
  25. run: |
  26. docker compose \
  27. --file docker-compose.yaml \
  28. --file docker-compose.api.yaml \
  29. --file docker-compose.a1111-test.yaml \
  30. up --detach --build
  31. - name: Delete Docker build cache
  32. run: |
  33. docker builder prune --all --force
  34. - name: Wait for Ollama to be up
  35. timeout-minutes: 5
  36. run: |
  37. until curl --output /dev/null --silent --fail http://localhost:11434; do
  38. printf '.'
  39. sleep 1
  40. done
  41. echo "Service is up!"
  42. - name: Preload Ollama model
  43. run: |
  44. docker exec ollama ollama pull qwen:0.5b-chat-v1.5-q2_K
  45. - name: Cypress run
  46. uses: cypress-io/github-action@v6
  47. env:
  48. LIBGL_ALWAYS_SOFTWARE: 1
  49. with:
  50. browser: chrome
  51. wait-on: 'http://localhost:3000'
  52. config: baseUrl=http://localhost:3000
  53. - uses: actions/upload-artifact@v4
  54. if: always()
  55. name: Upload Cypress videos
  56. with:
  57. name: cypress-videos
  58. path: cypress/videos
  59. if-no-files-found: ignore
  60. - name: Extract Compose logs
  61. if: always()
  62. run: |
  63. docker compose logs > compose-logs.txt
  64. - uses: actions/upload-artifact@v4
  65. if: always()
  66. name: Upload Compose logs
  67. with:
  68. name: compose-logs
  69. path: compose-logs.txt
  70. if-no-files-found: ignore
  71. # pytest:
  72. # name: Run Backend Tests
  73. # runs-on: ubuntu-latest
  74. # steps:
  75. # - uses: actions/checkout@v4
  76. # - name: Set up Python
  77. # uses: actions/setup-python@v5
  78. # with:
  79. # python-version: ${{ matrix.python-version }}
  80. # - name: Install dependencies
  81. # run: |
  82. # python -m pip install --upgrade pip
  83. # pip install -r backend/requirements.txt
  84. # - name: pytest run
  85. # run: |
  86. # ls -al
  87. # cd backend
  88. # PYTHONPATH=. pytest . -o log_cli=true -o log_cli_level=INFO
  89. migration_test:
  90. name: Run Migration Tests
  91. runs-on: ubuntu-latest
  92. services:
  93. postgres:
  94. image: postgres
  95. env:
  96. POSTGRES_PASSWORD: postgres
  97. options: >-
  98. --health-cmd pg_isready
  99. --health-interval 10s
  100. --health-timeout 5s
  101. --health-retries 5
  102. ports:
  103. - 5432:5432
  104. # mysql:
  105. # image: mysql
  106. # env:
  107. # MYSQL_ROOT_PASSWORD: mysql
  108. # MYSQL_DATABASE: mysql
  109. # options: >-
  110. # --health-cmd "mysqladmin ping -h localhost"
  111. # --health-interval 10s
  112. # --health-timeout 5s
  113. # --health-retries 5
  114. # ports:
  115. # - 3306:3306
  116. steps:
  117. - name: Checkout Repository
  118. uses: actions/checkout@v4
  119. - name: Set up Python
  120. uses: actions/setup-python@v5
  121. with:
  122. python-version: ${{ matrix.python-version }}
  123. - name: Set up uv
  124. uses: yezz123/setup-uv@v4
  125. with:
  126. uv-venv: venv
  127. - name: Activate virtualenv
  128. run: |
  129. . venv/bin/activate
  130. echo PATH=$PATH >> $GITHUB_ENV
  131. - name: Install dependencies
  132. run: |
  133. uv pip install -r backend/requirements.txt
  134. - name: Test backend with SQLite
  135. id: sqlite
  136. env:
  137. WEBUI_SECRET_KEY: secret-key
  138. GLOBAL_LOG_LEVEL: debug
  139. run: |
  140. cd backend
  141. uvicorn open_webui.main:app --port "8080" --forwarded-allow-ips '*' &
  142. UVICORN_PID=$!
  143. # Wait up to 40 seconds for the server to start
  144. for i in {1..40}; do
  145. curl -s http://localhost:8080/api/config > /dev/null && break
  146. sleep 1
  147. if [ $i -eq 40 ]; then
  148. echo "Server failed to start"
  149. kill -9 $UVICORN_PID
  150. exit 1
  151. fi
  152. done
  153. # Check that the server is still running after 5 seconds
  154. sleep 5
  155. if ! kill -0 $UVICORN_PID; then
  156. echo "Server has stopped"
  157. exit 1
  158. fi
  159. - name: Test backend with Postgres
  160. if: success() || steps.sqlite.conclusion == 'failure'
  161. env:
  162. WEBUI_SECRET_KEY: secret-key
  163. GLOBAL_LOG_LEVEL: debug
  164. DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres
  165. DATABASE_POOL_SIZE: 10
  166. DATABASE_POOL_MAX_OVERFLOW: 10
  167. DATABASE_POOL_TIMEOUT: 30
  168. run: |
  169. cd backend
  170. uvicorn open_webui.main:app --port "8081" --forwarded-allow-ips '*' &
  171. UVICORN_PID=$!
  172. # Wait up to 20 seconds for the server to start
  173. for i in {1..20}; do
  174. curl -s http://localhost:8081/api/config > /dev/null && break
  175. sleep 1
  176. if [ $i -eq 20 ]; then
  177. echo "Server failed to start"
  178. kill -9 $UVICORN_PID
  179. exit 1
  180. fi
  181. done
  182. # Check that the server is still running after 5 seconds
  183. sleep 5
  184. if ! kill -0 $UVICORN_PID; then
  185. echo "Server has stopped"
  186. exit 1
  187. fi
  188. # Check that service will reconnect to postgres when connection will be closed
  189. status_code=$(curl --write-out %{http_code} -s --output /dev/null http://localhost:8081/health/db)
  190. if [[ "$status_code" -ne 200 ]] ; then
  191. echo "Server has failed before postgres reconnect check"
  192. exit 1
  193. fi
  194. echo "Terminating all connections to postgres..."
  195. python -c "import os, psycopg2 as pg2; \
  196. conn = pg2.connect(dsn=os.environ['DATABASE_URL'].replace('+pool', '')); \
  197. cur = conn.cursor(); \
  198. cur.execute('SELECT pg_terminate_backend(psa.pid) FROM pg_stat_activity psa WHERE datname = current_database() AND pid <> pg_backend_pid();')"
  199. status_code=$(curl --write-out %{http_code} -s --output /dev/null http://localhost:8081/health/db)
  200. if [[ "$status_code" -ne 200 ]] ; then
  201. echo "Server has not reconnected to postgres after connection was closed: returned status $status_code"
  202. exit 1
  203. fi
  204. # - name: Test backend with MySQL
  205. # if: success() || steps.sqlite.conclusion == 'failure' || steps.postgres.conclusion == 'failure'
  206. # env:
  207. # WEBUI_SECRET_KEY: secret-key
  208. # GLOBAL_LOG_LEVEL: debug
  209. # DATABASE_URL: mysql://root:mysql@localhost:3306/mysql
  210. # run: |
  211. # cd backend
  212. # uvicorn open_webui.main:app --port "8083" --forwarded-allow-ips '*' &
  213. # UVICORN_PID=$!
  214. # # Wait up to 20 seconds for the server to start
  215. # for i in {1..20}; do
  216. # curl -s http://localhost:8083/api/config > /dev/null && break
  217. # sleep 1
  218. # if [ $i -eq 20 ]; then
  219. # echo "Server failed to start"
  220. # kill -9 $UVICORN_PID
  221. # exit 1
  222. # fi
  223. # done
  224. # # Check that the server is still running after 5 seconds
  225. # sleep 5
  226. # if ! kill -0 $UVICORN_PID; then
  227. # echo "Server has stopped"
  228. # exit 1
  229. # fi