mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-09 23:54:09 -06:00
176 lines
5.9 KiB
YAML
176 lines
5.9 KiB
YAML
name: Run Python tests on PostgreSQL
|
|
|
|
on:
|
|
push:
|
|
branches: [ "master" ]
|
|
pull_request:
|
|
branches: [ "master" ]
|
|
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
POSTGRESQL_VERSIONS: 15 14 13 12 11
|
|
|
|
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: |
|
|
PACKAGES=
|
|
for VERSION in ${POSTGRESQL_VERSIONS};
|
|
do
|
|
PACKAGES="${PACKAGES} postgresql-${VERSION} postgresql-${VERSION}-pldebugger"
|
|
done
|
|
|
|
sudo apt update
|
|
sudo apt install -y build-essential python3-dev python3-pip libpq-dev libffi-dev libssl-dev libkrb5-dev zlib1g-dev ${PACKAGES} pgagent
|
|
|
|
- name: Create the tablespace directory
|
|
run: |
|
|
for VERSION in ${POSTGRESQL_VERSIONS};
|
|
do
|
|
sudo mkdir -p /var/lib/postgresql/tablespaces/${VERSION}
|
|
sudo chown postgres:postgres /var/lib/postgresql/tablespaces/${VERSION}
|
|
done
|
|
|
|
- name: Start PostgreSQL
|
|
run: |
|
|
# Note: we use a custom port for PostgreSQL as the runner may already have a version of PostgreSQL installed
|
|
for VERSION in ${POSTGRESQL_VERSIONS};
|
|
do
|
|
sudo su -c "echo local all all trust > /etc/postgresql/${VERSION}/main/pg_hba.conf"
|
|
sudo sed -i "s/port = 543[0-9]/port = 59${VERSION}/g" /etc/postgresql/${VERSION}/main/postgresql.conf
|
|
sudo sed -i "s/#shared_preload_libraries = ''/shared_preload_libraries = '\$libdir\/plugin_debugger'/g" /etc/postgresql/${VERSION}/main/postgresql.conf
|
|
sudo su - postgres -c "/usr/lib/postgresql/${VERSION}/bin/postgres -D /var/lib/postgresql/${VERSION}/main -c config_file=/etc/postgresql/${VERSION}/main/postgresql.conf &"
|
|
|
|
until sudo runuser -l postgres -c "pg_isready -p 59${VERSION}" 2>/dev/null; do
|
|
>&2 echo "Postgres is unavailable - sleeping for 2 seconds"
|
|
sleep 2
|
|
done
|
|
|
|
psql -U postgres -p 59${VERSION} -c 'CREATE EXTENSION pgagent;'
|
|
psql -U postgres -p 59${VERSION} -c 'CREATE EXTENSION pldbgapi;'
|
|
done
|
|
|
|
- name: Install Python dependencies
|
|
run: |
|
|
sudo pip install --upgrade pip
|
|
sudo pip install -r web/regression/requirements.txt
|
|
sudo pip install "pyOpenSSL>=23.*"
|
|
|
|
- name: Create the test configuration
|
|
run: |
|
|
cat <<EOF > 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 <<EOF > 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": [
|
|
EOF
|
|
|
|
function add_server_def() {
|
|
SEP=","
|
|
if [ "$1" = "$2" ]; then
|
|
SEP=""
|
|
fi
|
|
|
|
cat <<EOF >> web/regression/test_config.json
|
|
{
|
|
"name": "PostgreSQL $1",
|
|
"comment": "PostgreSQL $1 Server",
|
|
"db_username": "postgres",
|
|
"host": "/var/run/postgresql",
|
|
"db_password": "postgres",
|
|
"db_port": 59$1,
|
|
"maintenance_db": "postgres",
|
|
"sslmode": "prefer",
|
|
"tablespace_path": "/var/lib/postgresql/tablespaces/$1",
|
|
"enabled": true,
|
|
"default_binary_paths": {
|
|
"pg": "/usr/lib/postgresql/$1/bin",
|
|
"ppas": ""
|
|
}
|
|
}${SEP}
|
|
EOF
|
|
}
|
|
|
|
LAST_VERSION=$(echo ${POSTGRESQL_VERSIONS} | awk '{print $NF}')
|
|
for VERSION in ${POSTGRESQL_VERSIONS};
|
|
do
|
|
add_server_def ${VERSION} ${LAST_VERSION}
|
|
done
|
|
|
|
cat <<EOF >> web/regression/test_config.json
|
|
],
|
|
"server_update_data": [
|
|
{
|
|
"comment": "This is test update comment"
|
|
}
|
|
]
|
|
}
|
|
EOF
|
|
|
|
- name: Run the tests
|
|
run: make check-python
|
|
|
|
- name: Archive server log
|
|
if: success() || failure()
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: server-log
|
|
path: var/pgadmin4.log
|
|
|
|
- name: Archive regression log
|
|
if: success() || failure()
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: regression-log
|
|
path: web/regression/regression.log
|