Skip to content

Commit f7514e7

Browse files
committed
add workflow for testing psql build
1 parent f4fe248 commit f7514e7

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

.github/workflows/build-db.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Test DB build scripts
2+
on: pull_request
3+
4+
jobs:
5+
build-mimic-iv-psql:
6+
# Containers must run in Linux based operating systems
7+
runs-on: ubuntu-latest
8+
# Docker Hub image that `container-job` executes in
9+
container: node:latest
10+
11+
# Service containers to run with `container-job`
12+
services:
13+
# Label used to access the service container
14+
postgres:
15+
# Docker Hub image
16+
image: postgres
17+
# Provide the password for postgres
18+
env:
19+
POSTGRES_PASSWORD: postgres
20+
# Set health checks to wait until postgres has started
21+
options: >-
22+
--health-cmd pg_isready
23+
--health-interval 10s
24+
--health-timeout 5s
25+
--health-retries 5
26+
27+
steps:
28+
- name: Check out repository code
29+
uses: actions/checkout@v3
30+
31+
- name: Install psql command
32+
run: |
33+
apt-get update
34+
apt-get install --yes --no-install-recommends postgresql-client
35+
36+
- id: 'auth'
37+
uses: 'google-github-actions/auth@v0'
38+
with:
39+
project_id: ${{ secrets.GCP_PROJECT_ID }}
40+
credentials_json: ${{ secrets.GCP_SA_KEY }}
41+
42+
- name: 'Set up Cloud SDK'
43+
uses: 'google-github-actions/setup-gcloud@v0'
44+
45+
- name: Download demo and create tables on PostgreSQL
46+
run: |
47+
echo "Downloading MIMIC-IV demo from GCP."
48+
gsutil -q -u $PROJECT_ID -m cp -r gs://mimic-iv-archive/v2.0/demo ./
49+
echo "Building and loading data into psql."
50+
psql -q -h $POSTGRES_HOST -U postgres -f mimic-iv/buildmimic/postgres/create.sql
51+
psql -q -h $POSTGRES_HOST -U postgres -v mimic_data_dir=demo -f mimic-iv/buildmimic/postgres/load_gz.sql
52+
echo "Validating build."
53+
psql -h $POSTGRES_HOST -U postgres -f mimic-iv/buildmimic/postgres/validate_demo.sql > validate_results.txt
54+
cat validate_results.txt
55+
56+
env:
57+
# The hostname used to communicate with the PostgreSQL service container
58+
POSTGRES_HOST: postgres
59+
PGPASSWORD: postgres
60+
# The default PostgreSQL port
61+
POSTGRES_PORT: 5432
62+
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}

0 commit comments

Comments
 (0)