mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-26 11:08:13 +00:00
ci/windows: add Postgresql setup action to tests
This commit is contained in:
83
.github/actions/setup-postgresql-windows/action.yml
vendored
Normal file
83
.github/actions/setup-postgresql-windows/action.yml
vendored
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
name: 'Setup Postgresql and Postgis on Windows'
|
||||||
|
|
||||||
|
description: 'Installs PostgreSQL and PostGIS for Windows and configures it for CI tests'
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
postgresql-version:
|
||||||
|
description: 'Version of PostgreSQL to install'
|
||||||
|
required: true
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Decide Postgis version (Windows)
|
||||||
|
id: postgis-ver
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
echo "PowerShell version: ${PSVersionTable.PSVersion}"
|
||||||
|
$PG_VERSION = Split-Path $env:PGROOT -Leaf
|
||||||
|
$postgis_page = "https://download.osgeo.org/postgis/windows/pg$PG_VERSION"
|
||||||
|
echo "Detecting PostGIS version from $postgis_page for PostgreSQL $PG_VERSION"
|
||||||
|
$pgis_bundle = (Invoke-WebRequest -Uri $postgis_page -ErrorAction Stop).Links.Where({$_.href -match "^postgis.*zip$"}).href
|
||||||
|
if (!$pgis_bundle) {
|
||||||
|
Write-Error "Could not find latest PostGIS version in $postgis_page that would match ^postgis.*zip$ pattern"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
$pgis_bundle = [IO.Path]::ChangeExtension($pgis_bundle, [NullString]::Value)
|
||||||
|
$pgis_bundle_url = "$postgis_page/$pgis_bundle.zip"
|
||||||
|
Add-Content $env:GITHUB_OUTPUT "postgis_file=$pgis_bundle"
|
||||||
|
Add-Content $env:GITHUB_OUTPUT "postgis_bundle_url=$pgis_bundle_url"
|
||||||
|
|
||||||
|
- uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
C:/postgis.zip
|
||||||
|
key: postgis-cache-${{ steps.postgis-ver.outputs.postgis_file }}
|
||||||
|
|
||||||
|
- name: Download postgis
|
||||||
|
run: |
|
||||||
|
if (!(Test-Path "C:\postgis.zip")){(new-object net.webclient).DownloadFile($env:PGIS_BUNDLE_URL, "c:\postgis.zip")}
|
||||||
|
if (Test-path "c:\postgis_archive"){Remove-Item "c:\postgis_archive" -Recurse -Force}
|
||||||
|
7z x c:\postgis.zip -oc:\postgis_archive
|
||||||
|
shell: pwsh
|
||||||
|
env:
|
||||||
|
PGIS_BUNDLE_URL: ${{ steps.postgis-ver.outputs.postgis_bundle_url }}
|
||||||
|
|
||||||
|
- name: Install postgis
|
||||||
|
run: |
|
||||||
|
echo "Root: $PGROOT, Bin: $PGBIN"
|
||||||
|
cp -r c:/postgis_archive/postgis-bundle-*/* "$PGROOT"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Start PostgreSQL on Windows
|
||||||
|
run: |
|
||||||
|
$pgService = Get-Service -Name postgresql*
|
||||||
|
Set-Service -InputObject $pgService -Status running -StartupType automatic
|
||||||
|
Start-Process -FilePath "$env:PGBIN\pg_isready" -Wait -PassThru
|
||||||
|
shell: pwsh
|
||||||
|
|
||||||
|
- name: Adapt postgresql configuration
|
||||||
|
shell: pwsh
|
||||||
|
env:
|
||||||
|
PGPASSWORD: root
|
||||||
|
run: |
|
||||||
|
& "$env:PGBIN\psql" -U postgres -d postgres -c "ALTER SYSTEM SET fsync = 'off';"
|
||||||
|
& "$env:PGBIN\psql" -U postgres -d postgres -c "ALTER SYSTEM SET synchronous_commit = 'off';"
|
||||||
|
& "$env:PGBIN\psql" -U postgres -d postgres -c "ALTER SYSTEM SET full_page_writes = 'off';"
|
||||||
|
& "$env:PGBIN\psql" -U postgres -d postgres -c "ALTER SYSTEM SET shared_buffers = '1GB';"
|
||||||
|
& "$env:PGBIN\psql" -U postgres -d postgres -c "ALTER SYSTEM SET port = 5432;"
|
||||||
|
|
||||||
|
Restart-Service -Name postgresql*
|
||||||
|
Start-Process -FilePath "$env:PGBIN\pg_isready" -Wait -PassThru
|
||||||
|
|
||||||
|
- name: Setup database users
|
||||||
|
shell: pwsh
|
||||||
|
env:
|
||||||
|
PGPASSWORD: root
|
||||||
|
run: |
|
||||||
|
& "$env:PGBIN\createuser" -U postgres -S www-data
|
||||||
|
& "$env:PGBIN\createuser" -U postgres -s runner
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
2
.github/actions/setup-postgresql/action.yml
vendored
2
.github/actions/setup-postgresql/action.yml
vendored
@@ -1,5 +1,7 @@
|
|||||||
name: 'Setup Postgresql and Postgis'
|
name: 'Setup Postgresql and Postgis'
|
||||||
|
|
||||||
|
description: 'Installs PostgreSQL and PostGIS and configures it for CI tests'
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
postgresql-version:
|
postgresql-version:
|
||||||
description: 'Version of PostgreSQL to install'
|
description: 'Version of PostgreSQL to install'
|
||||||
|
|||||||
4
.github/workflows/ci-tests.yml
vendored
4
.github/workflows/ci-tests.yml
vendored
@@ -152,6 +152,10 @@ jobs:
|
|||||||
- name: Unpack Nominatim
|
- name: Unpack Nominatim
|
||||||
run: tar xf nominatim-src.tar.bz2
|
run: tar xf nominatim-src.tar.bz2
|
||||||
|
|
||||||
|
- uses: ./Nominatim/.github/actions/setup-postgresql-windows
|
||||||
|
with:
|
||||||
|
postgresql-version: 16
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
|
|||||||
Reference in New Issue
Block a user