-
Notifications
You must be signed in to change notification settings - Fork 1
66 lines (58 loc) · 2.07 KB
/
check-migrate-from-prod-db.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
name: Check Migrate from prod DB
on:
pull_request:
branches:
- main
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
check-migrate-from-prod-db:
environment: Testing
runs-on: ubuntu-latest
services:
test_db:
image: postgres:16-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: localcrag_test
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Set up postgres 16
uses: ankane/setup-postgres@v1
with:
postgres-version: 16
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v1
with:
python-version: 3.11
- name: Install pipenv
run: pip install pipenv
- name: Installing pipenv dependencies
run: |
cd server/src
pipenv install
- name: Pull newest prod dump from backup server
run: |
echo "${{ secrets.BACKUP_SERVER_SSH_KEY }}" >> backup_key.pem
chmod 600 backup_key.pem
mkdir -p server/tests/dumps
scp -i backup_key.pem -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${{ secrets.BACKUP_SERVER_USER }}@${{ secrets.BACKUP_SERVER_IP }}:${{ secrets.BACKUP_SERVER_DUMPPATH }} server/tests/dumps/localcrag_prod_dump.sql
- name: Setup database with prod dump
run: |
export PGPASSWORD='postgres'; psql -h 0.0.0.0 -p 5432 -U postgres -d localcrag_test < server/scripts/create_uuid_extension.sql
export PGPASSWORD='postgres'; pg_restore --no-privileges --no-owner -h 0.0.0.0 -p 5432 -U postgres -d localcrag_test server/tests/dumps/localcrag_prod_dump.sql
- name: Run Migrations
run: |
cd server/src
export PYTHONPATH=.
export LOCALCRAG_CONFIG=config/test-ci.cfg
pipenv run flask db upgrade