-
Notifications
You must be signed in to change notification settings - Fork 61
324 lines (314 loc) · 13.8 KB
/
ci.yml
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build-linux:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
- name: Add PostgreSQL apt repository
run: |
sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
sudo wget --quiet --output-document /etc/apt/trusted.gpg.d/apt.postgresql.org.asc https://www.postgresql.org/media/keys/ACCC4CF8.asc
- name: Update system
run: sudo apt update
- name: Install liburing
run: sudo apt install -y liburing-dev
- name: Install systemd
run: sudo apt install -y libsystemd-dev
- name: Install rst2man
run: sudo apt install -y python3-docutils
- name: Install zstd
run: sudo apt install -y libzstd-dev
- name: Install lz4
run: sudo apt install -y liblz4-dev
- name: Install bzip2
run: sudo apt install -y libbz2-dev
- name: Install graphviz
run: sudo apt install graphviz
- name: Install doxygen
run: sudo apt install doxygen
- name: Install crudini
run: sudo apt install -y crudini
- name: Install clang
run: sudo apt install -y clang
- name: Install PostgreSQL
run: sudo apt install -y postgresql postgresql-contrib
- name: Start postgres & setup test table
run: |
version=$(pg_config --version | grep -Eo "[0-9]{1,2}" | head -1)
sudo cp pg_hba.conf /etc/postgresql/${version}/main
sudo -u postgres /usr/lib/postgresql/${version}/bin/pg_ctl start -D /etc/postgresql/${version}/main/ -o "-p 5432"
netstat -tuln | grep '127.0.0.1:5432' || (echo "Nothing is listening on 127.0.0.1:5432"; exit 1)
netstat -tuln | grep '::1:5432' || (echo "Nothing is listening on ::1:5432"; exit 1)
PGPASSWORD="postgres" pgbench -i -s 1 -h localhost -p 5432 -U postgres -d postgres
working-directory: /home/runner/work/pgagroal/pgagroal/.github/config/
- name: Define functions `verify_running` and `verify_shutdown`
run: |
echo 'verify_running() {
echo "Confirming pgagroal is listening on port 2345"
netstat -tuln | grep "127.0.0.1:2345" || (echo "Nothing is listening on 127.0.0.1:2345"; exit 1)
netstat -tuln | grep "::1:2345" || (echo "Nothing is listening on ::1:2345"; exit 1)
echo "[*] Running pgagroal-cli ping"
./pgagroal-cli ping
echo "[*] Running queries with psql"
PGPASSWORD="postgres" psql -h 127.0.0.1 -p 2345 -U postgres -d postgres -c "SELECT * FROM pgbench_accounts LIMIT 50;" > /dev/null
PGPASSWORD="postgres" psql -h ::1 -p 2345 -U postgres -d postgres -c "SELECT * FROM pgbench_accounts LIMIT 50;" > /dev/null
}
verify_shutdown() {
echo "[*] Getting pgid"
pgid=$(ps -o pgid= -p $(cat /tmp/pgagroal.2345.pid) | grep -o '[0-9]*')
echo "[*] Running pgagroal-cli shutdown immediate"
./pgagroal-cli shutdown immediate
sleep 5
echo "[*] Confirming there are no dangling pgagroal processes"
if pgrep -g $pgid > /tmp/dangling; then
echo "[E] Dangling pgagroal child processes:
$(cat /tmp/dangling)"
exit 1
else
echo "rm -f /tmp/pgagroal.2345.pid"
rm -f /tmp/pgagroal.2345.pid
fi
}' > /tmp/functions.sh
- name: GCC/mkdir
run: mkdir build
working-directory: /home/runner/work/pgagroal/pgagroal/
- name: GCC/cmake
run: sudo apt install cmake && export CC=/usr/bin/gcc && cmake -DCMAKE_BUILD_TYPE=Debug ..
working-directory: /home/runner/work/pgagroal/pgagroal/build/
- name: GCC/make
run: make
working-directory: /home/runner/work/pgagroal/pgagroal/build/
- name: GCC/Run pgagroal as daemon with 'io_uring' backend
run: |
sudo mkdir -p /etc/pgagroal
crudini --set ../../doc/etc/pgagroal.conf pgagroal log_type file
crudini --set ../../doc/etc/pgagroal.conf pgagroal log_path /dev/null
crudini --set ../../doc/etc/pgagroal.conf pgagroal ev_backend io_uring
echo "host all all all trust" > ../../doc/etc/pgagroal_hba.conf
sudo cp ../../doc/etc/*.conf /etc/pgagroal
sudo sysctl kernel.io_uring_disabled=0
./pgagroal -d || exit
sleep 5
working-directory: /home/runner/work/pgagroal/pgagroal/build/src/
- name: GCC/Run verify_running for 'io_uring' backend
run: |
source /tmp/functions.sh
verify_running
working-directory: /home/runner/work/pgagroal/pgagroal/build/src/
- name: GCC/Run verify_shutdown for 'io_uring' backend
run: |
source /tmp/functions.sh
verify_shutdown
working-directory: /home/runner/work/pgagroal/pgagroal/build/src/
- name: GCC/Run pgagroal as daemon with 'epoll' backend
run: |
sudo mkdir -p /etc/pgagroal
crudini --set ../../doc/etc/pgagroal.conf pgagroal log_type file
crudini --set ../../doc/etc/pgagroal.conf pgagroal log_path /dev/null
crudini --set ../../doc/etc/pgagroal.conf pgagroal ev_backend epoll
echo "host all all all trust" > ../../doc/etc/pgagroal_hba.conf
sudo cp ../../doc/etc/*.conf /etc/pgagroal
./pgagroal -d || exit
sleep 5
working-directory: /home/runner/work/pgagroal/pgagroal/build/src/
- name: GCC/Run verify_running for 'epoll' backend
run: |
source /tmp/functions.sh
verify_running
working-directory: /home/runner/work/pgagroal/pgagroal/build/src/
- name: GCC/Run verify_shutdown for 'epoll' backend
run: |
source /tmp/functions.sh
verify_shutdown
working-directory: /home/runner/work/pgagroal/pgagroal/build/src/
- name: rm -Rf
run: rm -Rf build/
working-directory: /home/runner/work/pgagroal/pgagroal/
- name: CLANG/mkdir
run: mkdir build
working-directory: /home/runner/work/pgagroal/pgagroal/
- name: CLANG/cmake
run: export CC=/usr/bin/clang && cmake -DCMAKE_BUILD_TYPE=Debug ..
working-directory: /home/runner/work/pgagroal/pgagroal/build/
- name: CLANG/make
run: make
working-directory: /home/runner/work/pgagroal/pgagroal/build/
- name: CLANG/Run pgagroal as daemon with 'io_uring' backend
run: |
sudo mkdir -p /etc/pgagroal
crudini --set ../../doc/etc/pgagroal.conf pgagroal log_type file
crudini --set ../../doc/etc/pgagroal.conf pgagroal log_path /dev/null
crudini --set ../../doc/etc/pgagroal.conf pgagroal ev_backend io_uring
echo "host all all all trust" > ../../doc/etc/pgagroal_hba.conf
sudo cp ../../doc/etc/*.conf /etc/pgagroal
sudo sysctl kernel.io_uring_disabled=0
./pgagroal -d || exit 1
sleep 5
working-directory: /home/runner/work/pgagroal/pgagroal/build/src/
- name: CLANG/Run verify_running for 'io_uring' backend
run: |
source /tmp/functions.sh
verify_running
working-directory: /home/runner/work/pgagroal/pgagroal/build/src/
- name: CLANG/Run verify_shutdown for 'io_uring' backend
run: |
source /tmp/functions.sh
verify_shutdown
working-directory: /home/runner/work/pgagroal/pgagroal/build/src/
- name: CLANG/Run pgagroal as daemon with 'epoll' backend
run: |
sudo mkdir -p /etc/pgagroal
crudini --set ../../doc/etc/pgagroal.conf pgagroal log_type file
crudini --set ../../doc/etc/pgagroal.conf pgagroal log_path /dev/null
crudini --set ../../doc/etc/pgagroal.conf pgagroal ev_backend epoll
echo "host all all all trust" > ../../doc/etc/pgagroal_hba.conf
sudo cp ../../doc/etc/*.conf /etc/pgagroal
./pgagroal -d || exit
sleep 5
working-directory: /home/runner/work/pgagroal/pgagroal/build/src/
- name: CLANG/Run verify_running for 'epoll' backend
run: |
source /tmp/functions.sh
verify_running
working-directory: /home/runner/work/pgagroal/pgagroal/build/src/
- name: CLANG/Run verify_shutdown for 'epoll' backend
run: |
source /tmp/functions.sh
verify_shutdown
working-directory: /home/runner/work/pgagroal/pgagroal/build/src/
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Update system
run: brew update
- name: Install openssl
run: brew install openssl
- name: Install zstd
run: brew install zstd
- name: Install lz4
run: brew install lz4
- name: Install bzip2
run: brew install bzip2
- name: Install rst2man
run: brew install docutils
- name: Install graphviz
run: brew install graphviz
- name: Install doxygen
run: brew install doxygen
- name: Install clang
run: brew install llvm
- name: Install PostgreSQL
run: |
latest_pg=$(brew search postgresql | grep postgresql@ | tail -n 1)
brew install ${latest_pg} || true # `|| true` prevents install errors from breaking the run
- name: Start PostgreSQL & setup test table
run: |
installed_pg=$(brew search postgresql | grep postgresql@ | tail -n 1)
brew services start ${installed_pg}
sleep 5
/opt/homebrew/opt/${installed_pg}/bin/pgbench -i -s 1 -h localhost -p 5432 -U $(whoami) -d postgres
exit 0
- name: Define functions `verify_running` and `verify_shutdown`
run: |
echo 'verify_running() {
echo "[*] Confirming pgagroal is listening on port 2345"
netstat -an | grep "\.2345 .*LISTEN" || (echo "Nothing is listening on port 2345"; exit 1)
echo "[*] Running pgagroal-cli ping"
./pgagroal-cli ping
echo "[*] Running queries with psql"
installed_pg=$(brew search postgresql | grep postgresql@ | tail -n 1)
PGPASSWORD="postgres" /opt/homebrew/opt/${installed_pg}/bin/psql -h 127.0.0.1 -p 2345 -U $(whoami) -d postgres -c "SELECT * FROM pgbench_accounts LIMIT 50;" > /dev/null
PGPASSWORD="postgres" /opt/homebrew/opt/${installed_pg}/bin/psql -h ::1 -p 2345 -U $(whoami) -d postgres -c "SELECT * FROM pgbench_accounts LIMIT 50;" > /dev/null
}
verify_shutdown() {
echo "[*] Getting pgid"
pgid=$(ps -o pgid= -p $(cat /tmp/pgagroal.2345.pid) | grep -o "[0-9]*")
echo "[*] Running pgagroal-cli shutdown immediate"
./pgagroal-cli shutdown immediate
sleep 5
echo "[*] Confirming there are no dangling pgagroal processes"
if pgrep -g $pgid > /tmp/dangling; then
echo "[E] Dangling pgagroal child processes:
$(cat /tmp/dangling)"
exit 1
else
echo "Removing PID file"
rm -f /tmp/pgagroal.2345.pid
fi
}' > /tmp/functions.sh
- name: GCC/mkdir
run: mkdir build
working-directory: /Users/runner/work/pgagroal/pgagroal/
- name: GCC/cmake
run: export CC=/usr/bin/gcc && export OPENSSL_ROOT_DIR=`brew --prefix openssl` && cmake -DCMAKE_BUILD_TYPE=Debug ..
working-directory: /Users/runner/work/pgagroal/pgagroal/build/
- name: GCC/make
run: make
working-directory: /Users/runner/work/pgagroal/pgagroal/build/
- name: GCC/Run pgagroal as daemon with 'kqueue' backend
run: |
sudo mkdir -p /etc/pgagroal
sed -i '' 's/^log_type =.*$/log_type = file/' ../../doc/etc/pgagroal.conf
sed -i '' 's|^log_path =.*$|log_path = /dev/null|' ../../doc/etc/pgagroal.conf
sed -i '' 's/^ev_backend =.*$/ev_backend = kqueue/' ../../doc/etc/pgagroal.conf
cat ../../doc/etc/pgagroal.conf
echo "host all all all trust" > ../../doc/etc/pgagroal_hba.conf
sudo cp ../../doc/etc/*.conf /etc/pgagroal
./pgagroal -d || exit 1
sleep 5
working-directory: /Users/runner/work/pgagroal/pgagroal/build/src/
- name: DISABLED - GCC/Run verify_running for 'kqueue' backend
run: echo DISABLED
# source /tmp/functions.sh
# verify_running
working-directory: /Users/runner/work/pgagroal/pgagroal/build/src/
- name: GCC/Run verify_shutdown for 'kqueue' backend
run: |
source /tmp/functions.sh
verify_shutdown
working-directory: /Users/runner/work/pgagroal/pgagroal/build/src/
- name: GCC/Clean up build
run: rm -Rf build
working-directory: /Users/runner/work/pgagroal/pgagroal/
- name: CLANG/mkdir
run: mkdir build
working-directory: /Users/runner/work/pgagroal/pgagroal/
- name: CLANG/cmake
run: |
export CC=/usr/bin/clang
export OPENSSL_ROOT_DIR=$(brew --prefix openssl)
cmake -DCMAKE_BUILD_TYPE=Debug ..
working-directory: /Users/runner/work/pgagroal/pgagroal/build/
- name: CLANG/make
run: make
working-directory: /Users/runner/work/pgagroal/pgagroal/build/
- name: CLANG/Run pgagroal as daemon with 'kqueue' backend
run: |
sudo mkdir -p /etc/pgagroal
sed -i '' 's/^log_type =.*$/log_type = file/' ../../doc/etc/pgagroal.conf
sed -i '' 's|^log_path =.*$|log_path = /dev/null|' ../../doc/etc/pgagroal.conf
sed -i '' 's/^ev_backend =.*$/ev_backend = kqueue/' ../../doc/etc/pgagroal.conf
cat ../../doc/etc/pgagroal.conf
echo "host all all all trust" > ../../doc/etc/pgagroal_hba.conf
sudo cp ../../doc/etc/*.conf /etc/pgagroal
./pgagroal -d || exit 1
sleep 5
working-directory: /Users/runner/work/pgagroal/pgagroal/build/src/
- name: DISABLED - CLANG/Run verify_running for 'kqueue' backend
run: echo DISABLED
#source /tmp/functions.sh
#verify_running
working-directory: /Users/runner/work/pgagroal/pgagroal/build/src/
- name: CLANG/Run verify_shutdown for 'kqueue' backend
run: |
source /tmp/functions.sh
verify_shutdown
working-directory: /Users/runner/work/pgagroal/pgagroal/build/src/