Skip to content

Commit 0b5b37e

Browse files
asavchkovpostgres-devkulaginm
authored
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>
1 parent 68b77a0 commit 0b5b37e

File tree

4 files changed

+104
-13
lines changed

4 files changed

+104
-13
lines changed

.github/workflows/build.yml

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Build Probackup
2+
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
# Runs triggered by pull requests are disabled to prevent executing potentially unsafe code from public pull requests
8+
# pull_request:
9+
# branches:
10+
# - main
11+
12+
# Allows you to run this workflow manually from the Actions tab
13+
workflow_dispatch:
14+
15+
jobs:
16+
17+
build-win2019:
18+
19+
runs-on:
20+
- windows-2019
21+
22+
env:
23+
zlib_dir: C:\dep\zlib
24+
25+
steps:
26+
27+
- uses: actions/checkout@v2
28+
29+
- name: Install pacman packages
30+
run: |
31+
$env:PATH += ";C:\msys64\usr\bin"
32+
pacman -S --noconfirm --needed bison flex
33+
34+
- name: Make zlib
35+
run: |
36+
git clone -b v1.2.11 --depth 1 https://github.com/madler/zlib.git
37+
cd zlib
38+
cmake -DCMAKE_INSTALL_PREFIX:PATH=C:\dep\zlib -G "Visual Studio 16 2019" .
39+
cmake --build . --config Release --target ALL_BUILD
40+
cmake --build . --config Release --target INSTALL
41+
copy C:\dep\zlib\lib\zlibstatic.lib C:\dep\zlib\lib\zdll.lib
42+
copy C:\dep\zlib\bin\zlib.dll C:\dep\zlib\lib
43+
44+
- name: Get Postgres sources
45+
run: git clone -b REL_14_STABLE https://github.com/postgres/postgres.git
46+
47+
# Copy ptrack to contrib to build the ptrack extension
48+
# Convert line breaks in the patch file to LF otherwise the patch doesn't apply
49+
- name: Get Ptrack sources
50+
run: |
51+
git clone -b master --depth 1 https://github.com/postgrespro/ptrack.git
52+
Copy-Item -Path ptrack -Destination postgres\contrib -Recurse
53+
(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
54+
cd postgres
55+
git apply -3 ../ptrack/patches/REL_14_STABLE-ptrack-core.diff
56+
57+
- name: Build Postgres
58+
run: |
59+
$env:PATH += ";C:\msys64\usr\bin"
60+
cd postgres\src\tools\msvc
61+
(Get-Content config_default.pl) -Replace "zlib *=>(.*?)(?=,? *#)", "zlib => '${{ env.zlib_dir }}'" | Set-Content config.pl
62+
cmd.exe /s /c "`"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat`" amd64 && .\build.bat"
63+
64+
- name: Build Probackup
65+
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"
66+
67+
- name: Install Postgres
68+
run: |
69+
cd postgres
70+
src\tools\msvc\install.bat postgres_install
71+
72+
- name: Install Testgres
73+
run: |
74+
git clone -b no-port-for --single-branch --depth 1 https://github.com/postgrespro/testgres.git
75+
cd testgres
76+
python setup.py install
77+
78+
# Grant the Github runner user full control of the workspace for initdb to successfully process the data folder
79+
- name: Test Probackup
80+
run: |
81+
icacls.exe "${{ github.workspace }}" /grant "${env:USERNAME}:(OI)(CI)F"
82+
$env:PATH += ";${{ github.workspace }}\postgres\postgres_install\lib;${{ env.zlib_dir }}\lib"
83+
$Env:LC_MESSAGES = "English"
84+
$Env:PG_CONFIG = "${{ github.workspace }}\postgres\postgres_install\bin\pg_config.exe"
85+
$Env:PGPROBACKUPBIN = "${{ github.workspace }}\postgres\Release\pg_probackup\pg_probackup.exe"
86+
$Env:PG_PROBACKUP_PTRACK = "ON"
87+
If (!$Env:MODE -Or $Env:MODE -Eq "basic") {
88+
$Env:PG_PROBACKUP_TEST_BASIC = "ON"
89+
python -m unittest -v tests
90+
python -m unittest -v tests.init
91+
} else {
92+
python -m unittest -v tests.$Env:MODE
93+
}
94+

gen_probackup_project.pl

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ BEGIN
1313
{
1414
$pgsrc = shift @ARGV;
1515
if($pgsrc eq "--help"){
16-
print STDERR "Usage $0 pg-source-dir \n";
17-
print STDERR "Like this: \n";
18-
print STDERR "$0 C:/PgProject/postgresql.10dev/postgrespro \n";
19-
print STDERR "May be need input this before: \n";
20-
print STDERR "CALL \"C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\vcvarsall\" amd64\n";
16+
print STDERR "Usage $0 pg-source-dir\n";
17+
print STDERR "Like this:\n";
18+
print STDERR "$0 C:/PgProject/postgresql.10dev/postgrespro\n";
19+
print STDERR "May need to run this first:\n";
20+
print STDERR "CALL \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat\" amd64\n";
2121
exit 1;
2222
}
2323
}
@@ -133,7 +133,7 @@ sub build_pgprobackup
133133
unless (-d 'src/tools/msvc' && -d 'src');
134134

135135
# my $vsVersion = DetermineVisualStudioVersion();
136-
my $vsVersion = '12.00';
136+
my $vsVersion = '16.00';
137137

138138
$solution = CreateSolution($vsVersion, $config);
139139

tests/helpers/ptrack_helpers.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,7 @@ def dir_files(base_dir):
8989

9090
def is_enterprise():
9191
# pg_config --help
92-
if os.name == 'posix':
93-
cmd = [os.environ['PG_CONFIG'], '--help']
94-
95-
elif os.name == 'nt':
96-
cmd = [[os.environ['PG_CONFIG']], ['--help']]
92+
cmd = [os.environ['PG_CONFIG'], '--help']
9793

9894
p = subprocess.Popen(
9995
cmd,

tests/validate.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import unittest
33
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
44
from datetime import datetime, timedelta
5+
from pathlib import Path
56
import subprocess
67
from sys import exit
78
import time
@@ -58,7 +59,7 @@ def test_basic_validate_nullified_heap_page_backup(self):
5859
with open(log_file_path) as f:
5960
log_content = f.read()
6061
self.assertIn(
61-
'File: "{0}" blknum 1, empty page'.format(file),
62+
'File: "{0}" blknum 1, empty page'.format(Path(file).as_posix()),
6263
log_content,
6364
'Failed to detect nullified block')
6465

@@ -4247,4 +4248,4 @@ def test_no_validate_tablespace_map(self):
42474248
# 715 MAXALIGN(header.compressed_size), in);
42484249
# 716 if (read_len != MAXALIGN(header.compressed_size))
42494250
# -> 717 elog(ERROR, "cannot read block %u of \"%s\" read %lu of %d",
4250-
# 718 blknum, file->path, read_len, header.compressed_size);
4251+
# 718 blknum, file->path, read_len, header.compressed_size);

0 commit comments

Comments
 (0)