forked from pgmoneta/pgmoneta
-
Notifications
You must be signed in to change notification settings - Fork 0
239 lines (218 loc) · 8.75 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
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Update system
run: sudo apt update -y
- name: Install libev
run: sudo apt install -y libev4 libev-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 libssh
run: sudo apt install -y libssh-dev
- name: Install libarchive
run: sudo apt install -y libarchive-dev
- name: Install libcurl
run: sudo apt install -y libcurl4-nss-dev
- name: Install clang
run: sudo apt install -y clang
- name: Install graphviz
run: sudo apt install graphviz
- name: Install doxygen
run: sudo apt install doxygen
- name: GCC/mkdir
run: mkdir build
working-directory: /home/runner/work/pgmoneta/pgmoneta/
- name: GCC/cmake
run: export CC=/usr/bin/gcc && cmake -DCMAKE_BUILD_TYPE=Debug ..
working-directory: /home/runner/work/pgmoneta/pgmoneta/build/
- name: GCC/make
run: make
working-directory: /home/runner/work/pgmoneta/pgmoneta/build/
- name: rm -Rf
run: rm -Rf build/
working-directory: /home/runner/work/pgmoneta/pgmoneta/
- name: CLANG/mkdir
run: mkdir build
working-directory: /home/runner/work/pgmoneta/pgmoneta/
- name: CLANG/cmake
run: export CC=/usr/bin/clang && cmake -DCMAKE_BUILD_TYPE=Debug ..
working-directory: /home/runner/work/pgmoneta/pgmoneta/build/
- name: CLANG/make
run: make
working-directory: /home/runner/work/pgmoneta/pgmoneta/build/
- name: Install PostgreSQL
run: sudo apt install -y postgresql
- name: Init database
run: |
version=$(pg_config --version | grep -Eo "[0-9]{1,2}" | head -1)
sudo -u postgres /usr/lib/postgresql/${version}/bin/initdb /tmp/pgsql
- name: Config postgres
run: |
sudo -u postgres sed -i 's/#password_encryption = scram-sha-256/password_encryption = md5/' /tmp/pgsql/postgresql.conf
sudo -u postgres sed -i '/^host/d' /tmp/pgsql/pg_hba.conf
echo 'cat <<EOF >> /tmp/pgsql/pg_hba.conf
host postgres repl 127.0.0.1/32 md5
host postgres repl ::1/128 md5
host replication repl 127.0.0.1/32 md5
host replication repl ::1/128 md5
EOF
'| sudo -u postgres -s
- name: Setup postgres
run: |
version=$(pg_config --version | grep -Eo "[0-9]{1,2}" | head -1)
sudo -u postgres /usr/lib/postgresql/${version}/bin/pg_ctl start -D /tmp/pgsql
sudo -u postgres /usr/lib/postgresql/${version}/bin/psql -U postgres -c "CREATE ROLE repl WITH LOGIN REPLICATION PASSWORD 'secretpassword';"
- name: Config pgmoneta
run: |
/home/runner/work/pgmoneta/pgmoneta/build/src/pgmoneta-admin master-key -P pgmonetamasterkey
/home/runner/work/pgmoneta/pgmoneta/build/src/pgmoneta-admin -f pgmoneta_users.conf -U repl -P secretpassword user add
cat <<EOF > pgmoneta.conf
[pgmoneta]
host = *
metrics = 5001
create_slot = yes
base_dir = /home/runner/work/pgmoneta/pgmoneta/backup
compression = zstd
storage_engine = local
retention = 7
log_type = file
log_level = info
log_path = /tmp/pgmoneta.log
unix_socket_dir = /tmp/
[primary]
wal_slot = repl
host = localhost
port = 5432
user = repl
EOF
mkdir backup
working-directory: /home/runner/work/pgmoneta/pgmoneta/
- name: Execute backup
run: |
/home/runner/work/pgmoneta/pgmoneta/build/src/pgmoneta -c pgmoneta.conf -u pgmoneta_users.conf -d
sleep 5
/home/runner/work/pgmoneta/pgmoneta/build/src/pgmoneta-cli -c pgmoneta.conf backup primary
/home/runner/work/pgmoneta/pgmoneta/build/src/pgmoneta-cli -c pgmoneta.conf status details
working-directory: /home/runner/work/pgmoneta/pgmoneta/
- name: Restore backup
run: /home/runner/work/pgmoneta/pgmoneta/build/src/pgmoneta-cli -c pgmoneta.conf restore primary newest current /tmp/
working-directory: /home/runner/work/pgmoneta/pgmoneta/
- name: Cleanup
run: |
version=$(pg_config --version | grep -Eo "[0-9]{1,2}" | head -1)
/home/runner/work/pgmoneta/pgmoneta/build/src/pgmoneta-cli -c pgmoneta.conf stop
sudo -u postgres /usr/lib/postgresql/${version}/bin/pg_ctl stop -D /tmp/pgsql
working-directory: /home/runner/work/pgmoneta/pgmoneta/
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Install Homebrew
run: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
- name: Update system
run: brew update
- name: Install libev
run: brew install libev
- name: Install rst2man
run: brew install docutils
- name: Install libarchive
run: brew install --ignore-dependencies libarchive
- name: Install clang
run: brew install llvm
- name: Install PostgreSQL
run: brew install postgresql
- name: Install libssh
run: brew install libssh
- name: GCC/mkdir
run: mkdir build
working-directory: /Users/runner/work/pgmoneta/pgmoneta/
- name: GCC/cmake
run: export CC=/usr/bin/gcc && cmake -DCMAKE_BUILD_TYPE=Debug ..
working-directory: /Users/runner/work/pgmoneta/pgmoneta/build/
- name: GCC/make
run: make
working-directory: /Users/runner/work/pgmoneta/pgmoneta/build/
- name: rm -Rf
run: rm -Rf build/
working-directory: /Users/runner/work/pgmoneta/pgmoneta/
- name: CLANG/mkdir
run: mkdir build
working-directory: /Users/runner/work/pgmoneta/pgmoneta/
- name: CLANG/cmake
run: export CC=/usr/bin/clang && cmake -DCMAKE_BUILD_TYPE=Debug ..
working-directory: /Users/runner/work/pgmoneta/pgmoneta/build/
- name: CLANG/make
run: make
working-directory: /Users/runner/work/pgmoneta/pgmoneta/build/
- name: Init database
run: initdb /tmp/pgsql
- name: Config postgres
run: |
sed -i '' 's/#password_encryption = scram-sha-256/password_encryption = md5/' /tmp/pgsql/postgresql.conf
sed -i '' '/^host/d' /tmp/pgsql/pg_hba.conf
cat <<EOF >> /tmp/pgsql/pg_hba.conf
host postgres repl 127.0.0.1/32 md5
host postgres repl ::1/128 md5
host replication repl 127.0.0.1/32 md5
host replication repl ::1/128 md5
EOF
- name: Setup postgres
run: |
pg_ctl -D /tmp/pgsql start
createuser -s postgres
psql -U postgres -c "CREATE ROLE repl WITH LOGIN REPLICATION PASSWORD 'secretpassword';"
- name: Config pgmoneta
run: |
/Users/runner/work/pgmoneta/pgmoneta/build/src/pgmoneta-admin master-key -P pgmonetamasterkey
/Users/runner/work/pgmoneta/pgmoneta/build/src/pgmoneta-admin -f pgmoneta_users.conf -U repl -P secretpassword user add
cat <<EOF > pgmoneta.conf
[pgmoneta]
host = *
metrics = 5001
create_slot = yes
base_dir = /Users/runner/work/pgmoneta/pgmoneta/backup
compression = zstd
storage_engine = local
retention = 7
log_type = file
log_level = info
log_path = /tmp/pgmoneta.log
unix_socket_dir = /tmp/
[primary]
wal_slot = repl
host = localhost
port = 5432
user = repl
EOF
mkdir backup
working-directory: /Users/runner/work/pgmoneta/pgmoneta/
- name: Execute backup
run: |
/Users/runner/work/pgmoneta/pgmoneta/build/src/pgmoneta -c pgmoneta.conf -u pgmoneta_users.conf -d
sleep 5
/Users/runner/work/pgmoneta/pgmoneta/build/src/pgmoneta-cli -c pgmoneta.conf backup primary
/Users/runner/work/pgmoneta/pgmoneta/build/src/pgmoneta-cli -c pgmoneta.conf status details
working-directory: /Users/runner/work/pgmoneta/pgmoneta/
- name: Restore backup
run: /Users/runner/work/pgmoneta/pgmoneta/build/src/pgmoneta-cli -c pgmoneta.conf restore primary newest current /tmp/
working-directory: /Users/runner/work/pgmoneta/pgmoneta/
- name: Cleanup
run: |
/Users/runner/work/pgmoneta/pgmoneta/build/src/pgmoneta-cli -c pgmoneta.conf stop
pg_ctl stop -D /tmp/pgsql