-
Notifications
You must be signed in to change notification settings - Fork 19
355 lines (350 loc) · 14 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
name: Database Migrations Check PR
on:
pull_request:
paths:
- "deployment/hasura/migrations/**"
- "merlin-server/sql/**"
- "sequencing-server/sql/**"
- "scheduler-server/sql/**"
- "deployment/postgres-init-db/sql/**"
push:
paths:
- "deployment/hasura/migrations/**"
- "merlin-server/sql/**"
- "sequencing-server/sql/**"
- "scheduler-server/sql/**"
- "deployment/postgres-init-db/sql/**"
branches:
- develop
tags:
- v*
workflow_dispatch:
jobs:
dump-db-base:
runs-on: ubuntu-latest
environment: e2e-test
steps:
- name: Checkout v1.0.1
uses: actions/checkout@v3
with:
ref: "v1.0.1"
- name: Clone PGCMP
uses: actions/checkout@v3
with:
repository: cbbrowne/pgcmp
path: pgcmp
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Setup Postgres Client (psql)
run: |
sudo apt-get update
sudo apt-get install --yes postgresql-client
- name: Setup Hasura CLI
run: sudo curl -L https://github.com/hasura/graphql-engine/raw/stable/cli/get.sh | bash
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Distribute SQL and Assemble Java
uses: gradle/gradle-build-action@v2
with:
arguments: distributeSQL
- name: Start Postgres
run: |
docker compose up -d postgres hasura
docker images
docker ps -a
env:
AERIE_USERNAME: "${{secrets.AERIE_USERNAME}}"
AERIE_PASSWORD: "${{secrets.AERIE_PASSWORD}}"
POSTGRES_USER: "${{secrets.POSTGRES_USER}}"
POSTGRES_PASSWORD: "${{secrets.POSTGRES_PASSWORD}}"
HASURA_GRAPHQL_ADMIN_SECRET: "${{secrets.HASURA_GRAPHQL_ADMIN_SECRET}}"
HASURA_GRAPHQL_JWT_SECRET: "${{secrets.HASURA_GRAPHQL_JWT_SECRET}}"
- name: Sleep for 1 Minute
run: sleep 60s
shell: bash
- name: Dump v1.0.1 Database
env:
AERIE_USERNAME: "${{secrets.AERIE_USERNAME}}"
AERIE_PASSWORD: "${{secrets.AERIE_PASSWORD}}"
run: |
mkdir pgdumpv1_0_1
PGURI=postgres://"${AERIE_USERNAME}":"${AERIE_PASSWORD}"@localhost:5432/aerie_merlin PGCMPOUTPUT=./pgdumpv1_0_1/AerieMerlinV1_0_1 PGCLABEL=AerieMerlinV1_0_1 PGBINDIR=/usr/bin ./pgcmp/pgcmp-dump
PGURI=postgres://"${AERIE_USERNAME}":"${AERIE_PASSWORD}"@localhost:5432/aerie_scheduler PGCMPOUTPUT=./pgdumpv1_0_1/AerieSchedulerV1_0_1 PGCLABEL=AerieSchedulerV1_0_1 PGBINDIR=/usr/bin ./pgcmp/pgcmp-dump
PGURI=postgres://"${AERIE_USERNAME}":"${AERIE_PASSWORD}"@localhost:5432/aerie_sequencing PGCMPOUTPUT=./pgdumpv1_0_1/AerieSequencingV1_0_1 PGCLABEL=AerieSequencingV1_0_1 PGBINDIR=/usr/bin ./pgcmp/pgcmp-dump
PGURI=postgres://"${AERIE_USERNAME}":"${AERIE_PASSWORD}"@localhost:5432/aerie_ui PGCMPOUTPUT=./pgdumpv1_0_1/AerieUIV1_0_1 PGCLABEL=AerieUIV1_0_1 PGBINDIR=/usr/bin ./pgcmp/pgcmp-dump
shell: bash
- name: Share Database Dump
uses: actions/upload-artifact@v3
with:
name: v1_0_1-db-dump
path: pgdumpv1_0_1
retention-days: 1
- name: Checkout Latest
uses: actions/checkout@v3
- name: Restart Hasura
run: |
docker compose down
docker compose up -d postgres hasura
docker images
docker ps -a
env:
AERIE_USERNAME: "${{secrets.AERIE_USERNAME}}"
AERIE_PASSWORD: "${{secrets.AERIE_PASSWORD}}"
POSTGRES_USER: "${{secrets.POSTGRES_USER}}"
POSTGRES_PASSWORD: "${{secrets.POSTGRES_PASSWORD}}"
HASURA_GRAPHQL_ADMIN_SECRET: "${{secrets.HASURA_GRAPHQL_ADMIN_SECRET}}"
HASURA_GRAPHQL_JWT_SECRET: "${{secrets.HASURA_GRAPHQL_JWT_SECRET}}"
- 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 ..
env:
AERIE_USERNAME: "${{secrets.AERIE_USERNAME}}"
AERIE_PASSWORD: "${{secrets.AERIE_PASSWORD}}"
- name: Clone PGCMP
uses: actions/checkout@v3
with:
repository: cbbrowne/pgcmp
path: pgcmp
- name: Dump Databases
env:
AERIE_USERNAME: "${{secrets.AERIE_USERNAME}}"
AERIE_PASSWORD: "${{secrets.AERIE_PASSWORD}}"
run: |
mkdir pgdumpmigrated
PGURI=postgres://"${AERIE_USERNAME}":"${AERIE_PASSWORD}"@localhost:5432/aerie_merlin PGCMPOUTPUT=./pgdumpmigrated/AerieMerlinMigrated PGCLABEL=AerieMerlinMigrated PGBINDIR=/usr/bin ./pgcmp/pgcmp-dump
PGURI=postgres://"${AERIE_USERNAME}":"${AERIE_PASSWORD}"@localhost:5432/aerie_scheduler PGCMPOUTPUT=./pgdumpmigrated/AerieSchedulerMigrated PGCLABEL=AerieSchedulerMigrated PGBINDIR=/usr/bin ./pgcmp/pgcmp-dump
PGURI=postgres://"${AERIE_USERNAME}":"${AERIE_PASSWORD}"@localhost:5432/aerie_sequencing PGCMPOUTPUT=./pgdumpmigrated/AerieSequencingMigrated PGCLABEL=AerieSequencingMigrated PGBINDIR=/usr/bin ./pgcmp/pgcmp-dump
PGURI=postgres://"${AERIE_USERNAME}":"${AERIE_PASSWORD}"@localhost:5432/aerie_ui PGCMPOUTPUT=./pgdumpmigrated/AerieUIMigrated PGCLABEL=AerieUIMigrated PGBINDIR=/usr/bin ./pgcmp/pgcmp-dump
shell: bash
- name: Share Database Dump
uses: actions/upload-artifact@v3
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@v3
- name: Setup Postgres Client (psql)
run: |
sudo apt-get update
sudo apt-get install --yes postgresql-client
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Distribute SQL
uses: gradle/gradle-build-action@v2
with:
arguments: distributeSQL
- name: Setup Python
uses: actions/setup-python@v4
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
env:
AERIE_USERNAME: "${{secrets.AERIE_USERNAME}}"
AERIE_PASSWORD: "${{secrets.AERIE_PASSWORD}}"
POSTGRES_USER: "${{secrets.POSTGRES_USER}}"
POSTGRES_PASSWORD: "${{secrets.POSTGRES_PASSWORD}}"
HASURA_GRAPHQL_ADMIN_SECRET: "${{secrets.HASURA_GRAPHQL_ADMIN_SECRET}}"
HASURA_GRAPHQL_JWT_SECRET: "${{secrets.HASURA_GRAPHQL_JWT_SECRET}}"
- name: Sleep for 1 Minute
run: sleep 60s
shell: bash
- name: Clone PGCMP
uses: actions/checkout@v3
with:
repository: cbbrowne/pgcmp
path: pgcmp
- name: Dump Databases
env:
AERIE_USERNAME: "${{secrets.AERIE_USERNAME}}"
AERIE_PASSWORD: "${{secrets.AERIE_PASSWORD}}"
run: |
mkdir pgdumpraw
PGURI=postgres://"${AERIE_USERNAME}":"${AERIE_PASSWORD}"@localhost:5432/aerie_merlin PGCMPOUTPUT=./pgdumpraw/AerieMerlinRaw PGCLABEL=AerieMerlinRaw PGBINDIR=/usr/bin ./pgcmp/pgcmp-dump
PGURI=postgres://"${AERIE_USERNAME}":"${AERIE_PASSWORD}"@localhost:5432/aerie_scheduler PGCMPOUTPUT=./pgdumpraw/AerieSchedulerRaw PGCLABEL=AerieSchedulerRaw PGBINDIR=/usr/bin ./pgcmp/pgcmp-dump
PGURI=postgres://"${AERIE_USERNAME}":"${AERIE_PASSWORD}"@localhost:5432/aerie_sequencing PGCMPOUTPUT=./pgdumpraw/AerieSequencingRaw PGCLABEL=AerieSequencingRaw PGBINDIR=/usr/bin ./pgcmp/pgcmp-dump
PGURI=postgres://"${AERIE_USERNAME}":"${AERIE_PASSWORD}"@localhost:5432/aerie_ui PGCMPOUTPUT=./pgdumpraw/AerieUIRaw PGCLABEL=AerieUIRaw PGBINDIR=/usr/bin ./pgcmp/pgcmp-dump
shell: bash
- name: Share Database Dump
uses: actions/upload-artifact@v3
with:
name: raw-sql-db-dump
path: pgdumpraw
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 ..
env:
AERIE_USERNAME: "${{secrets.AERIE_USERNAME}}"
AERIE_PASSWORD: "${{secrets.AERIE_PASSWORD}}"
- name: Dump Databases
env:
AERIE_USERNAME: "${{secrets.AERIE_USERNAME}}"
AERIE_PASSWORD: "${{secrets.AERIE_PASSWORD}}"
run: |
mkdir pgdumpmigrateddown
PGURI=postgres://"${AERIE_USERNAME}":"${AERIE_PASSWORD}"@localhost:5432/aerie_merlin PGCMPOUTPUT=./pgdumpmigrateddown/AerieMerlinMigratedDown PGCLABEL=AerieMerlinMigratedDown PGBINDIR=/usr/bin ./pgcmp/pgcmp-dump
PGURI=postgres://"${AERIE_USERNAME}":"${AERIE_PASSWORD}"@localhost:5432/aerie_scheduler PGCMPOUTPUT=./pgdumpmigrateddown/AerieSchedulerMigratedDown PGCLABEL=AerieSchedulerMigratedDown PGBINDIR=/usr/bin ./pgcmp/pgcmp-dump
PGURI=postgres://"${AERIE_USERNAME}":"${AERIE_PASSWORD}"@localhost:5432/aerie_sequencing PGCMPOUTPUT=./pgdumpmigrateddown/AerieSequencingMigratedDown PGCLABEL=AerieSequencingMigratedDown PGBINDIR=/usr/bin ./pgcmp/pgcmp-dump
PGURI=postgres://"${AERIE_USERNAME}":"${AERIE_PASSWORD}"@localhost:5432/aerie_ui PGCMPOUTPUT=./pgdumpmigrateddown/AerieUIMigratedDown PGCLABEL=AerieUIMigratedDown PGBINDIR=/usr/bin ./pgcmp/pgcmp-dump
shell: bash
- name: Share Database Dump
uses: actions/upload-artifact@v3
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@v3
- name: Clone PGCMP
uses: actions/checkout@v3
with:
repository: cbbrowne/pgcmp
path: pgcmp
- name: Setup Postgres Client (psql)
run: |
sudo apt-get update
sudo apt-get install --yes postgresql-client
- name: Start Postgres
run: docker run -d -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust --name=postgres postgres:14.1
- name: Sleep for 5 Seconds
run: sleep 5s
shell: bash
- name: Download Shared Dumps
uses: actions/download-artifact@v3
with:
name: migrated-db-dump
path: pgcmp/pgdumpmigrated
- uses: actions/download-artifact@v3
with:
name: raw-sql-db-dump
path: pgcmp/pgdumpraw
- name: Compare Databases
id: dbcmp
run: |
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@v3
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@v3
- name: Clone PGCMP
uses: actions/checkout@v3
with:
repository: cbbrowne/pgcmp
path: pgcmp
- name: Setup Postgres Client (psql)
run: |
sudo apt-get update
sudo apt-get install --yes postgresql-client
- name: Start Postgres
run: docker run -d -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust --name=postgres postgres:14.1
- name: Sleep for 5 Seconds
run: sleep 5s
shell: bash
- name: Download Shared Dumps
uses: actions/download-artifact@v3
with:
name: v1_0_1-db-dump
path: pgcmp/pgdumpv1_0_1
- uses: actions/download-artifact@v3
with:
name: migrated-down-db-dump
path: pgcmp/pgdumpmigrateddown
- name: Compare Databases
id: dbcmp
run: |
cp ./.github/scripts/compareDatabasesDown.sh pgcmp/compareDatabases.sh
cp ./.github/scripts/explanations pgcmp/explanations
cat ./.github/scripts/explanations ./.github/scripts/explanations_merlin_down > pgcmp/explanations_merlin
cd pgcmp
./compareDatabases.sh
shell: bash
- name: Upload Invalid
if: ${{ failure() && steps.dbcmp.conclusion == 'failure' }}
uses: actions/upload-artifact@v3
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