2024-04-26 21:32:09 +00:00
|
|
|
name: Integration Test
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
- dev
|
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
- dev
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
cypress-run:
|
|
|
|
name: Run Cypress Integration Tests
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2024-08-11 13:17:32 +00:00
|
|
|
- name: Maximize build space
|
|
|
|
uses: AdityaGarg8/remove-unwanted-software@v4.1
|
|
|
|
with:
|
|
|
|
remove-android: 'true'
|
|
|
|
remove-haskell: 'true'
|
|
|
|
remove-codeql: 'true'
|
|
|
|
|
2024-04-26 21:32:09 +00:00
|
|
|
- name: Checkout Repository
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Build and run Compose Stack
|
|
|
|
run: |
|
2024-05-20 07:56:18 +00:00
|
|
|
docker compose \
|
|
|
|
--file docker-compose.yaml \
|
|
|
|
--file docker-compose.api.yaml \
|
|
|
|
--file docker-compose.a1111-test.yaml \
|
|
|
|
up --detach --build
|
2024-06-20 16:12:33 +00:00
|
|
|
|
2024-08-03 19:53:31 +00:00
|
|
|
- name: Delete Docker build cache
|
|
|
|
run: |
|
|
|
|
docker builder prune --all --force
|
|
|
|
|
2024-05-06 22:13:57 +00:00
|
|
|
- name: Wait for Ollama to be up
|
|
|
|
timeout-minutes: 5
|
|
|
|
run: |
|
|
|
|
until curl --output /dev/null --silent --fail http://localhost:11434; do
|
|
|
|
printf '.'
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
echo "Service is up!"
|
2024-04-26 21:32:09 +00:00
|
|
|
|
|
|
|
- name: Preload Ollama model
|
|
|
|
run: |
|
|
|
|
docker exec ollama ollama pull qwen:0.5b-chat-v1.5-q2_K
|
|
|
|
|
|
|
|
- name: Cypress run
|
|
|
|
uses: cypress-io/github-action@v6
|
|
|
|
with:
|
|
|
|
browser: chrome
|
2024-10-05 20:01:35 +00:00
|
|
|
wait-on: 'http://localhost:3000'
|
|
|
|
config: baseUrl=http://localhost:3000
|
2024-04-26 21:32:09 +00:00
|
|
|
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
|
|
if: always()
|
|
|
|
name: Upload Cypress videos
|
|
|
|
with:
|
|
|
|
name: cypress-videos
|
|
|
|
path: cypress/videos
|
|
|
|
if-no-files-found: ignore
|
|
|
|
|
|
|
|
- name: Extract Compose logs
|
|
|
|
if: always()
|
|
|
|
run: |
|
|
|
|
docker compose logs > compose-logs.txt
|
|
|
|
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
|
|
if: always()
|
|
|
|
name: Upload Compose logs
|
|
|
|
with:
|
|
|
|
name: compose-logs
|
|
|
|
path: compose-logs.txt
|
|
|
|
if-no-files-found: ignore
|
2024-04-28 14:41:33 +00:00
|
|
|
|
2024-07-06 06:54:03 +00:00
|
|
|
# pytest:
|
|
|
|
# name: Run Backend Tests
|
|
|
|
# runs-on: ubuntu-latest
|
|
|
|
# steps:
|
|
|
|
# - uses: actions/checkout@v4
|
2024-06-25 07:06:04 +00:00
|
|
|
|
2024-07-06 06:54:03 +00:00
|
|
|
# - name: Set up Python
|
2024-10-05 18:21:28 +00:00
|
|
|
# uses: actions/setup-python@v5
|
2024-07-06 06:54:03 +00:00
|
|
|
# with:
|
|
|
|
# python-version: ${{ matrix.python-version }}
|
2024-06-25 07:06:04 +00:00
|
|
|
|
2024-07-06 06:54:03 +00:00
|
|
|
# - name: Install dependencies
|
|
|
|
# run: |
|
|
|
|
# python -m pip install --upgrade pip
|
|
|
|
# pip install -r backend/requirements.txt
|
2024-06-25 07:06:04 +00:00
|
|
|
|
2024-07-06 06:54:03 +00:00
|
|
|
# - name: pytest run
|
|
|
|
# run: |
|
|
|
|
# ls -al
|
|
|
|
# cd backend
|
|
|
|
# PYTHONPATH=. pytest . -o log_cli=true -o log_cli_level=INFO
|
2024-06-25 07:06:04 +00:00
|
|
|
|
2024-04-28 14:41:33 +00:00
|
|
|
migration_test:
|
|
|
|
name: Run Migration Tests
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
services:
|
|
|
|
postgres:
|
|
|
|
image: postgres
|
|
|
|
env:
|
|
|
|
POSTGRES_PASSWORD: postgres
|
|
|
|
options: >-
|
|
|
|
--health-cmd pg_isready
|
|
|
|
--health-interval 10s
|
|
|
|
--health-timeout 5s
|
|
|
|
--health-retries 5
|
|
|
|
ports:
|
|
|
|
- 5432:5432
|
2024-06-20 16:12:33 +00:00
|
|
|
# mysql:
|
|
|
|
# image: mysql
|
|
|
|
# env:
|
|
|
|
# MYSQL_ROOT_PASSWORD: mysql
|
|
|
|
# MYSQL_DATABASE: mysql
|
|
|
|
# options: >-
|
|
|
|
# --health-cmd "mysqladmin ping -h localhost"
|
|
|
|
# --health-interval 10s
|
|
|
|
# --health-timeout 5s
|
|
|
|
# --health-retries 5
|
|
|
|
# ports:
|
|
|
|
# - 3306:3306
|
2024-04-28 14:41:33 +00:00
|
|
|
steps:
|
|
|
|
- name: Checkout Repository
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Set up Python
|
2024-05-22 08:20:26 +00:00
|
|
|
uses: actions/setup-python@v5
|
2024-04-28 14:41:33 +00:00
|
|
|
with:
|
|
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
|
|
|
|
- name: Set up uv
|
|
|
|
uses: yezz123/setup-uv@v4
|
|
|
|
with:
|
|
|
|
uv-venv: venv
|
|
|
|
|
|
|
|
- name: Activate virtualenv
|
|
|
|
run: |
|
|
|
|
. venv/bin/activate
|
|
|
|
echo PATH=$PATH >> $GITHUB_ENV
|
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
uv pip install -r backend/requirements.txt
|
|
|
|
|
|
|
|
- name: Test backend with SQLite
|
|
|
|
id: sqlite
|
2024-04-28 15:59:48 +00:00
|
|
|
env:
|
|
|
|
WEBUI_SECRET_KEY: secret-key
|
|
|
|
GLOBAL_LOG_LEVEL: debug
|
2024-04-28 14:41:33 +00:00
|
|
|
run: |
|
|
|
|
cd backend
|
2024-09-04 18:27:30 +00:00
|
|
|
uvicorn open_webui.main:app --port "8080" --forwarded-allow-ips '*' &
|
2024-04-28 14:41:33 +00:00
|
|
|
UVICORN_PID=$!
|
2024-07-06 06:58:13 +00:00
|
|
|
# Wait up to 40 seconds for the server to start
|
|
|
|
for i in {1..40}; do
|
2024-04-28 14:41:33 +00:00
|
|
|
curl -s http://localhost:8080/api/config > /dev/null && break
|
|
|
|
sleep 1
|
2024-07-06 06:58:13 +00:00
|
|
|
if [ $i -eq 40 ]; then
|
2024-04-28 14:41:33 +00:00
|
|
|
echo "Server failed to start"
|
|
|
|
kill -9 $UVICORN_PID
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
# Check that the server is still running after 5 seconds
|
|
|
|
sleep 5
|
|
|
|
if ! kill -0 $UVICORN_PID; then
|
|
|
|
echo "Server has stopped"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
- name: Test backend with Postgres
|
|
|
|
if: success() || steps.sqlite.conclusion == 'failure'
|
2024-04-28 15:59:48 +00:00
|
|
|
env:
|
|
|
|
WEBUI_SECRET_KEY: secret-key
|
|
|
|
GLOBAL_LOG_LEVEL: debug
|
|
|
|
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres
|
2024-10-06 14:46:35 +00:00
|
|
|
DATABASE_POOL_SIZE: 10
|
|
|
|
DATABASE_POOL_MAX_OVERFLOW: 10
|
|
|
|
DATABASE_POOL_TIMEOUT: 30
|
2024-04-28 14:41:33 +00:00
|
|
|
run: |
|
|
|
|
cd backend
|
2024-09-04 18:27:30 +00:00
|
|
|
uvicorn open_webui.main:app --port "8081" --forwarded-allow-ips '*' &
|
2024-04-28 14:41:33 +00:00
|
|
|
UVICORN_PID=$!
|
|
|
|
# Wait up to 20 seconds for the server to start
|
|
|
|
for i in {1..20}; do
|
|
|
|
curl -s http://localhost:8081/api/config > /dev/null && break
|
|
|
|
sleep 1
|
|
|
|
if [ $i -eq 20 ]; then
|
|
|
|
echo "Server failed to start"
|
|
|
|
kill -9 $UVICORN_PID
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
# Check that the server is still running after 5 seconds
|
|
|
|
sleep 5
|
|
|
|
if ! kill -0 $UVICORN_PID; then
|
|
|
|
echo "Server has stopped"
|
|
|
|
exit 1
|
|
|
|
fi
|
2024-06-20 16:12:33 +00:00
|
|
|
|
2024-05-30 13:20:09 +00:00
|
|
|
# Check that service will reconnect to postgres when connection will be closed
|
2024-06-18 13:03:31 +00:00
|
|
|
status_code=$(curl --write-out %{http_code} -s --output /dev/null http://localhost:8081/health/db)
|
2024-05-30 13:20:09 +00:00
|
|
|
if [[ "$status_code" -ne 200 ]] ; then
|
|
|
|
echo "Server has failed before postgres reconnect check"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Terminating all connections to postgres..."
|
|
|
|
python -c "import os, psycopg2 as pg2; \
|
|
|
|
conn = pg2.connect(dsn=os.environ['DATABASE_URL'].replace('+pool', '')); \
|
|
|
|
cur = conn.cursor(); \
|
|
|
|
cur.execute('SELECT pg_terminate_backend(psa.pid) FROM pg_stat_activity psa WHERE datname = current_database() AND pid <> pg_backend_pid();')"
|
2024-06-20 16:12:33 +00:00
|
|
|
|
2024-06-18 13:03:31 +00:00
|
|
|
status_code=$(curl --write-out %{http_code} -s --output /dev/null http://localhost:8081/health/db)
|
2024-05-30 13:20:09 +00:00
|
|
|
if [[ "$status_code" -ne 200 ]] ; then
|
|
|
|
echo "Server has not reconnected to postgres after connection was closed: returned status $status_code"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-04-28 15:55:53 +00:00
|
|
|
# - name: Test backend with MySQL
|
|
|
|
# if: success() || steps.sqlite.conclusion == 'failure' || steps.postgres.conclusion == 'failure'
|
2024-04-28 15:59:48 +00:00
|
|
|
# env:
|
|
|
|
# WEBUI_SECRET_KEY: secret-key
|
|
|
|
# GLOBAL_LOG_LEVEL: debug
|
|
|
|
# DATABASE_URL: mysql://root:mysql@localhost:3306/mysql
|
2024-04-28 15:55:53 +00:00
|
|
|
# run: |
|
|
|
|
# cd backend
|
2024-09-04 18:27:30 +00:00
|
|
|
# uvicorn open_webui.main:app --port "8083" --forwarded-allow-ips '*' &
|
2024-04-28 15:55:53 +00:00
|
|
|
# UVICORN_PID=$!
|
|
|
|
# # Wait up to 20 seconds for the server to start
|
|
|
|
# for i in {1..20}; do
|
|
|
|
# curl -s http://localhost:8083/api/config > /dev/null && break
|
|
|
|
# sleep 1
|
|
|
|
# if [ $i -eq 20 ]; then
|
|
|
|
# echo "Server failed to start"
|
|
|
|
# kill -9 $UVICORN_PID
|
|
|
|
# exit 1
|
|
|
|
# fi
|
|
|
|
# done
|
|
|
|
# # Check that the server is still running after 5 seconds
|
|
|
|
# sleep 5
|
|
|
|
# if ! kill -0 $UVICORN_PID; then
|
|
|
|
# echo "Server has stopped"
|
|
|
|
# exit 1
|
|
|
|
# fi
|