-
Notifications
You must be signed in to change notification settings - Fork 21
356 lines (350 loc) · 13 KB
/
pgcmp.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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
name: Database Migrations Check PR
on:
pull_request:
paths:
- "deployment/hasura/migrations/**"
- "deployment/postgres-init-db/sql/**"
- ".github/workflows/pgcmp.yml"
- ".github/workflows/scripts/compareDatabases*"
push:
paths:
- "deployment/hasura/migrations/**"
- "deployment/postgres-init-db/sql/**"
- ".github/workflows/pgcmp.yml"
- ".github/workflows/scripts/compareDatabases*"
branches:
- develop
- dev-[0-9]+.[0-9]+.[0-9]+
tags:
- v*
workflow_dispatch:
env:
AERIE_USERNAME: "${{secrets.AERIE_USERNAME}}"
AERIE_PASSWORD: "${{secrets.AERIE_PASSWORD}}"
HASURA_GRAPHQL_ADMIN_SECRET: "${{secrets.HASURA_GRAPHQL_ADMIN_SECRET}}"
HASURA_GRAPHQL_JWT_SECRET: "${{secrets.HASURA_GRAPHQL_JWT_SECRET}}"
POSTGRES_USER: "${{secrets.POSTGRES_USER}}"
POSTGRES_PASSWORD: "${{secrets.POSTGRES_PASSWORD}}"
GATEWAY_USERNAME: "${{secrets.GATEWAY_USERNAME}}"
GATEWAY_PASSWORD: "${{secrets.GATEWAY_PASSWORD}}"
MERLIN_USERNAME: "${{secrets.MERLIN_USERNAME}}"
MERLIN_PASSWORD: "${{secrets.MERLIN_PASSWORD}}"
SCHEDULER_USERNAME: "${{secrets.SCHEDULER_USERNAME}}"
SCHEDULER_PASSWORD: "${{secrets.SCHEDULER_PASSWORD}}"
SEQUENCING_USERNAME: "${{secrets.SEQUENCING_USERNAME}}"
SEQUENCING_PASSWORD: "${{secrets.SEQUENCING_PASSWORD}}"
jobs:
dump-db-base:
runs-on: ubuntu-latest
environment: e2e-test
steps:
- name: Checkout v2.8.0
uses: actions/checkout@v4
with:
ref: "v2.8.0"
- name: Clone PGCMP
uses: actions/checkout@v4
with:
repository: NASA-AMMOS/pgcmp
path: pgcmp
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Setup Postgres Client (psql)
# ubuntu-latest does not currently have psql-16 in its apt library, so we cannot just run
# sudo apt update && sudo apt-get install --yes postgresql-client-16
# Current instructions are from https://www.postgresql.org/download/linux/ubuntu/
run: |
sudo apt update
sudo apt install curl ca-certificates
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
sudo sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
sudo apt update
sudo apt -y install postgresql-client-16
- name: Setup Hasura CLI
run: sudo curl -L https://github.com/hasura/graphql-engine/raw/stable/cli/get.sh | bash
- name: Start Postgres
run: |
sed -i 's/postgres:14.8/postgres:16.4/' docker-compose.yml
docker compose up -d postgres hasura
docker images
docker ps -a
- name: Sleep for 1 Minute
run: sleep 60s
shell: bash
- name: Dump v2.8.0 Database
run: |
mkdir pgdumpV2_8_0
PGURI=postgres://"${AERIE_USERNAME}":"${AERIE_PASSWORD}"@localhost:5432/aerie \
PGCMPOUTPUT=./pgdumpV2_8_0/AerieV2_8_0 \
PGCLABEL=AerieV2_8_0 \
PGBINDIR=/usr/bin \
./pgcmp/pgcmp-dump
shell: bash
- name: Share Database Dump
uses: actions/upload-artifact@v4
with:
name: v2_8_0-db-dump
path: pgdumpV2_8_0
retention-days: 1
- name: Checkout Latest
uses: actions/checkout@v4
- name: Restart Hasura
run: |
docker compose down
docker compose up -d postgres hasura
docker images
docker ps -a
- name: Sleep for 30 seconds
run: sleep 30s
shell: bash
- name: Migrate Base to Latest
run: |
cd deployment
cat << EOF > .env
AERIE_USERNAME=${AERIE_USERNAME}
AERIE_PASSWORD=${AERIE_PASSWORD}
EOF
python -m pip install -r requirements.txt
python aerie_db_migration.py --apply --all
cd ..
- name: Clone PGCMP
uses: actions/checkout@v4
with:
repository: NASA-AMMOS/pgcmp
path: pgcmp
- name: Dump Migrated Database
run: |
mkdir pgdumpmigrated
PGURI=postgres://"${AERIE_USERNAME}":"${AERIE_PASSWORD}"@localhost:5432/aerie \
PGCMPOUTPUT=./pgdumpmigrated/AerieMigratedUp \
PGCLABEL=AerieMigratedUp \
PGBINDIR=/usr/bin \
./pgcmp/pgcmp-dump
shell: bash
- name: Share Database Dump
uses: actions/upload-artifact@v4
with:
name: migrated-db-dump
path: pgdumpmigrated
retention-days: 1
- name: Print Logs for Services
if: success() || failure()
run: docker compose logs -t
- name: Stop Postgres and Hasura
run: |
docker ps -a
docker compose down
docker ps -a
- name: Prune Volumes
run: docker volume prune --force
dump-current:
runs-on: ubuntu-latest
environment: e2e-test
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Setup Postgres Client (psql)
# ubuntu-latest does not currently have psql-16 in its apt library, so we cannot just run
# sudo apt update && sudo apt-get install --yes postgresql-client-16
# Current instructions are from https://www.postgresql.org/download/linux/ubuntu/
run: |
sudo apt update
sudo apt install curl ca-certificates
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
sudo sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
sudo apt update
sudo apt -y install postgresql-client-16
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Setup Hasura CLI
run: sudo curl -L https://github.com/hasura/graphql-engine/raw/stable/cli/get.sh | bash
- name: Start Postgres and Hasura
run: |
docker compose up -d postgres hasura
docker images
docker ps -a
- name: Sleep for 1 Minute
run: sleep 60s
shell: bash
- name: Clone PGCMP
uses: actions/checkout@v4
with:
repository: NASA-AMMOS/pgcmp
path: pgcmp
- name: Dump Current Database
run: |
mkdir pgdumpcurrent
PGURI=postgres://"${AERIE_USERNAME}":"${AERIE_PASSWORD}"@localhost:5432/aerie \
PGCMPOUTPUT=./pgdumpcurrent/AerieCurrent \
PGCLABEL=AerieCurrent \
PGBINDIR=/usr/bin \
./pgcmp/pgcmp-dump
shell: bash
- name: Share Database Dump
uses: actions/upload-artifact@v4
with:
name: current-sql-db-dump
path: pgdumpcurrent
retention-days: 1
- name: Migrate Latest to Base
run: |
cd deployment
cat << EOF > .env
AERIE_USERNAME=${AERIE_USERNAME}
AERIE_PASSWORD=${AERIE_PASSWORD}
EOF
python -m pip install -r requirements.txt
python aerie_db_migration.py --revert --all
cd ..
- name: Dump Migrated Database
run: |
mkdir pgdumpmigrateddown
PGURI=postgres://"${AERIE_USERNAME}":"${AERIE_PASSWORD}"@localhost:5432/aerie \
PGCMPOUTPUT=./pgdumpmigrateddown/AerieMigratedDown \
PGCLABEL=AerieMigratedDown \
PGBINDIR=/usr/bin \
./pgcmp/pgcmp-dump
shell: bash
- name: Share Database Dump
uses: actions/upload-artifact@v4
with:
name: migrated-down-db-dump
path: pgdumpmigrateddown
retention-days: 1
- name: Print Logs for Services
run: docker compose logs -t
- name: Stop Postgres and Hasura
run: |
docker ps -a
docker compose down
docker ps -a
- name: Prune Volumes
run: docker volume prune --force
pgcmp-up:
needs: [dump-db-base, dump-current]
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Clone PGCMP
uses: actions/checkout@v4
with:
repository: NASA-AMMOS/pgcmp
path: pgcmp
- name: Setup Postgres Client (psql)
# ubuntu-latest does not currently have psql-16 in its apt library, so we cannot just run
# sudo apt update && sudo apt-get install --yes postgresql-client-16
# Current instructions are from https://www.postgresql.org/download/linux/ubuntu/
run: |
sudo apt update
sudo apt install curl ca-certificates
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
sudo sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
sudo apt update
sudo apt -y install postgresql-client-16
- name: Start Postgres
run: docker run -d -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust --name=postgres postgres:16.4
- name: Sleep for 5 Seconds
run: sleep 5s
shell: bash
- name: Download Shared Dumps
uses: actions/download-artifact@v4
with:
name: migrated-db-dump
path: pgcmp/pgdumpmigrated
- uses: actions/download-artifact@v4
with:
name: current-sql-db-dump
path: pgcmp/pgdumpcurrent
- name: Compare Databases
id: dbcmp
run: |
cp ./.github/scripts/explanations pgcmp
cp ./.github/scripts/compareDatabasesUp.sh pgcmp/compareDatabases.sh
cd pgcmp
./compareDatabases.sh
shell: bash
- name: Upload Invalid
if: ${{ failure() && steps.dbcmp.conclusion == 'failure' }}
uses: actions/upload-artifact@v4
with:
name: pgcmpresultsup
path: "**/results/"
- name: Print Logs for Services
if: always()
run: docker logs -t postgres
- name: Stop Postgres
run: |
docker ps -a
docker stop postgres
docker ps -a
- name: Prune Volumes
run: docker volume prune --force
pgcmp-down:
needs: [dump-db-base, dump-current]
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Clone PGCMP
uses: actions/checkout@v4
with:
repository: NASA-AMMOS/pgcmp
path: pgcmp
- name: Setup Postgres Client (psql)
# ubuntu-latest does not currently have psql-16 in its apt library, so we cannot just run
# sudo apt update && sudo apt-get install --yes postgresql-client-16
# Current instructions are from https://www.postgresql.org/download/linux/ubuntu/
run: |
sudo apt update
sudo apt install curl ca-certificates
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
sudo sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
sudo apt update
sudo apt -y install postgresql-client-16
- name: Start Postgres
run: docker run -d -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust --name=postgres postgres:16.4
- name: Sleep for 5 Seconds
run: sleep 5s
shell: bash
- name: Download Shared Dumps
uses: actions/download-artifact@v4
with:
name: v2_8_0-db-dump
path: pgcmp/pgdumpV2_8_0
- uses: actions/download-artifact@v4
with:
name: migrated-down-db-dump
path: pgcmp/pgdumpmigrateddown
- name: Compare Databases
id: dbcmp
run: |
cp ./.github/scripts/explanations pgcmp
cp ./.github/scripts/compareDatabasesDown.sh pgcmp/compareDatabases.sh
cd pgcmp
./compareDatabases.sh
shell: bash
- name: Upload Invalid
if: ${{ failure() && steps.dbcmp.conclusion == 'failure' }}
uses: actions/upload-artifact@v4
with:
name: pgcmpresultsdown
path: "**/results/"
- name: Print Logs for Services
if: always()
run: docker logs -t postgres
- name: Stop Postgres
run: |
docker ps -a
docker stop postgres
docker ps -a
- name: Prune Volumes
run: docker volume prune --force