Skip to content

Support building pgsodium on windows #239

Support building pgsodium on windows

Support building pgsodium on windows #239

Workflow file for this run

name: Tests
on: [push, pull_request]
jobs:
test_linux:
name: Linux build and tests
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: Run tests
run: |
./test.sh
test_windows:
name: Windows build and tests
runs-on: windows-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1
- name: Install dependencies
run: |
Invoke-WebRequest -URI https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable-msvc.zip -OutFile libsodium-1.0.18-stable-msvc.zip
tar -xf libsodium-1.0.18-stable-msvc.zip
rm libsodium-1.0.18-stable-msvc.zip
cp .\libsodium\x64\Release\v143\dynamic\libsodium.dll $env:PGROOT\lib
Invoke-WebRequest -URI https://github.com/theory/pgtap/archive/refs/tags/v1.2.0.zip -OutFile pgtap.zip
tar -xf pgtap.zip
rm pgtap.zip
cd pgtap-1.2.0
cp .\sql\pgtap.sql.in .\sql\pgtap.sql
perl.exe '-pi.bak' -e "s/TAPSCHEMA/tap/g" .\sql\pgtap.sql
perl.exe '-pi.bak' -e "s/__OS__/win32/g" .\sql\pgtap.sql
perl.exe '-pi.bak' -e "s/__VERSION__/0.24/g" .\sql\pgtap.sql
perl.exe '-pi.bak' -e "s/^-- ## //g" .\sql\pgtap.sql
cp .\sql\pgtap.sql $env:PGROOT\share\extension
cp .\pgtap.control $env:PGROOT\share\extension
cp .\contrib\pgtap.spec $env:PGROOT\share\contrib
ren $env:PGROOT\share\extension\pgtap.sql $env:PGROOT\share\extension\pgtap--1.2.0.sql
shell: pwsh
- name: Run msbuild
working-directory: ./build
run: |
msbuild pgsodium.vcxproj /p:libsodiumLocation=..\libsodium /p:PostgreSQLLocation=%PGROOT% /p:Configuration=Release /p:Platform=x64 /p:platformToolset=v143
- name: Install pgsodium, update config, and restart
run: |
cp .\build\x64\Release\pgsodium.dll $env:PGROOT\lib
cp pgsodium.control $env:PGROOT\share\extension
cp .\sql\* $env:PGROOT\share\extension
cp .\getkey_scripts\pgsodium_getkey.bat $env:PGDATA\
((Get-Content -Path $env:PGDATA\postgresql.conf) -Replace "#shared_preload_libraries = ''","shared_preload_libraries = 'pgsodium'") | Set-Content -Path $env:PGDATA\postgresql.conf
Add-Content -Path $env:PGDATA\postgresql.conf -Value ("pgsodium.getkey_script = '$env:PGDATA\pgsodium_getkey.bat'" -Replace "\\","/")
& $env:PGBIN\pg_ctl restart -D $env:PGDATA
shell: pwsh
- name: Run pgsodium tests
run: |
& $env:PGBIN\psql -q -U postgres -f .\test\test.sql
shell: pwsh