JdrCydsek/open-webui
0
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: Delete Docker build cache39 run: |40 docker builder prune --all --force41 42 - name: Preload Ollama model43 run: |44 docker exec ollama ollama pull qwen:0.5b-chat-v1.5-q2_K45 46 - name: Cypress run47 uses: cypress-io/github-action@v648 with:49 browser: chrome50 wait-on: 'http://localhost:3000'51 config: baseUrl=http://localhost:300052 53 - uses: actions/upload-artifact@v454 if: always()55 name: Upload Cypress videos56 with:57 name: cypress-videos58 path: cypress/videos59 if-no-files-found: ignore60 61 - name: Extract Compose logs62 if: always()63 run: |64 docker compose logs > compose-logs.txt65 66 - uses: actions/upload-artifact@v467 if: always()68 name: Upload Compose logs69 with:70 name: compose-logs71 path: compose-logs.txt72 if-no-files-found: ignore73 74 # pytest:75 # name: Run Backend Tests76 # runs-on: ubuntu-latest77 # steps:78 # - uses: actions/checkout@v479 80 # - name: Set up Python81 # uses: actions/setup-python@v482 # with:83 # python-version: ${{ matrix.python-version }}84 85 # - name: Install dependencies86 # run: |87 # python -m pip install --upgrade pip88 # pip install -r backend/requirements.txt89 90 # - name: pytest run91 # run: |92 # ls -al93 # cd backend94 # PYTHONPATH=. pytest . -o log_cli=true -o log_cli_level=INFO95 96 migration_test:97 name: Run Migration Tests98 runs-on: ubuntu-latest99 services:100 postgres:101 image: postgres102 env:103 POSTGRES_PASSWORD: postgres104 options: >-105 --health-cmd pg_isready106 --health-interval 10s107 --health-timeout 5s108 --health-retries 5109 ports:110 - 5432:5432111 # mysql:112 # image: mysql113 # env:114 # MYSQL_ROOT_PASSWORD: mysql115 # MYSQL_DATABASE: mysql116 # options: >-117 # --health-cmd "mysqladmin ping -h localhost"118 # --health-interval 10s119 # --health-timeout 5s120 # --health-retries 5121 # ports:122 # - 3306:3306123 steps:124 - name: Checkout Repository125 uses: actions/checkout@v4126 127 - name: Set up Python128 uses: actions/setup-python@v5129 with:130 python-version: ${{ matrix.python-version }}131 132 - name: Set up uv133 uses: yezz123/setup-uv@v4134 with:135 uv-venv: venv136 137 - name: Activate virtualenv138 run: |139 . venv/bin/activate140 echo PATH=$PATH >> $GITHUB_ENV141 142 - name: Install dependencies143 run: |144 uv pip install -r backend/requirements.txt145 146 - name: Test backend with SQLite147 id: sqlite148 env:149 WEBUI_SECRET_KEY: secret-key150 GLOBAL_LOG_LEVEL: debug151 run: |152 cd backend153 uvicorn main:app --port "8080" --forwarded-allow-ips '*' &154 UVICORN_PID=$!155 # Wait up to 40 seconds for the server to start156 for i in {1..40}; do157 curl -s http://localhost:8080/api/config > /dev/null && break158 sleep 1159 if [ $i -eq 40 ]; then160 echo "Server failed to start"161 kill -9 $UVICORN_PID162 exit 1163 fi164 done165 # Check that the server is still running after 5 seconds166 sleep 5167 if ! kill -0 $UVICORN_PID; then168 echo "Server has stopped"169 exit 1170 fi171 172 - name: Test backend with Postgres173 if: success() || steps.sqlite.conclusion == 'failure'174 env:175 WEBUI_SECRET_KEY: secret-key176 GLOBAL_LOG_LEVEL: debug177 DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres178 run: |179 cd backend180 uvicorn main:app --port "8081" --forwarded-allow-ips '*' &181 UVICORN_PID=$!182 # Wait up to 20 seconds for the server to start183 for i in {1..20}; do184 curl -s http://localhost:8081/api/config > /dev/null && break185 sleep 1186 if [ $i -eq 20 ]; then187 echo "Server failed to start"188 kill -9 $UVICORN_PID189 exit 1190 fi191 done192 # Check that the server is still running after 5 seconds193 sleep 5194 if ! kill -0 $UVICORN_PID; then195 echo "Server has stopped"196 exit 1197 fi198 199 # Check that service will reconnect to postgres when connection will be closed200 status_code=$(curl --write-out %{http_code} -s --output /dev/null http://localhost:8081/health/db)201 if [[ "$status_code" -ne 200 ]] ; then202 echo "Server has failed before postgres reconnect check"203 exit 1204 fi205 206 echo "Terminating all connections to postgres..."207 python -c "import os, psycopg2 as pg2; \208 conn = pg2.connect(dsn=os.environ['DATABASE_URL'].replace('+pool', '')); \209 cur = conn.cursor(); \210 cur.execute('SELECT pg_terminate_backend(psa.pid) FROM pg_stat_activity psa WHERE datname = current_database() AND pid <> pg_backend_pid();')"211 212 status_code=$(curl --write-out %{http_code} -s --output /dev/null http://localhost:8081/health/db)213 if [[ "$status_code" -ne 200 ]] ; then214 echo "Server has not reconnected to postgres after connection was closed: returned status $status_code"215 exit 1216 fi217 218# - name: Test backend with MySQL219# if: success() || steps.sqlite.conclusion == 'failure' || steps.postgres.conclusion == 'failure'220# env:221# WEBUI_SECRET_KEY: secret-key222# GLOBAL_LOG_LEVEL: debug223# DATABASE_URL: mysql://root:mysql@localhost:3306/mysql224# run: |225# cd backend226# uvicorn main:app --port "8083" --forwarded-allow-ips '*' &227# UVICORN_PID=$!228# # Wait up to 20 seconds for the server to start229# for i in {1..20}; do230# curl -s http://localhost:8083/api/config > /dev/null && break231# sleep 1232# if [ $i -eq 20 ]; then233# echo "Server failed to start"234# kill -9 $UVICORN_PID235# exit 1236# fi237# done238# # Check that the server is still running after 5 seconds239# sleep 5240# if ! kill -0 $UVICORN_PID; then241# echo "Server has stopped"242# exit 1243# fi244 