Skip to content

Commit a3159d9

Browse files
authored
Merge pull request #1400 from MIT-LCP/gh_action_dependency
GitHub actions refactor
2 parents 5d0e11d + 57a7504 commit a3159d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+237
-203
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: "Download MIMIC-IV Demo"
2+
description: "Downloads MIMIC-IV demo data from GCP"
3+
inputs:
4+
gcp-project-id:
5+
required: true
6+
description: "The Google Cloud Project ID used for billing usage"
7+
gcp-sa-key:
8+
required: true
9+
description: "The service account key used to authenticate with GCP"
10+
runs:
11+
using: "composite"
12+
steps:
13+
- name: Authenticate with GCP
14+
uses: 'google-github-actions/auth@v0'
15+
with:
16+
project_id: ${{ inputs.gcp-project-id }}
17+
credentials_json: ${{ inputs.gcp-sa-key }}
18+
19+
- name: Set up Cloud SDK
20+
uses: 'google-github-actions/setup-gcloud@v0'
21+
22+
- name: Download demo data from GCP
23+
run: |
24+
echo "Downloading MIMIC-IV demo from GCP."
25+
gsutil -q -u $PROJECT_ID -m cp -r gs://mimic-iv-archive/v2.0/demo ./
26+
env:
27+
PROJECT_ID: ${{ inputs.gcp-project-id }}
28+
shell: bash

.github/workflows/build-db.yml

Lines changed: 0 additions & 172 deletions
This file was deleted.

.github/workflows/mysql.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: mysql demo db build
2+
on:
3+
pull_request_review:
4+
types: [submitted]
5+
6+
jobs:
7+
mimic-iv-mysql:
8+
# only run if PR is approved
9+
if: github.event.review.state == 'approved'
10+
runs-on: ubuntu-22.04
11+
12+
steps:
13+
- name: Check out repository code
14+
uses: actions/checkout@v3
15+
16+
- name: Download demo data
17+
uses: ./.github/actions/download-demo
18+
with:
19+
gcp-project-id: ${{ secrets.GCP_PROJECT_ID }}
20+
gcp-sa-key: ${{ secrets.GCP_SA_KEY }}
21+
22+
- name: Extract demo data to local folder
23+
run: |
24+
mv demo/hosp/*.csv.gz ./
25+
mv demo/icu/*.csv.gz ./
26+
mv demo/ed/*.csv.gz ./
27+
gzip -d *.csv.gz
28+
29+
- name: Start MySQL service
30+
run: |
31+
sudo /etc/init.d/mysql start
32+
mysql -u root -proot -e "SET GLOBAL local_infile=1;"
33+
mysql -u root -proot -e "SET GLOBAL sql_notes=0;"
34+
mysql -u root -proot -e "create database mimic"
35+
36+
- name: Load icu/hosp demo data
37+
run: |
38+
echo "Loading data into mysql."
39+
mysql -u root -proot --local-infile=1 mimic < mimic-iv/buildmimic/mysql/load.sql
40+
mysql -u root -proot mimic < mimic-iv/buildmimic/mysql/validate_demo.sql > results
41+
42+
# if we find "FAILED", then we did not pass the build
43+
if grep -F -q "FAILED" results; then
44+
echo "Failed the following row counts:"
45+
head -n 1 results
46+
grep "FAILED" results
47+
exit 1
48+
else
49+
echo "Built and loaded demo data successfully."
50+
cat results
51+
fi
52+
53+
- name: Load ed demo data
54+
run: |
55+
echo "Loading data into mysql."
56+
mysql -u root -proot --local-infile=1 mimic < mimic-iv-ed/buildmimic/mysql/load.sql
57+
mysql -u root -proot mimic < mimic-iv-ed/buildmimic/mysql/validate_demo.sql > results
58+
59+
# if we find "FAILED", then we did not pass the build
60+
if grep -F -q "FAILED" results; then
61+
echo "Failed the following row counts:"
62+
head -n 1 results
63+
grep "FAILED" results
64+
exit 1
65+
else
66+
echo "Built and loaded demo data successfully."
67+
cat results
68+
fi

.github/workflows/psql.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: psql demo db build
2+
on:
3+
pull_request_review:
4+
types: [submitted]
5+
6+
jobs:
7+
mimic-iv-psql:
8+
# only run if PR is approved
9+
if: github.event.review.state == 'approved'
10+
runs-on: ubuntu-latest
11+
container: node:latest
12+
13+
services:
14+
# Label used to access the service container
15+
postgres:
16+
# Docker Hub image
17+
image: 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: Download demo data
32+
uses: ./.github/actions/download-demo
33+
with:
34+
gcp-project-id: ${{ secrets.GCP_PROJECT_ID }}
35+
gcp-sa-key: ${{ secrets.GCP_SA_KEY }}
36+
37+
- name: Install postgresql-client
38+
run: |
39+
apt-get update
40+
apt-get install --yes --no-install-recommends postgresql-client
41+
42+
- name: Load icu/hosp data into PostgreSQL
43+
run: |
44+
echo "Loading data into psql."
45+
psql -q -h $POSTGRES_HOST -U postgres -f ${BUILDCODE_PATH}/create.sql
46+
psql -q -h $POSTGRES_HOST -U postgres -v mimic_data_dir=demo -f ${BUILDCODE_PATH}/load_gz.sql
47+
echo "Validating build."
48+
psql -h $POSTGRES_HOST -U postgres -f ${BUILDCODE_PATH}/validate_demo.sql > results
49+
50+
# if we find "FAILED", then we did not pass the build
51+
if grep -F -q "FAILED" results; then
52+
echo "Failed the following row counts:"
53+
head -n 1 results
54+
grep "FAILED" results
55+
exit 1
56+
else
57+
echo "Built and loaded demo data successfully."
58+
cat results
59+
fi
60+
61+
env:
62+
POSTGRES_HOST: postgres
63+
PGPASSWORD: postgres
64+
BUILDCODE_PATH: mimic-iv/buildmimic/postgres
65+
66+
- name: Build mimic-iv concepts
67+
run: |
68+
psql -h $POSTGRES_HOST -U postgres -f postgres-functions.sql
69+
psql -h $POSTGRES_HOST -U postgres -f postgres-make-concepts.sql
70+
working-directory: ./mimic-iv/concepts_postgres
71+
env:
72+
POSTGRES_HOST: postgres
73+
PGPASSWORD: postgres
74+
75+
- name: Load ed data into PostgreSQL
76+
run: |
77+
echo "Loading data into psql."
78+
psql -q -h $POSTGRES_HOST -U postgres -f ${BUILDCODE_PATH}/create.sql
79+
psql -q -h $POSTGRES_HOST -U postgres -v mimic_data_dir=demo/ed -f ${BUILDCODE_PATH}/load_gz.sql
80+
echo "Validating build."
81+
psql -h $POSTGRES_HOST -U postgres -f ${BUILDCODE_PATH}/validate_demo.sql > results
82+
83+
# if we find "FAILED", then we did not pass the build
84+
if grep -F -q "FAILED" results; then
85+
echo "Failed the following row counts:"
86+
head -n 1 results
87+
grep "FAILED" results
88+
exit 1
89+
else
90+
echo "Built and loaded demo data successfully."
91+
cat results
92+
fi
93+
94+
env:
95+
# The hostname used to communicate with the PostgreSQL service container
96+
POSTGRES_HOST: postgres
97+
PGPASSWORD: postgres
98+
# The default PostgreSQL port
99+
POSTGRES_PORT: 5432
100+
BUILDCODE_PATH: mimic-iv-ed/buildmimic/postgres

0 commit comments

Comments
 (0)