-
-
Notifications
You must be signed in to change notification settings - Fork 17
172 lines (153 loc) · 7.17 KB
/
Copy pathbuild.yml
File metadata and controls
172 lines (153 loc) · 7.17 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- windows-latest
- macos-latest
config:
- qt_version: "6.5.3"
include:
# Two Linux builds: one against libmysqlclient (MySQL 8+) and one
# against libmariadb (MariaDB Connector/C) to catch type-mismatch
# errors like the my_bool*/bool* incompatibility.
- os: ubuntu-latest
config:
qt_version: "6.5.3"
mysql_lib: libmysqlclient-dev
- os: ubuntu-latest
config:
qt_version: "6.11.0"
mysql_lib: libmariadb-dev
steps:
- name: Install dependencies on Ubuntu
if: runner.os == 'Linux'
run: |
sudo apt update -qq
sudo apt install -y doxygen graphviz postgresql-server-dev-16 unixodbc-dev libsqlite3-dev
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 100
# Install the requested MySQL/MariaDB client development library.
# libmariadb-dev conflicts with libmysqlclient-dev (both provide
# mysql/mysql.h), so remove the MySQL packages first when building
# against MariaDB.
if [ "${{ matrix.mysql_lib }}" = "libmariadb-dev" ]; then
sudo apt remove -y libmysqlclient-dev libmysqlclient21 || true
fi
sudo apt install -y ${{ matrix.mysql_lib }}
# ── PostgreSQL ────────────────────────────────────────────────────
sudo systemctl start postgresql.service
# Create a superuser role matching the runner OS user so that
# postgresql:/// (peer-auth, db == username) works without a password.
sudo -u postgres createuser --superuser "$USER"
createdb # creates database named after $USER
echo "ASQL_PG_TEST_DB=postgresql:///" >> "$GITHUB_ENV"
# ── MySQL / MariaDB ───────────────────────────────────────────────
# GitHub-hosted Ubuntu runners ship MySQL with root/root credentials.
sudo systemctl start mysql.service
mysql -u root -proot -e "CREATE DATABASE IF NOT EXISTS asql_test;"
mysql -u root -proot -e \
"CREATE USER IF NOT EXISTS 'asql'@'localhost' IDENTIFIED BY 'asql';"
mysql -u root -proot -e \
"GRANT ALL PRIVILEGES ON asql_test.* TO 'asql'@'localhost'; FLUSH PRIVILEGES;"
echo "ASQL_MYSQL_TEST_DB=mysql://asql:asql@localhost/asql_test" >> "$GITHUB_ENV"
- name: Install dependencies on macOS
if: runner.os == 'macOS'
run: |
# GitHub macOS runners ship aws/tap; Homebrew 6+ warns on untrusted taps.
brew untap aws/tap || true
brew install postgresql@16
brew services start postgresql@16
# Wait until the server accepts connections
until pg_isready --host=localhost --port=5432; do sleep 1; done
# Ensure a database exists for the runner user (required for postgresql:///)
createdb || true
- name: Set up PostgreSQL on Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
# PostgreSQL is pre-installed on windows-latest but stopped/disabled.
# Find whichever version's service is present (14, 15, 16, ...).
$pgSvc = Get-Service -Name "postgresql-x64-*" -ErrorAction SilentlyContinue |
Select-Object -First 1
if (-not $pgSvc) {
Write-Error "No postgresql-x64-* service found on this runner."
exit 1
}
Write-Host "Found service: $($pgSvc.Name)"
Set-Service -Name $pgSvc.Name -StartupType Automatic
Start-Service -Name $pgSvc.Name
# Locate pg_isready / createdb via the PGBIN env var set by the image
$pgBin = [System.Environment]::GetEnvironmentVariable('PGBIN')
if (-not $pgBin) {
# Fall back: find bin/ next to the service executable
$pgBin = Split-Path (Get-WmiObject Win32_Service -Filter "Name='$($pgSvc.Name)'").PathName
}
& "$pgBin\pg_isready.exe" --host=localhost --port=5432 --timeout=30
$env:PGPASSWORD = 'root'
& "$pgBin\createdb.exe" -U postgres asql_test
$pgDir = Split-Path $pgBin # C:\Program Files\PostgreSQL\14
"ASQL_PG_TEST_DB=postgresql://postgres:root@localhost/asql_test" | `
Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"PGDIR=$pgDir" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Install Qt with options and default aqtversion
uses: jurplel/install-qt-action@v4
with:
aqtversion: null # use whatever the default is
version: ${{ matrix.config.qt_version }}
cache: true
- name: Install ninja-build tool (must be after Qt due PATH changes)
uses: turtlesec-no/get-ninja@main
- name: Make sure MSVC is found when Ninja generator is in use
if: ${{ runner.os == 'Windows' }}
uses: ilammy/msvc-dev-cmd@v1
- name: Checkout sources
uses: actions/checkout@v6
- name: Configure project (Shared Link)
run: >
cmake -S . -B ./build-shared -G Ninja
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_PREFIX_PATH="/opt/homebrew/opt/postgresql@16;${{ env.PGDIR }}"
-DENABLE_MAINTAINER_CFLAGS=${{ matrix.build_type == 'Debug' }}
-DBUILD_SHARED_LIBS=ON
-DASQL_DRIVER_MYSQL=${{ runner.os == 'Linux' }}
-DASQL_DRIVER_ODBC=${{ runner.os == 'Linux' }}
- name: Build project
run: cmake --build ./build-shared
- name: Run tests
id: ctest_shared
run: ctest --test-dir ./build-shared -C Debug --output-on-failure
- name: Read tests log when it fails
uses: andstor/file-reader-action@v1
if: ${{ steps.ctest_shared.conclusion == 'failure' }}
with:
path: "./build-shared/Testing/Temporary/LastTest.log"
# Installing PostgreSQL on Windows takes too much time, so better reuse it here
- name: Configure project (Static Link)
run: >
cmake -S . -B ./build-static -G Ninja
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_PREFIX_PATH="/opt/homebrew/opt/postgresql@16;${{ env.PGDIR }}"
-DBUILD_SHARED_LIBS=OFF
-DASQL_DRIVER_MYSQL=${{ runner.os == 'Linux' }}
-DASQL_DRIVER_ODBC=${{ runner.os == 'Linux' }}
- name: Build project
run: cmake --build ./build-static
- name: Run tests
id: ctest_static
run: ctest --test-dir ./build-static -C Debug --output-on-failure
- name: Read tests log when it fails
uses: andstor/file-reader-action@v1
if: ${{ steps.ctest_static.conclusion == 'failure' }}
with:
path: "./build-static/Testing/Temporary/LastTest.log"