2023-03-31 15:25:35 +00:00
name : Run Python tests on PostgreSQL
2023-03-29 15:46:53 +00:00
2023-04-20 12:34:00 +00:00
# Note: we use a custom port (and installation directory on Windows) for
# PostgreSQL as the runners may already have a version installed.
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 :
2023-10-05 06:27:24 +00:00
run-python-tests-pg :
2023-04-05 15:04:20 +00:00
strategy :
fail-fast : false
matrix :
2024-12-09 07:02:03 +00:00
os : [ macos-latest, ubuntu-22.04, windows-latest]
2024-12-11 07:01:53 +00:00
pgver : [ 13 , 14 , 15 , 16 , 17 ]
2023-04-05 15:04:20 +00:00
2023-04-06 12:05:42 +00:00
runs-on : ${{ matrix.os }}
2023-03-29 15:46:53 +00:00
steps :
2024-03-12 09:56:31 +00:00
- uses : actions/checkout@v4
2023-03-29 15:46:53 +00:00
2023-04-20 12:34:00 +00:00
- name : Setup the PGDG APT repo on Linux
2024-12-09 07:02:03 +00:00
if : ${{ matrix.os == 'ubuntu-22.04' }}
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
2024-12-09 07:02:03 +00:00
if : ${{ matrix.os == 'ubuntu-22.04' }}
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 }}
2024-05-02 07:21:39 +00:00
echo "/opt/homebrew/opt/postgresql@${{ matrix.pgver }}/bin" >> $GITHUB_PATH
2023-04-06 12:05:42 +00:00
2023-04-20 12:34:00 +00:00
- name : Uninstall PostgreSQL if already present
if : ${{ matrix.os == 'windows-latest' }}
run : |
if exist "C:\Program Files\PostgreSQL\{{ matrix.pgver }}\uninstall-postgresql.exe" (
"C:\Program Files\PostgreSQL\{{ matrix.pgver }}\uninstall-postgresql.exe" --mode unattended
)
reg delete "HKLM\SOFTWARE\PostgreSQL" /f
shell : cmd
- name : Install platform dependencies on Windows
if : ${{ matrix.os == 'windows-latest' }}
run : |
2023-10-11 12:54:12 +00:00
FOR /f "delims=" %%F IN ('python tools\get_sb_package.py "https://www.postgresql.org/applications-v2.xml" "postgresql_${{ matrix.pgver }}" "windows-x64"') DO SET INSTALLER_EXE=%%F
ECHO Running %INSTALLER_EXE%...
2023-10-11 13:44:01 +00:00
%INSTALLER_EXE% --prefix C:\PostgreSQL\${{ matrix.pgver }} --datadir C:\PostgreSQL\${{ matrix.pgver }}\data --serverport 59${{ matrix.pgver }} --superpassword postgres --install_runtimes 0 --mode unattended --unattendedmodeui none --disable-components pgAdmin,stackbuilder --enable-components server,commandlinetools"
2023-04-20 12:34:00 +00:00
choco install -y mitkerberos
2024-11-08 10:18:24 +00:00
2023-04-20 12:34:00 +00:00
REM Ignore error 3010 (reboot required)
IF %ERRORLEVEL% EQU 3010 cmd /c "exit /b 0"
shell : cmd
2023-04-06 12:05:42 +00:00
- name : Create the tablespace directory on Linux
2024-12-09 07:02:03 +00:00
if : ${{ matrix.os == 'ubuntu-22.04' }}
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 : |
2024-04-30 12:06:34 +00:00
mkdir -p /opt/homebrew/var/tablespaces/${{ matrix.pgver }}
2023-04-06 12:05:42 +00:00
2023-04-20 12:34:00 +00:00
- name : Create the tablespace directory on Windows
if : ${{ matrix.os == 'windows-latest' }}
run : |
mkdir "C:\PostgreSQL\${{ matrix.pgver }}\tablespaces"
icacls "C:\PostgreSQL\${{ matrix.pgver }}\tablespaces" /grant "NETWORK SERVICE":(OI)(CI)F /T
shell : cmd
2023-04-06 12:05:42 +00:00
- name : Start PostgreSQL on Linux
2024-12-09 07:02:03 +00:00
if : ${{ matrix.os == 'ubuntu-22.04' }}
2023-03-29 15:46:53 +00:00
run : |
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 &"
2024-11-08 10:18:24 +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
2024-11-08 10:18:24 +00:00
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 : |
2024-04-30 12:06:34 +00:00
echo local all all trust > /opt/homebrew/var/postgresql@${{ matrix.pgver }}/pg_hba.conf
sed -i '' "s/#port = 543[0-9]/port = 59${{ matrix.pgver }}/g" /opt/homebrew/var/postgresql@${{ matrix.pgver }}/postgresql.conf
2023-04-06 12:05:42 +00:00
brew services restart postgresql@${{ matrix.pgver }}
2024-11-08 10:18:24 +00:00
2024-04-30 12:06:34 +00:00
until /opt/homebrew/opt/postgresql@${{ matrix.pgver }}/bin/pg_isready -p 59${{ matrix.pgver }} 2>/dev/null; do
2023-04-06 12:05:42 +00:00
>&2 echo "Postgres is unavailable - sleeping for 2 seconds"
sleep 2
done
2024-11-08 10:18:24 +00:00
psql postgres -p 59${{ matrix.pgver }} -c 'CREATE ROLE postgres SUPERUSER LOGIN;'
2024-10-28 08:42:29 +00:00
2023-04-20 12:34:00 +00:00
- name : Install Python dependencies on Linux and macOS
2024-12-09 07:02:03 +00:00
if : ${{ matrix.os == 'macos-latest' || matrix.os == 'ubuntu-22.04' }}
2023-04-05 14:06:59 +00:00
run : make install-python-testing
2023-03-30 14:54:06 +00:00
2023-04-20 12:34:00 +00:00
- name : Install Python dependencies on Windows
if : ${{ matrix.os == 'windows-latest' }}
run : |
SET LIB=C:\PostgreSQL\${{ matrix.pgver }}\lib;%LIB%
SET INCLUDE=C:\PostgreSQL\${{ matrix.pgver }}\include;%INCLUDE%
python -m venv venv
call venv\Scripts\activate.bat
python -m pip install --upgrade pip
pip install wheel sphinx sphinxcontrib-youtube -r web\regression\requirements.txt
shell : cmd
- name : Create the test configuration on Linux and macOS
2024-12-09 07:02:03 +00:00
if : ${{ matrix.os == 'macos-latest' || matrix.os == 'ubuntu-22.04' }}
2023-03-29 15:46:53 +00:00
run : |
cat <<EOF > web/config_local.py
from config import *
2024-11-08 10:18:24 +00:00
2023-03-29 15:46:53 +00:00
# Debug mode
DEBUG = True
2024-11-08 10:18:24 +00:00
2023-03-29 15:46:53 +00:00
# App mode
SERVER_MODE = False
2024-11-08 10:18:24 +00:00
2023-03-29 15:46:53 +00:00
# Log
CONSOLE_LOG_LEVEL = DEBUG
FILE_LOG_LEVEL = DEBUG
2024-11-08 10:18:24 +00:00
2023-03-29 15:46:53 +00:00
DEFAULT_SERVER = '127.0.0.1'
2024-11-08 10:18:24 +00:00
2023-03-29 15:46:53 +00:00
UPGRADE_CHECK_ENABLED = False
2024-11-08 10:18:24 +00:00
2023-03-29 15:46:53 +00:00
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
2024-11-08 10:18:24 +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" ,
2024-12-09 07:02:03 +00:00
"host": "${{ matrix.os == 'macos-latest' && '/tmp' || matrix.os == 'ubuntu-22.04' && '/var/run/postgresql' || '127.0.0.1' }}" ,
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" ,
2024-04-30 12:06:34 +00:00
"tablespace_path": "${{ matrix.os == 'macos-latest' && format('/opt/homebrew/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": {
2024-04-30 12:06:34 +00:00
"pg": "${{ matrix.os == 'macos-latest' && format('/opt/homebrew/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-04-20 12:34:00 +00:00
- name : Create the test configuration on Windows
if : ${{ matrix.os == 'windows-latest' }}
run : |
FOR /f "delims=" %%D IN ('python -c "import os; print(os.getcwd().replace('\\', '\\\\'))"') DO SET WORKING_DIR=%%D
2024-11-08 10:18:24 +00:00
2023-04-20 12:34:00 +00:00
> web\config_local.py (
@echo.from config import *
@echo.
@echo.# Debug mode
@echo.DEBUG = True
@echo.
@echo.# App mode
@echo.SERVER_MODE = False
@echo.
@echo.# Log
@echo.CONSOLE_LOG_LEVEL = DEBUG
@echo.FILE_LOG_LEVEL = DEBUG
@echo.
@echo.DEFAULT_SERVER = '127.0.0.1'
@echo.
@echo.UPGRADE_CHECK_ENABLED = False
@echo.
@echo.LOG_FILE = "%WORKING_DIR%\\var\\pgadmin4.log"
@echo.SESSION_DB_PATH = "%WORKING_DIR%\\var\\sessions"
@echo.STORAGE_DIR = "%WORKING_DIR%\\var\\storage"
@echo.SQLITE_PATH = "%WORKING_DIR%\\var\\pgadmin4.db"
@echo.TEST_SQLITE_PATH = "%WORKING_DIR%\\var\\test_pgadmin4.db"
@echo.AZURE_CREDENTIAL_CACHE_DIR = "%WORKING_DIR%\\var\\azurecredentialcache"
)
2024-11-08 10:18:24 +00:00
2023-04-20 12:34:00 +00:00
> web\regression\test_config.json (
@echo.{
@echo. "pgAdmin4_login_credentials": {
@echo. "new_password": "NEWPASSWORD",
@echo. "login_password": "PASSWORD",
@echo. "login_username": "USER@EXAMPLE.COM"
@echo. },
@echo. "pgAdmin4_test_user_credentials": {
@echo. "new_password": "NEWPASSWORD",
@echo. "login_password": "PASSWORD",
@echo. "login_username": "USER2@EXAMPLE.COM"
@echo. },
@echo. "pgAdmin4_test_non_admin_credentials": {
@echo. "new_password": "NEWPASSWORD",
@echo. "login_password": "PASSWORD",
@echo. "login_username": "USER@EXAMPLE.COM"
@echo. },
@echo. "server_group": 1,
@echo. "server_credentials": [
@echo. {
@echo. "name": "PostgreSQL ${{ matrix.pgver }}",
@echo. "comment": "PostgreSQL ${{ matrix.pgver }} Server",
@echo. "db_username": "postgres",
@echo. "host": "127.0.0.1",
@echo. "db_password": "postgres",
@echo. "db_port": 59${{ matrix.pgver }},
@echo. "maintenance_db": "postgres",
@echo. "sslmode": "prefer",
@echo. "tablespace_path": "C:\\PostgreSQL\\${{ matrix.pgver }}\\tablespaces",
@echo. "enabled": true,
@echo. "default_binary_paths": {
@echo. "pg": "C:\\PostgreSQL\\${{ matrix.pgver }}\\bin",
@echo. "ppas": ""
@echo. }
@echo. }
@echo. ],
@echo. "server_update_data": [
@echo. {
@echo. "comment": "This is test update comment"
@echo. }
@echo. ]
@echo.}
)
shell : cmd
- name : Run the tests on Linux and macOS
2024-12-09 07:02:03 +00:00
if : ${{ matrix.os == 'macos-latest' || matrix.os == 'ubuntu-22.04' }}
2023-04-05 14:01:11 +00:00
run : |
. venv/bin/activate
make check-python
2023-03-29 15:46:53 +00:00
2023-04-20 12:34:00 +00:00
- name : Run the tests on Windows
if : ${{ matrix.os == 'windows-latest' }}
run : |
call venv\Scripts\activate.bat
python web\regression\runtests.py --exclude feature_tests
shell : cmd
2023-03-29 15:46:53 +00:00
- name : Archive server log
2023-03-30 10:16:46 +00:00
if : success() || failure()
2024-03-12 10:34:15 +00:00
uses : actions/upload-artifact@v4
2023-03-29 15:46:53 +00:00
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()
2024-03-12 10:34:15 +00:00
uses : actions/upload-artifact@v4
2023-03-29 15:46:53 +00:00
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
2023-04-20 12:34:00 +00:00