Niansuh/open-webui
2
1name: Integration Test2 3on:4 push:5 branches:6 - main7 - dev8 pull_request:9 branches:10 - main11 - dev12 13jobs:14 cypress-run:15 name: Run Cypress Integration Tests16 runs-on: ubuntu-latest17 steps:18 - name: Checkout Repository19 uses: actions/checkout@v420 21 - name: Build and run Compose Stack22 run: |23 docker compose \24 --file docker-compose.yaml \25 --file docker-compose.api.yaml \26 --file docker-compose.a1111-test.yaml \27 up --detach --build28 29 - name: Wait for Ollama to be up30 timeout-minutes: 531 run: |32 until curl --output /dev/null --silent --fail http://localhost:11434; do33 printf '.'34 sleep 135 done36 echo "Service is up!"37 38 - name: Preload Ollama model39 run: |40 docker exec ollama ollama pull qwen:0.5b-chat-v1.5-q2_K41 42 - name: Cypress run43 uses: cypress-io/github-action@v644 with:45 browser: chrome46 wait-on: "http://localhost:3000"47 config: baseUrl=http://localhost:300048 49 - uses: actions/upload-artifact@v450 if: always()51 name: Upload Cypress videos52 with:53 name: cypress-videos54 path: cypress/videos55 if-no-files-found: ignore56 57 - name: Extract Compose logs58 if: always()59 run: |60 docker compose logs > compose-logs.txt61 62 - uses: actions/upload-artifact@v463 if: always()64 name: Upload Compose logs65 with:66 name: compose-logs67 path: compose-logs.txt68 if-no-files-found: ignore69 70 migration_test:71 name: Run Migration Tests72 runs-on: ubuntu-latest73 services:74 postgres:75 image: postgres76 env:77 POSTGRES_PASSWORD: postgres78 options: >-79 --health-cmd pg_isready80 --health-interval 10s81 --health-timeout 5s82 --health-retries 583 ports:84 - 5432:543285 # mysql:86 # image: mysql87 # env:88 # MYSQL_ROOT_PASSWORD: mysql89 # MYSQL_DATABASE: mysql90 # options: >-91 # --health-cmd "mysqladmin ping -h localhost"92 # --health-interval 10s93 # --health-timeout 5s94 # --health-retries 595 # ports:96 # - 3306:330697 steps:98 - name: Checkout Repository99 uses: actions/checkout@v4100 101 - name: Set up Python102 uses: actions/setup-python@v5103 with:104 python-version: ${{ matrix.python-version }}105 106 - name: Set up uv107 uses: yezz123/setup-uv@v4108 with:109 uv-venv: venv110 111 - name: Activate virtualenv112 run: |113 . venv/bin/activate114 echo PATH=$PATH >> $GITHUB_ENV115 116 - name: Install dependencies117 run: |118 uv pip install -r backend/requirements.txt119 120 - name: Test backend with SQLite121 id: sqlite122 env:123 WEBUI_SECRET_KEY: secret-key124 GLOBAL_LOG_LEVEL: debug125 run: |126 cd backend127 uvicorn main:app --port "8080" --forwarded-allow-ips '*' &128 UVICORN_PID=$!129 # Wait up to 20 seconds for the server to start130 for i in {1..20}; do131 curl -s http://localhost:8080/api/config > /dev/null && break132 sleep 1133 if [ $i -eq 20 ]; then134 echo "Server failed to start"135 kill -9 $UVICORN_PID136 exit 1137 fi138 done139 # Check that the server is still running after 5 seconds140 sleep 5141 if ! kill -0 $UVICORN_PID; then142 echo "Server has stopped"143 exit 1144 fi145 146 - name: Test backend with Postgres147 if: success() || steps.sqlite.conclusion == 'failure'148 env:149 WEBUI_SECRET_KEY: secret-key150 GLOBAL_LOG_LEVEL: debug151 DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres152 run: |153 cd backend154 uvicorn main:app --port "8081" --forwarded-allow-ips '*' &155 UVICORN_PID=$!156 # Wait up to 20 seconds for the server to start157 for i in {1..20}; do158 curl -s http://localhost:8081/api/config > /dev/null && break159 sleep 1160 if [ $i -eq 20 ]; then161 echo "Server failed to start"162 kill -9 $UVICORN_PID163 exit 1164 fi165 done166 # Check that the server is still running after 5 seconds167 sleep 5168 if ! kill -0 $UVICORN_PID; then169 echo "Server has stopped"170 exit 1171 fi172 173 # Check that service will reconnect to postgres when connection will be closed174 status_code=$(curl --write-out %{http_code} -s --output /dev/null http://localhost:8081/health)175 if [[ "$status_code" -ne 200 ]] ; then176 echo "Server has failed before postgres reconnect check"177 exit 1178 fi179 180 echo "Terminating all connections to postgres..."181 python -c "import os, psycopg2 as pg2; \182 conn = pg2.connect(dsn=os.environ['DATABASE_URL'].replace('+pool', '')); \183 cur = conn.cursor(); \184 cur.execute('SELECT pg_terminate_backend(psa.pid) FROM pg_stat_activity psa WHERE datname = current_database() AND pid <> pg_backend_pid();')"185 186 status_code=$(curl --write-out %{http_code} -s --output /dev/null http://localhost:8081/health)187 if [[ "$status_code" -ne 200 ]] ; then188 echo "Server has not reconnected to postgres after connection was closed: returned status $status_code"189 exit 1190 fi191 192# - name: Test backend with MySQL193# if: success() || steps.sqlite.conclusion == 'failure' || steps.postgres.conclusion == 'failure'194# env:195# WEBUI_SECRET_KEY: secret-key196# GLOBAL_LOG_LEVEL: debug197# DATABASE_URL: mysql://root:mysql@localhost:3306/mysql198# run: |199# cd backend200# uvicorn main:app --port "8083" --forwarded-allow-ips '*' &201# UVICORN_PID=$!202# # Wait up to 20 seconds for the server to start203# for i in {1..20}; do204# curl -s http://localhost:8083/api/config > /dev/null && break205# sleep 1206# if [ $i -eq 20 ]; then207# echo "Server failed to start"208# kill -9 $UVICORN_PID209# exit 1210# fi211# done212# # Check that the server is still running after 5 seconds213# sleep 5214# if ! kill -0 $UVICORN_PID; then215# echo "Server has stopped"216# exit 1217# fi218 