integration-test.yml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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: Checkout Repository
  17. uses: actions/checkout@v4
  18. - name: Build and run Compose Stack
  19. run: |
  20. docker compose --file docker-compose.yaml --file docker-compose.api.yaml up --detach --build
  21. - name: Wait for Ollama to be up
  22. timeout-minutes: 5
  23. run: |
  24. until curl --output /dev/null --silent --fail http://localhost:11434; do
  25. printf '.'
  26. sleep 1
  27. done
  28. echo "Service is up!"
  29. - name: Preload Ollama model
  30. run: |
  31. docker exec ollama ollama pull qwen:0.5b-chat-v1.5-q2_K
  32. - name: Cypress run
  33. uses: cypress-io/github-action@v6
  34. with:
  35. browser: chrome
  36. wait-on: 'http://localhost:3000'
  37. config: baseUrl=http://localhost:3000
  38. - uses: actions/upload-artifact@v4
  39. if: always()
  40. name: Upload Cypress videos
  41. with:
  42. name: cypress-videos
  43. path: cypress/videos
  44. if-no-files-found: ignore
  45. - name: Extract Compose logs
  46. if: always()
  47. run: |
  48. docker compose logs > compose-logs.txt
  49. - uses: actions/upload-artifact@v4
  50. if: always()
  51. name: Upload Compose logs
  52. with:
  53. name: compose-logs
  54. path: compose-logs.txt
  55. if-no-files-found: ignore
  56. migration_test:
  57. name: Run Migration Tests
  58. runs-on: ubuntu-latest
  59. services:
  60. postgres:
  61. image: postgres
  62. env:
  63. POSTGRES_PASSWORD: postgres
  64. options: >-
  65. --health-cmd pg_isready
  66. --health-interval 10s
  67. --health-timeout 5s
  68. --health-retries 5
  69. ports:
  70. - 5432:5432
  71. # mysql:
  72. # image: mysql
  73. # env:
  74. # MYSQL_ROOT_PASSWORD: mysql
  75. # MYSQL_DATABASE: mysql
  76. # options: >-
  77. # --health-cmd "mysqladmin ping -h localhost"
  78. # --health-interval 10s
  79. # --health-timeout 5s
  80. # --health-retries 5
  81. # ports:
  82. # - 3306:3306
  83. steps:
  84. - name: Checkout Repository
  85. uses: actions/checkout@v4
  86. - name: Set up Python
  87. uses: actions/setup-python@v2
  88. with:
  89. python-version: ${{ matrix.python-version }}
  90. - name: Set up uv
  91. uses: yezz123/setup-uv@v4
  92. with:
  93. uv-venv: venv
  94. - name: Activate virtualenv
  95. run: |
  96. . venv/bin/activate
  97. echo PATH=$PATH >> $GITHUB_ENV
  98. - name: Install dependencies
  99. run: |
  100. uv pip install -r backend/requirements.txt
  101. - name: Test backend with SQLite
  102. id: sqlite
  103. env:
  104. WEBUI_SECRET_KEY: secret-key
  105. GLOBAL_LOG_LEVEL: debug
  106. run: |
  107. cd backend
  108. uvicorn main:app --port "8080" --forwarded-allow-ips '*' &
  109. UVICORN_PID=$!
  110. # Wait up to 20 seconds for the server to start
  111. for i in {1..20}; do
  112. curl -s http://localhost:8080/api/config > /dev/null && break
  113. sleep 1
  114. if [ $i -eq 20 ]; then
  115. echo "Server failed to start"
  116. kill -9 $UVICORN_PID
  117. exit 1
  118. fi
  119. done
  120. # Check that the server is still running after 5 seconds
  121. sleep 5
  122. if ! kill -0 $UVICORN_PID; then
  123. echo "Server has stopped"
  124. exit 1
  125. fi
  126. - name: Test backend with Postgres
  127. if: success() || steps.sqlite.conclusion == 'failure'
  128. env:
  129. WEBUI_SECRET_KEY: secret-key
  130. GLOBAL_LOG_LEVEL: debug
  131. DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres
  132. run: |
  133. cd backend
  134. uvicorn main:app --port "8081" --forwarded-allow-ips '*' &
  135. UVICORN_PID=$!
  136. # Wait up to 20 seconds for the server to start
  137. for i in {1..20}; do
  138. curl -s http://localhost:8081/api/config > /dev/null && break
  139. sleep 1
  140. if [ $i -eq 20 ]; then
  141. echo "Server failed to start"
  142. kill -9 $UVICORN_PID
  143. exit 1
  144. fi
  145. done
  146. # Check that the server is still running after 5 seconds
  147. sleep 5
  148. if ! kill -0 $UVICORN_PID; then
  149. echo "Server has stopped"
  150. exit 1
  151. fi
  152. # - name: Test backend with MySQL
  153. # if: success() || steps.sqlite.conclusion == 'failure' || steps.postgres.conclusion == 'failure'
  154. # env:
  155. # WEBUI_SECRET_KEY: secret-key
  156. # GLOBAL_LOG_LEVEL: debug
  157. # DATABASE_URL: mysql://root:mysql@localhost:3306/mysql
  158. # run: |
  159. # cd backend
  160. # uvicorn main:app --port "8083" --forwarded-allow-ips '*' &
  161. # UVICORN_PID=$!
  162. # # Wait up to 20 seconds for the server to start
  163. # for i in {1..20}; do
  164. # curl -s http://localhost:8083/api/config > /dev/null && break
  165. # sleep 1
  166. # if [ $i -eq 20 ]; then
  167. # echo "Server failed to start"
  168. # kill -9 $UVICORN_PID
  169. # exit 1
  170. # fi
  171. # done
  172. # # Check that the server is still running after 5 seconds
  173. # sleep 5
  174. # if ! kill -0 $UVICORN_PID; then
  175. # echo "Server has stopped"
  176. # exit 1
  177. # fi