-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (90 loc) · 3.42 KB
/
windows.yml
File metadata and controls
105 lines (90 loc) · 3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: windows
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
jobs:
test:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Install Chocolatey
shell: powershell
run: |
Set-ExecutionPolicy Bypass -Scope Process -Force; `
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; `
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
- name: Install PostgreSQL
shell: powershell
run: |
choco install -y postgresql16 --params "'/Password:my_password'"
- name: Add PostgreSQL bin to PATH
shell: powershell
run: |
$env:PATH += ';C:\Program Files\PostgreSQL\16\bin'
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine)
- name: Start PostgreSQL service
shell: powershell
run: |
$serviceName = 'postgresql-x64-16'
$service = Get-Service -Name $serviceName -ErrorAction SilentlyContinue
if ($service -and $service.Status -ne 'Running') {
net start $serviceName
} else {
Write-Host "Service $serviceName is already running."
}
- name: Setup PostgreSQL user and database
shell: powershell
run: |
$env:PGPASSWORD = 'my_password'
$psql = 'C:\Program Files\PostgreSQL\16\bin\psql.exe'
& $psql -U postgres -c "CREATE USER my_user WITH PASSWORD 'my_password';"
& $psql -U postgres -c "CREATE DATABASE my_db OWNER my_user;"
- name: Wait for PostgreSQL to be ready
shell: powershell
run: |
$env:PGPASSWORD = 'my_password'
$psql = 'C:\Program Files\PostgreSQL\16\bin\psql.exe'
while ($true) {
try {
& $psql -U my_user -d my_db -c "SELECT 1;" | Out-Null
break
} catch {
Write-Host "Waiting for PostgreSQL..."
Start-Sleep -Seconds 2
}
}
- name: Create table in the database
shell: powershell
run: |
$env:PGPASSWORD = 'my_password'
$psql = 'C:\Program Files\PostgreSQL\16\bin\psql.exe'
& $psql -U my_user -d my_db -c "CREATE TABLE my_table (id SERIAL PRIMARY KEY, description TEXT);"
- name: Install prerequisites
shell: powershell
run: |
choco install -y git cmake visualstudio2022buildtools --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --includeOptional"
- name: Install vcpkg
shell: powershell
run: |
git clone https://github.com/microsoft/vcpkg.git C:\vcpkg
cd C:\vcpkg
.\bootstrap-vcpkg.bat
- name: Clone project repository
run: |
git clone https://github.com/leventkaragol/libcpp-pg-pool.git C:\libcpp-pg-pool
- name: Build the project
shell: powershell
run: |
cd C:\libcpp-pg-pool
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build build --config Release
- name: Run tests
shell: powershell
run: |
cd C:\libcpp-pg-pool\build\test\Release
.\test.exe