|
| 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