From cc4dfaf951836ea9990c3365f04d77c7f0cff1b9 Mon Sep 17 00:00:00 2001 From: Dave Page Date: Wed, 29 Mar 2023 16:46:53 +0100 Subject: [PATCH] Run Python regression tests. --- .github/workflows/run-python-tests.yml | 136 +++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 .github/workflows/run-python-tests.yml diff --git a/.github/workflows/run-python-tests.yml b/.github/workflows/run-python-tests.yml new file mode 100644 index 000000000..c0cd66954 --- /dev/null +++ b/.github/workflows/run-python-tests.yml @@ -0,0 +1,136 @@ +name: Run Python tests + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Setup the PGDG APT repo + run: | + sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' + wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - + + - name: Install platform dependencies + run: | + sudo apt update + sudo apt upgrade -y + sudo apt install -y build-essential python3-dev python3-pip libpq-dev libffi-dev libssl-dev libkrb5-dev zlib1g-dev postgresql-15 postgresql-15-pldebugger pgagent + + - name: Create the tablespace directory + run: | + sudo mkdir -p /var/lib/postgresql/tablespaces/15 + sudo chown postgres:postgres /var/lib/postgresql/tablespaces/15 + + - name: Start PostgreSQL + run: | + echo -e "local all all trust\n$(cat /etc/postgresql/15/main/pg_hba.conf)" > /etc/postgresql/15/main/pg_hba.conf + echo "shared_preload_libraries = '$libdir/plugin_debugger'" > /etc/postgresql/15/main/postgresql.auto.conf + su - postgres -c '/usr/lib/postgresql/15/bin/postgres -D /var/lib/postgresql/15/main -c config_file=/etc/postgresql/15/main/postgresql.conf &' + + until runuser -l postgres -c 'pg_isready' 2>/dev/null; do + >&2 echo "Postgres is unavailable - sleeping for 2 seconds" + sleep 2 + done + + psql -U postgres -c 'CREATE EXTENSION pgagent;' + + - name: Install Python dependencies + run: | + sudo pip install --upgrade pip + sudo pip install -r web/regression/requirements.txt + + - name: Create the test configuration + run: | + cat < web/config_local.py + from config import * + + # Debug mode + DEBUG = True + + # App mode + SERVER_MODE = False + + # Log + CONSOLE_LOG_LEVEL = DEBUG + FILE_LOG_LEVEL = DEBUG + + DEFAULT_SERVER = '127.0.0.1' + + UPGRADE_CHECK_ENABLED = False + + LOG_FILE = "$(pwd)/var/pgadmin4.log" + SESSION_DB_PATH = "$(pwd)/var/sessions" + STORAGE_DIR = "$(pwd)/var/storage" + SQLITE_PATH = "$(pwd)/var/pgadmin4.db" + TEST_SQLITE_PATH = "$(pwd)/var/pgadmin4.db" + AZURE_CREDENTIAL_CACHE_DIR = "$(pwd)/var/azurecredentialcache" + EOF + + cat < web/regression/test_config.json + { + "pgAdmin4_login_credentials": { + "new_password": "NEWPASSWORD", + "login_password": "PASSWORD", + "login_username": "USER@EXAMPLE.COM" + }, + "pgAdmin4_test_user_credentials": { + "new_password": "NEWPASSWORD", + "login_password": "PASSWORD", + "login_username": "USER2@EXAMPLE.COM" + }, + "pgAdmin4_test_non_admin_credentials": { + "new_password": "NEWPASSWORD", + "login_password": "PASSWORD", + "login_username": "USER@EXAMPLE.COM" + }, + "server_group": 1, + "server_credentials": [ + { + "name": "PostgreSQL 15", + "comment": "PostgreSQL 15 Server", + "db_username": "postgres", + "host": "/var/run/postgresql", + "db_password": "postgres", + "db_port": 5432, + "maintenance_db": "postgres", + "sslmode": "prefer", + "tablespace_path": "/var/lib/postgresql/tablespaces/15", + "enabled": true, + "default_binary_paths": { + "pg": "/usr/lib/postgresql/15/bin", + "ppas": "" + } + } + ], + "server_update_data": [ + { + "comment": "This is test update comment" + } + ] + } + EOF + + - name: Run the tests + run: make check-python + + - name: Archive server log + uses: actions/upload-artifact@v3 + with: + name: server-log + path: var/pgadmin4.log + + - name: Archive regression log + uses: actions/upload-artifact@v3 + with: + name: regression-log + path: web/regression/regression.log