mirror of
				https://github.com/pgadmin-org/pgadmin4.git
				synced 2025-02-25 18:55:31 -06:00 
			
		
		
		
	Run Python tests on Windows.
This commit is contained in:
		
							
								
								
									
										143
									
								
								.github/workflows/run-python-tests-pg.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										143
									
								
								.github/workflows/run-python-tests-pg.yml
									
									
									
									
										vendored
									
									
								
							| @@ -1,5 +1,8 @@ | ||||
| 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" ] | ||||
| @@ -17,7 +20,7 @@ jobs: | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         os: [macos-latest, ubuntu-latest] | ||||
|         os: [macos-latest, ubuntu-latest, windows-latest] | ||||
|         pgver: [11, 12, 13, 14, 15] | ||||
|  | ||||
|     runs-on: ${{ matrix.os }} | ||||
| @@ -25,7 +28,7 @@ jobs: | ||||
|     steps: | ||||
|       - uses: actions/checkout@v3 | ||||
|  | ||||
|       - name: Setup the PGDG APT repo | ||||
|       - 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' | ||||
| @@ -42,6 +45,25 @@ jobs: | ||||
|         run: | | ||||
|           brew install postgresql@${{ matrix.pgver }} | ||||
|  | ||||
|       - 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: | | ||||
|           choco install -y postgresql${{ matrix.pgver }} --params "/Password:postgres /Port:59${{ matrix.pgver }}" --ia "--prefix C:\PostgreSQL\${{ matrix.pgver }} --datadir C:\PostgreSQL\${{ matrix.pgver }}\data --install_runtimes 0 --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: | | ||||
| @@ -53,10 +75,16 @@ jobs: | ||||
|         run: | | ||||
|           mkdir -p /usr/local/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: | | ||||
|           # Note: we use a custom port for PostgreSQL as the runner may already have a version of PostgreSQL installed | ||||
|           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 | ||||
| @@ -73,7 +101,6 @@ jobs: | ||||
|       - 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 }} | ||||
| @@ -85,10 +112,23 @@ jobs: | ||||
|            | ||||
|           psql postgres -p 59${{ matrix.pgver }} -c 'CREATE ROLE postgres SUPERUSER LOGIN;' | ||||
|  | ||||
|       - name: Install Python dependencies | ||||
|       - name: Install Python dependencies on Linux and macOS | ||||
|         if: ${{ matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest' }} | ||||
|         run: make install-python-testing | ||||
|  | ||||
|       - name: Create the test configuration | ||||
|       - 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 * | ||||
| @@ -138,12 +178,12 @@ jobs: | ||||
|                 "name": "PostgreSQL ${{ matrix.pgver }}", | ||||
|                 "comment": "PostgreSQL ${{ matrix.pgver }} Server", | ||||
|                 "db_username": "postgres", | ||||
|                 "host": "${{ matrix.os == 'macos-latest' && '/tmp' || '/var/run/postgresql' }}", | ||||
|                 "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('/usr/local/var/tablespaces/{0}', matrix.pgver) || format('/var/lib/postgresql/tablespaces/{0}', matrix.pgver) }}", | ||||
|                 "tablespace_path": "${{ matrix.os == 'macos-latest' && format('/usr/local/var/tablespaces/{0}', matrix.pgver) || format('/var/lib/postgresql/tablespaces/{0}', matrix.pgver) }}", | ||||
|                 "enabled": true, | ||||
|                 "default_binary_paths": { | ||||
|                   "pg": "${{ matrix.os == 'macos-latest' && format('/usr/local/opt/postgresql@{0}/bin', matrix.pgver) || format('/usr/lib/postgresql/{0}/bin', matrix.pgver) }}", | ||||
| @@ -159,11 +199,94 @@ jobs: | ||||
|           } | ||||
|           EOF | ||||
|  | ||||
|       - name: Run the tests | ||||
|       - 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": "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 | ||||
|         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@v3 | ||||
| @@ -177,3 +300,5 @@ jobs: | ||||
|         with: | ||||
|           name: regression-log-${{ matrix.os }}-pg${{ matrix.pgver }} | ||||
|           path: web/regression/regression.log | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user