2023-03-31 15:25:35 +00:00
|
|
|
name: Run Python tests on PostgreSQL
|
2023-03-29 15:46:53 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: [ "master" ]
|
|
|
|
pull_request:
|
|
|
|
branches: [ "master" ]
|
|
|
|
|
|
|
|
workflow_dispatch:
|
|
|
|
|
2023-04-05 15:11:19 +00:00
|
|
|
concurrency:
|
|
|
|
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2023-03-29 15:46:53 +00:00
|
|
|
jobs:
|
|
|
|
build:
|
2023-04-05 15:04:20 +00:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
2023-04-06 12:05:42 +00:00
|
|
|
os: [macos-latest, ubuntu-latest]
|
2023-04-05 15:04:20 +00:00
|
|
|
pgver: [11, 12, 13, 14, 15]
|
|
|
|
|
2023-04-06 12:05:42 +00:00
|
|
|
runs-on: ${{ matrix.os }}
|
2023-03-29 15:46:53 +00:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Setup the PGDG APT repo
|
2023-04-06 12:05:42 +00:00
|
|
|
if: ${{ matrix.os == 'ubuntu-latest' }}
|
2023-03-29 15:46:53 +00:00
|
|
|
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 -
|
2023-03-30 14:54:06 +00:00
|
|
|
|
2023-04-06 12:05:42 +00:00
|
|
|
- name: Install platform dependencies on Linux
|
|
|
|
if: ${{ matrix.os == 'ubuntu-latest' }}
|
2023-03-29 15:46:53 +00:00
|
|
|
run: |
|
|
|
|
sudo apt update
|
2023-04-05 15:04:20 +00:00
|
|
|
sudo apt install -y libpq-dev libffi-dev libssl-dev libkrb5-dev zlib1g-dev postgresql-${{ matrix.pgver }} postgresql-${{ matrix.pgver }}-pldebugger pgagent
|
2023-03-30 14:54:06 +00:00
|
|
|
|
2023-04-06 12:05:42 +00:00
|
|
|
- name: Install platform dependencies on macOS
|
|
|
|
if: ${{ matrix.os == 'macos-latest' }}
|
|
|
|
run: |
|
|
|
|
brew install postgresql@${{ matrix.pgver }}
|
|
|
|
|
|
|
|
- name: Create the tablespace directory on Linux
|
|
|
|
if: ${{ matrix.os == 'ubuntu-latest' }}
|
2023-03-29 15:46:53 +00:00
|
|
|
run: |
|
2023-04-05 15:04:20 +00:00
|
|
|
sudo mkdir -p /var/lib/postgresql/tablespaces/${{ matrix.pgver }}
|
|
|
|
sudo chown postgres:postgres /var/lib/postgresql/tablespaces/${{ matrix.pgver }}
|
2023-03-30 14:54:06 +00:00
|
|
|
|
2023-04-06 12:05:42 +00:00
|
|
|
- name: Create the tablespace directory on macOS
|
|
|
|
if: ${{ matrix.os == 'macos-latest' }}
|
|
|
|
run: |
|
|
|
|
mkdir -p /usr/local/var/tablespaces/${{ matrix.pgver }}
|
|
|
|
|
|
|
|
- name: Start PostgreSQL on Linux
|
|
|
|
if: ${{ matrix.os == 'ubuntu-latest' }}
|
2023-03-29 15:46:53 +00:00
|
|
|
run: |
|
2023-03-30 10:16:46 +00:00
|
|
|
# Note: we use a custom port for PostgreSQL as the runner may already have a version of PostgreSQL installed
|
2023-04-05 15:04:20 +00:00
|
|
|
sudo su -c "echo local all all trust > /etc/postgresql/${{ matrix.pgver }}/main/pg_hba.conf"
|
|
|
|
sudo sed -i "s/port = 543[0-9]/port = 59${{ matrix.pgver }}/g" /etc/postgresql/${{ matrix.pgver }}/main/postgresql.conf
|
|
|
|
sudo sed -i "s/#shared_preload_libraries = ''/shared_preload_libraries = '\$libdir\/plugin_debugger'/g" /etc/postgresql/${{ matrix.pgver }}/main/postgresql.conf
|
|
|
|
sudo su - postgres -c "/usr/lib/postgresql/${{ matrix.pgver }}/bin/postgres -D /var/lib/postgresql/${{ matrix.pgver }}/main -c config_file=/etc/postgresql/${{ matrix.pgver }}/main/postgresql.conf &"
|
2023-03-30 14:54:06 +00:00
|
|
|
|
2023-04-05 15:04:20 +00:00
|
|
|
until sudo runuser -l postgres -c "pg_isready -p 59${{ matrix.pgver }}" 2>/dev/null; do
|
|
|
|
>&2 echo "Postgres is unavailable - sleeping for 2 seconds"
|
|
|
|
sleep 2
|
2023-03-29 15:46:53 +00:00
|
|
|
done
|
2023-04-05 15:04:20 +00:00
|
|
|
|
|
|
|
psql -U postgres -p 59${{ matrix.pgver }} -c 'CREATE EXTENSION pgagent;'
|
|
|
|
psql -U postgres -p 59${{ matrix.pgver }} -c 'CREATE EXTENSION pldbgapi;'
|
2023-03-30 14:54:06 +00:00
|
|
|
|
2023-04-06 12:05:42 +00:00
|
|
|
- name: Start PostgreSQL on macOS
|
|
|
|
if: ${{ matrix.os == 'macos-latest' }}
|
|
|
|
run: |
|
|
|
|
# Note: we use a custom port for PostgreSQL as the runner may already have a version of PostgreSQL installed
|
|
|
|
echo local all all trust > /usr/local/var/postgresql@${{ matrix.pgver }}/pg_hba.conf
|
|
|
|
sed -i '' "s/#port = 543[0-9]/port = 59${{ matrix.pgver }}/g" /usr/local/var/postgresql@${{ matrix.pgver }}/postgresql.conf
|
|
|
|
brew services restart postgresql@${{ matrix.pgver }}
|
|
|
|
|
|
|
|
until /usr/local/opt/postgresql@${{ matrix.pgver }}/bin/pg_isready -p 59${{ matrix.pgver }} 2>/dev/null; do
|
|
|
|
>&2 echo "Postgres is unavailable - sleeping for 2 seconds"
|
|
|
|
sleep 2
|
|
|
|
done
|
|
|
|
|
|
|
|
psql postgres -p 59${{ matrix.pgver }} -c 'CREATE ROLE postgres SUPERUSER LOGIN;'
|
|
|
|
|
2023-03-29 15:46:53 +00:00
|
|
|
- name: Install Python dependencies
|
2023-04-05 14:06:59 +00:00
|
|
|
run: make install-python-testing
|
2023-03-30 14:54:06 +00:00
|
|
|
|
2023-03-29 15:46:53 +00:00
|
|
|
- name: Create the test configuration
|
|
|
|
run: |
|
|
|
|
cat <<EOF > web/config_local.py
|
|
|
|
from config import *
|
2023-03-30 14:54:06 +00:00
|
|
|
|
2023-03-29 15:46:53 +00:00
|
|
|
# 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
|
2023-03-30 14:54:06 +00:00
|
|
|
|
2023-03-29 15:46:53 +00:00
|
|
|
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": [
|
|
|
|
{
|
2023-04-05 15:04:20 +00:00
|
|
|
"name": "PostgreSQL ${{ matrix.pgver }}",
|
|
|
|
"comment": "PostgreSQL ${{ matrix.pgver }} Server",
|
2023-03-29 15:46:53 +00:00
|
|
|
"db_username": "postgres",
|
2023-04-06 12:05:42 +00:00
|
|
|
"host": "${{ matrix.os == 'macos-latest' && '/tmp' || '/var/run/postgresql' }}",
|
2023-03-29 15:46:53 +00:00
|
|
|
"db_password": "postgres",
|
2023-04-05 15:04:20 +00:00
|
|
|
"db_port": 59${{ matrix.pgver }},
|
2023-03-29 15:46:53 +00:00
|
|
|
"maintenance_db": "postgres",
|
|
|
|
"sslmode": "prefer",
|
2023-04-06 12:05:42 +00:00
|
|
|
"tablespace_path": "${{ matrix.os == 'macos-latest' && format('/usr/local/var/tablespaces/{0}', matrix.pgver) || format('/var/lib/postgresql/tablespaces/{0}', matrix.pgver) }}",
|
2023-03-29 15:46:53 +00:00
|
|
|
"enabled": true,
|
|
|
|
"default_binary_paths": {
|
2023-04-06 12:05:42 +00:00
|
|
|
"pg": "${{ matrix.os == 'macos-latest' && format('/usr/local/opt/postgresql@{0}/bin', matrix.pgver) || format('/usr/lib/postgresql/{0}/bin', matrix.pgver) }}",
|
2023-03-29 15:46:53 +00:00
|
|
|
"ppas": ""
|
|
|
|
}
|
2023-04-05 15:04:20 +00:00
|
|
|
}
|
2023-03-29 15:46:53 +00:00
|
|
|
],
|
|
|
|
"server_update_data": [
|
|
|
|
{
|
|
|
|
"comment": "This is test update comment"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
EOF
|
2023-03-30 14:54:06 +00:00
|
|
|
|
2023-03-29 15:46:53 +00:00
|
|
|
- name: Run the tests
|
2023-04-05 14:01:11 +00:00
|
|
|
run: |
|
|
|
|
. venv/bin/activate
|
|
|
|
make check-python
|
2023-03-29 15:46:53 +00:00
|
|
|
|
|
|
|
- name: Archive server log
|
2023-03-30 10:16:46 +00:00
|
|
|
if: success() || failure()
|
2023-03-29 15:46:53 +00:00
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
2023-04-06 12:05:42 +00:00
|
|
|
name: server-log-${{ matrix.os }}-pg${{ matrix.pgver }}
|
2023-03-29 15:46:53 +00:00
|
|
|
path: var/pgadmin4.log
|
|
|
|
|
|
|
|
- name: Archive regression log
|
2023-03-30 10:16:46 +00:00
|
|
|
if: success() || failure()
|
2023-03-29 15:46:53 +00:00
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
2023-04-06 12:05:42 +00:00
|
|
|
name: regression-log-${{ matrix.os }}-pg${{ matrix.pgver }}
|
2023-03-29 15:46:53 +00:00
|
|
|
path: web/regression/regression.log
|