1
0

integration-test.yml 7.7 KB

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