Skip to content

Commit 4423034

Browse files
committed
add CI to test docker builds of psql/duckdb
1 parent 4ab8483 commit 4423034

1 file changed

Lines changed: 89 additions & 0 deletions

File tree

‎.github/workflows/docker-build.yml‎

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Build and run the containerized MIMIC-IV builds against the demo dataset.
2+
name: docker build
3+
4+
on:
5+
pull_request:
6+
paths:
7+
- 'mimic-iv/buildmimic/postgres/**'
8+
- 'mimic-iv/buildmimic/duckdb/**'
9+
- 'mimic-iv/buildmimic/download_data.sh'
10+
- '.github/workflows/docker-build.yml'
11+
push:
12+
branches:
13+
- main
14+
paths:
15+
- 'mimic-iv/buildmimic/postgres/**'
16+
- 'mimic-iv/buildmimic/duckdb/**'
17+
- '.github/workflows/docker-build.yml'
18+
19+
# Cancel superseded runs when a PR is pushed again.
20+
concurrency:
21+
group: docker-build-${{ github.event.pull_request.number || github.ref }}
22+
cancel-in-progress: true
23+
24+
permissions:
25+
contents: read
26+
27+
jobs:
28+
build:
29+
runs-on: ubuntu-latest
30+
31+
defaults:
32+
run:
33+
# Name bash explicitly to get `-eo pipefail`.
34+
shell: bash
35+
36+
env:
37+
DUCKDB_DOCKER: mimic-iv/buildmimic/duckdb/docker
38+
POSTGRES_DOCKER: mimic-iv/buildmimic/postgres/docker
39+
MIMIC_DATA_DIR: ${{ github.workspace }}
40+
MIMIC_OUTPUT_DIR: ${{ github.workspace }}/duckdb-out
41+
42+
steps:
43+
- uses: actions/checkout@v7
44+
- uses: ./.github/actions/download-demo
45+
- uses: ./.github/actions/setup-duckdb
46+
47+
- name: Build both images
48+
run: |
49+
docker compose -f "$DUCKDB_DOCKER/docker-compose.yml" build
50+
docker compose -f "$POSTGRES_DOCKER/docker-compose.yml" build
51+
52+
# --exit-code-from implies --abort-on-container-exit and returns the build
53+
# job's own status, so a failed build fails the step.
54+
- name: Build MIMIC-IV in DuckDB
55+
run: |
56+
mkdir -p "$MIMIC_OUTPUT_DIR"
57+
docker compose -f "$DUCKDB_DOCKER/docker-compose.yml" \
58+
up --exit-code-from mimic-build | tee duckdb.log
59+
if grep -F -q "FAILED" duckdb.log; then
60+
echo "::error::DuckDB container row-count validation failed:"
61+
grep -F "FAILED" duckdb.log
62+
exit 1
63+
fi
64+
65+
- name: Read the built database with the runner's own duckdb
66+
run: |
67+
rows=$(duckdb "$MIMIC_OUTPUT_DIR/mimic4.db" -noheader -list \
68+
-c "SELECT count(*) FROM mimiciv_derived.sepsis3")
69+
echo "mimiciv_derived.sepsis3: ${rows} rows"
70+
if [ -z "${rows}" ] || [ "${rows}" -eq 0 ]; then
71+
echo "::error::The concepts are missing from the container-built database."
72+
exit 1
73+
fi
74+
75+
- name: Build MIMIC-IV in PostgreSQL
76+
run: |
77+
docker compose -f "$POSTGRES_DOCKER/docker-compose.yml" \
78+
up --exit-code-from mimic-build | tee psql.log
79+
if grep -F -q "FAILED" psql.log; then
80+
echo "::error::PostgreSQL container row-count validation failed:"
81+
grep -F "FAILED" psql.log
82+
exit 1
83+
fi
84+
85+
- name: Tear down
86+
if: always()
87+
run: |
88+
docker compose -f "$DUCKDB_DOCKER/docker-compose.yml" down -v || true
89+
docker compose -f "$POSTGRES_DOCKER/docker-compose.yml" down -v || true

0 commit comments

Comments
 (0)