1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2024-11-21 18:17:06 +02:00

Add a workflow to build and test probackup on Windows (#484)

* Add a workflow to build and test probackup on Windows

* [PBCKP-149] fix test_basic_validate_nullified_heap_page_backup for windows

Co-authored-by: Alexey Savchkov <a.savchkov@postgrespro.ru>
Co-authored-by: Mikhail A. Kulagin <m.kulagin@postgrespro.ru>
This commit is contained in:
asavchkov 2022-05-26 19:53:01 +07:00 committed by GitHub
parent 68b77a06bc
commit 0b5b37e893
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 104 additions and 13 deletions

94
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,94 @@
name: Build Probackup
on:
push:
branches:
- "**"
# Runs triggered by pull requests are disabled to prevent executing potentially unsafe code from public pull requests
# pull_request:
# branches:
# - main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build-win2019:
runs-on:
- windows-2019
env:
zlib_dir: C:\dep\zlib
steps:
- uses: actions/checkout@v2
- name: Install pacman packages
run: |
$env:PATH += ";C:\msys64\usr\bin"
pacman -S --noconfirm --needed bison flex
- name: Make zlib
run: |
git clone -b v1.2.11 --depth 1 https://github.com/madler/zlib.git
cd zlib
cmake -DCMAKE_INSTALL_PREFIX:PATH=C:\dep\zlib -G "Visual Studio 16 2019" .
cmake --build . --config Release --target ALL_BUILD
cmake --build . --config Release --target INSTALL
copy C:\dep\zlib\lib\zlibstatic.lib C:\dep\zlib\lib\zdll.lib
copy C:\dep\zlib\bin\zlib.dll C:\dep\zlib\lib
- name: Get Postgres sources
run: git clone -b REL_14_STABLE https://github.com/postgres/postgres.git
# Copy ptrack to contrib to build the ptrack extension
# Convert line breaks in the patch file to LF otherwise the patch doesn't apply
- name: Get Ptrack sources
run: |
git clone -b master --depth 1 https://github.com/postgrespro/ptrack.git
Copy-Item -Path ptrack -Destination postgres\contrib -Recurse
(Get-Content ptrack\patches\REL_14_STABLE-ptrack-core.diff -Raw).Replace("`r`n","`n") | Set-Content ptrack\patches\REL_14_STABLE-ptrack-core.diff -Force -NoNewline
cd postgres
git apply -3 ../ptrack/patches/REL_14_STABLE-ptrack-core.diff
- name: Build Postgres
run: |
$env:PATH += ";C:\msys64\usr\bin"
cd postgres\src\tools\msvc
(Get-Content config_default.pl) -Replace "zlib *=>(.*?)(?=,? *#)", "zlib => '${{ env.zlib_dir }}'" | Set-Content config.pl
cmd.exe /s /c "`"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat`" amd64 && .\build.bat"
- name: Build Probackup
run: cmd.exe /s /c "`"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat`" amd64 && perl .\gen_probackup_project.pl `"${{ github.workspace }}`"\postgres"
- name: Install Postgres
run: |
cd postgres
src\tools\msvc\install.bat postgres_install
- name: Install Testgres
run: |
git clone -b no-port-for --single-branch --depth 1 https://github.com/postgrespro/testgres.git
cd testgres
python setup.py install
# Grant the Github runner user full control of the workspace for initdb to successfully process the data folder
- name: Test Probackup
run: |
icacls.exe "${{ github.workspace }}" /grant "${env:USERNAME}:(OI)(CI)F"
$env:PATH += ";${{ github.workspace }}\postgres\postgres_install\lib;${{ env.zlib_dir }}\lib"
$Env:LC_MESSAGES = "English"
$Env:PG_CONFIG = "${{ github.workspace }}\postgres\postgres_install\bin\pg_config.exe"
$Env:PGPROBACKUPBIN = "${{ github.workspace }}\postgres\Release\pg_probackup\pg_probackup.exe"
$Env:PG_PROBACKUP_PTRACK = "ON"
If (!$Env:MODE -Or $Env:MODE -Eq "basic") {
$Env:PG_PROBACKUP_TEST_BASIC = "ON"
python -m unittest -v tests
python -m unittest -v tests.init
} else {
python -m unittest -v tests.$Env:MODE
}

View File

@ -13,11 +13,11 @@ if (($#ARGV+1)==1)
{
$pgsrc = shift @ARGV;
if($pgsrc eq "--help"){
print STDERR "Usage $0 pg-source-dir \n";
print STDERR "Like this: \n";
print STDERR "$0 C:/PgProject/postgresql.10dev/postgrespro \n";
print STDERR "May be need input this before: \n";
print STDERR "CALL \"C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\vcvarsall\" amd64\n";
print STDERR "Usage $0 pg-source-dir\n";
print STDERR "Like this:\n";
print STDERR "$0 C:/PgProject/postgresql.10dev/postgrespro\n";
print STDERR "May need to run this first:\n";
print STDERR "CALL \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat\" amd64\n";
exit 1;
}
}
@ -133,7 +133,7 @@ sub build_pgprobackup
unless (-d 'src/tools/msvc' && -d 'src');
# my $vsVersion = DetermineVisualStudioVersion();
my $vsVersion = '12.00';
my $vsVersion = '16.00';
$solution = CreateSolution($vsVersion, $config);

View File

@ -89,11 +89,7 @@ def dir_files(base_dir):
def is_enterprise():
# pg_config --help
if os.name == 'posix':
cmd = [os.environ['PG_CONFIG'], '--help']
elif os.name == 'nt':
cmd = [[os.environ['PG_CONFIG']], ['--help']]
cmd = [os.environ['PG_CONFIG'], '--help']
p = subprocess.Popen(
cmd,

View File

@ -2,6 +2,7 @@ import os
import unittest
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
from datetime import datetime, timedelta
from pathlib import Path
import subprocess
from sys import exit
import time
@ -58,7 +59,7 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
with open(log_file_path) as f:
log_content = f.read()
self.assertIn(
'File: "{0}" blknum 1, empty page'.format(file),
'File: "{0}" blknum 1, empty page'.format(Path(file).as_posix()),
log_content,
'Failed to detect nullified block')
@ -4247,4 +4248,4 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
# 715 MAXALIGN(header.compressed_size), in);
# 716 if (read_len != MAXALIGN(header.compressed_size))
# -> 717 elog(ERROR, "cannot read block %u of \"%s\" read %lu of %d",
# 718 blknum, file->path, read_len, header.compressed_size);
# 718 blknum, file->path, read_len, header.compressed_size);