-
Notifications
You must be signed in to change notification settings - Fork 655
307 lines (266 loc) · 12.8 KB
/
run-python-tests-pg.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
name: Run Python tests on PostgreSQL
# Note: we use a custom port (and installation directory on Windows) for
# PostgreSQL as the runners may already have a version installed.
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
jobs:
run-python-tests-pg:
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
pgver: [12, 13, 14, 15, 16]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup the PGDG APT repo on Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
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 on Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
sudo apt update
sudo apt install -y libpq-dev libffi-dev libssl-dev libkrb5-dev zlib1g-dev postgresql-${{ matrix.pgver }} postgresql-${{ matrix.pgver }}-pldebugger pgagent
- name: Install platform dependencies on macOS
if: ${{ matrix.os == 'macos-latest' }}
run: |
brew install postgresql@${{ matrix.pgver }}
echo "/opt/homebrew/opt/postgresql@${{ matrix.pgver }}/bin" >> $GITHUB_PATH
- 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: |
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%...
%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"
choco install -y mitkerberos
REM Ignore error 3010 (reboot required)
IF %ERRORLEVEL% EQU 3010 cmd /c "exit /b 0"
shell: cmd
- name: Create the tablespace directory on Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
sudo mkdir -p /var/lib/postgresql/tablespaces/${{ matrix.pgver }}
sudo chown postgres:postgres /var/lib/postgresql/tablespaces/${{ matrix.pgver }}
- name: Create the tablespace directory on macOS
if: ${{ matrix.os == 'macos-latest' }}
run: |
mkdir -p /opt/homebrew/var/tablespaces/${{ matrix.pgver }}
- 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
- name: Start PostgreSQL on Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
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 &"
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
done
psql -U postgres -p 59${{ matrix.pgver }} -c 'CREATE EXTENSION pgagent;'
psql -U postgres -p 59${{ matrix.pgver }} -c 'CREATE EXTENSION pldbgapi;'
- name: Start PostgreSQL on macOS
if: ${{ matrix.os == 'macos-latest' }}
run: |
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
brew services restart postgresql@${{ matrix.pgver }}
until /opt/homebrew/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;'
- name: Install Python dependencies on Linux and macOS
if: ${{ matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest' }}
run: make install-python-testing
- 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
if: ${{ matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest' }}
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": "[email protected]"
},
"pgAdmin4_test_user_credentials": {
"new_password": "NEWPASSWORD",
"login_password": "PASSWORD",
"login_username": "[email protected]"
},
"pgAdmin4_test_non_admin_credentials": {
"new_password": "NEWPASSWORD",
"login_password": "PASSWORD",
"login_username": "[email protected]"
},
"server_group": 1,
"server_credentials": [
{
"name": "PostgreSQL ${{ matrix.pgver }}",
"comment": "PostgreSQL ${{ matrix.pgver }} Server",
"db_username": "postgres",
"host": "${{ matrix.os == 'macos-latest' && '/tmp' || matrix.os == 'ubuntu-latest' && '/var/run/postgresql' || '127.0.0.1' }}",
"db_password": "postgres",
"db_port": 59${{ matrix.pgver }},
"maintenance_db": "postgres",
"sslmode": "prefer",
"tablespace_path": "${{ matrix.os == 'macos-latest' && format('/opt/homebrew/var/tablespaces/{0}', matrix.pgver) || format('/var/lib/postgresql/tablespaces/{0}', matrix.pgver) }}",
"enabled": true,
"default_binary_paths": {
"pg": "${{ matrix.os == 'macos-latest' && format('/opt/homebrew/opt/postgresql@{0}/bin', matrix.pgver) || format('/usr/lib/postgresql/{0}/bin', matrix.pgver) }}",
"ppas": ""
}
}
],
"server_update_data": [
{
"comment": "This is test update comment"
}
]
}
EOF
- 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
> 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"
)
> web\regression\test_config.json (
@echo.{
@echo. "pgAdmin4_login_credentials": {
@echo. "new_password": "NEWPASSWORD",
@echo. "login_password": "PASSWORD",
@echo. "login_username": "[email protected]"
@echo. },
@echo. "pgAdmin4_test_user_credentials": {
@echo. "new_password": "NEWPASSWORD",
@echo. "login_password": "PASSWORD",
@echo. "login_username": "[email protected]"
@echo. },
@echo. "pgAdmin4_test_non_admin_credentials": {
@echo. "new_password": "NEWPASSWORD",
@echo. "login_password": "PASSWORD",
@echo. "login_username": "[email protected]"
@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
if: ${{ matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest' }}
run: |
. venv/bin/activate
make check-python
- 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
- name: Archive server log
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: server-log-${{ matrix.os }}-pg${{ matrix.pgver }}
path: var/pgadmin4.log
- name: Archive regression log
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: regression-log-${{ matrix.os }}-pg${{ matrix.pgver }}
path: web/regression/regression.log