mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-09 23:54:09 -06:00
184 lines
6.4 KiB
YAML
184 lines
6.4 KiB
YAML
# This workflow requires the following configuration in Github
|
|
#
|
|
# Vars:
|
|
# ENABLE_EPAS_TESTS - Set to true to enable this test
|
|
#
|
|
# Secrets:
|
|
# EDB_REPO_USERNAME - Username for accessing EDB Repos 1.0
|
|
# EDB_REPO_PASSWORD - Password for accessing EDB Repos 1.0
|
|
|
|
name: Run Python tests on EPAS
|
|
|
|
on:
|
|
push:
|
|
branches: [ "master" ]
|
|
pull_request:
|
|
branches: [ "master" ]
|
|
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
POSTGRESQL_VERSIONS: 15 14 13 12 11
|
|
|
|
jobs:
|
|
build:
|
|
# Only run if the tests are enabled
|
|
# TODO: Figure out a way to test for the presence of the secrets instead
|
|
if: vars.ENABLE_EPAS_TESTS == 'true'
|
|
|
|
runs-on: ubuntu-22.04
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Setup the EDB APT repo
|
|
run: |
|
|
sudo su -c 'echo "deb [arch=amd64] https://apt.enterprisedb.com/$(lsb_release -cs)-edb/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/edb-$(lsb_release -cs).list'
|
|
sudo su -c 'echo "machine apt.enterprisedb.com login ${{ secrets.EDB_REPO_USERNAME }} password ${{ secrets.EDB_REPO_PASSWORD }}" > /etc/apt/auth.conf.d/edb.conf'
|
|
sudo wget -q -O - https://apt.enterprisedb.com/edb-deb.gpg.key | sudo apt-key add -
|
|
- name: Install platform dependencies
|
|
run: |
|
|
PACKAGES=
|
|
for VERSION in ${POSTGRESQL_VERSIONS};
|
|
do
|
|
PACKAGES="${PACKAGES} edb-as${VERSION}-server edb-as${VERSION}-server-pldebugger edb-as${VERSION}-pgagent"
|
|
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}
|
|
- name: Create the tablespace directory
|
|
run: |
|
|
for VERSION in ${POSTGRESQL_VERSIONS};
|
|
do
|
|
sudo mkdir -p /var/lib/edb-as/tablespaces/${VERSION}
|
|
sudo chown enterprisedb:enterprisedb /var/lib/edb-as/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/edb-as/${VERSION}/main/pg_hba.conf"
|
|
sudo sed -i "s/port = 544[0-9]/port = 58${VERSION}/g" /etc/edb-as/${VERSION}/main/postgresql.conf
|
|
sudo sed -i "s/shared_preload_libraries = '/shared_preload_libraries = '\$libdir\/plugin_debugger,/g" /etc/edb-as/${VERSION}/main/postgresql.conf
|
|
sudo su - enterprisedb -c "mkdir -p /var/run/edb-as/${VERSION}-main.epas_stat_tmp"
|
|
sudo systemctl restart edb-as@${VERSION}-main
|
|
|
|
until sudo runuser -l enterprisedb -c "/usr/lib/edb-as/${VERSION}/bin/pg_isready -p 58${VERSION}" 2>/dev/null; do
|
|
>&2 echo "EPAS is unavailable - sleeping for 2 seconds"
|
|
sleep 2
|
|
done
|
|
|
|
psql -U enterprisedb -d postgres -p 58${VERSION} -c 'CREATE EXTENSION IF NOT EXISTS pgagent;'
|
|
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": "EPAS $1",
|
|
"comment": "EPAS $1 Server",
|
|
"db_username": "enterprisedb",
|
|
"host": "/var/run/edb-as",
|
|
"db_password": "",
|
|
"db_port": 58$1,
|
|
"maintenance_db": "postgres",
|
|
"sslmode": "prefer",
|
|
"tablespace_path": "/var/lib/edb-as/tablespaces/$1",
|
|
"enabled": true,
|
|
"default_binary_paths": {
|
|
"pg": "",
|
|
"ppas": "/usr/lib/edb-as/$1/bin"
|
|
}
|
|
}${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
|