Skip to content

Commit 1255e91

Browse files
committed
build db:ci automatically
1 parent 37b562e commit 1255e91

1 file changed

Lines changed: 47 additions & 2 deletions

File tree

.github/workflows/dbdump.yml

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
psql -h localhost -U postgres -d bety -c "CREATE EXTENSION postgis;"
3636
3737
- name: Sync with EBI
38-
run: script/load.bety.sh -a "postgres" -p "-h localhost" -d "bety" -o bety -m 99 -r 0 -c -w https://ebi-forecast.igb.illinois.edu/pecan/dump/bety.tar.gz
38+
run: script/load.bety.sh -a "postgres" -p "-h localhost" -d "bety" -o bety -m 99 -r 0 -c -w http://www.betydb.org/dump/bety.tar.gz
3939

4040
- name: Sync with BU
4141
run: script/load.bety.sh -a "postgres" -p "-h localhost" -d "bety" -o bety -m 99 -r 1
@@ -44,7 +44,7 @@ jobs:
4444
run: script/load.bety.sh -a "postgres" -p "-h localhost" -d "bety" -o bety -m 99 -r 2 -w ftp://anon:anon@ftp.test.bnl.gov/outgoing/betydb/bety.tar.gz
4545

4646
- name: Sync with Wisconsin
47-
run: script/load.bety.sh -a "postgres" -p "-h localhost" -d "bety" -o bety -m 99 -r 5 -w http://fen.aos.wisc.edu:6480/sync/dump/bety.tar.gz
47+
run: script/load.bety.sh -a "postgres" -p "-h localhost" -d "bety" -o bety -m 99 -r 5 -w http://tree.aos.wisc.edu:6480/sync/dump/bety.tar.gz
4848

4949
- name: Dump Database
5050
run: |
@@ -56,6 +56,45 @@ jobs:
5656
cd initdb
5757
docker build --tag image --file Dockerfile .
5858
59+
- name: Build smaller dump for CI runs
60+
# update on scheduled runs, not every PR
61+
if: github.event.schedule != ''
62+
run: |
63+
# Nuke some large tables not used in testing
64+
# (to avoid foreign key constraints when deleting their child inputs)
65+
docker exec ${PG} psql -h localhost -U bety -c "
66+
TRUNCATE runs,likelihoods,benchmarks CASCADE"
67+
# Drop unneeded records from inputs table
68+
# (loop is because many are referenced only by descendent inputs
69+
# that are themselves deleted here.)
70+
while [ "$DEL_RES" != "DELETE 0" ]; do
71+
DEL_RES=$(
72+
docker exec ${PG} psql -h localhost -U bety -c "
73+
DELETE FROM inputs WHERE
74+
id NOT IN (
75+
SELECT DISTINCT container_id FROM dbfiles
76+
WHERE container_type = 'Input'
77+
AND container_id IS NOT null)
78+
AND id NOT IN (
79+
SELECT DISTINCT parent_id FROM inputs
80+
WHERE parent_id IS NOT null);"
81+
) || break
82+
echo ${DEL_RES}
83+
done
84+
# CI tests don't need any records from the excluded tables, just schemas
85+
docker exec ${PG} pg_dump \
86+
-h localhost -U bety \
87+
--exclude-table-data='runs*' \
88+
--exclude-table-data='inputs_runs*' \
89+
--exclude-table-data='likelihoods*' \
90+
--exclude-table-data='ensembles*' \
91+
--exclude-table-data='posteriors_ensembles*' \
92+
--exclude-table-data='benchmarks*' \
93+
--exclude-table-data='reference_runs*' \
94+
-F c \
95+
bety > initdb/db.dump
96+
docker build --tag image_ci --file Dockerfile .
97+
5998
- name: Login into registry
6099
run: |
61100
echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
@@ -75,3 +114,9 @@ jobs:
75114
docker push pecan/db:$T
76115
fi
77116
done
117+
if [ -n "$(docker image ls -q image_ci)" ]; then
118+
docker tag image_ci $IMAGE_ID:ci
119+
docker push $IMAGE_ID:ci
120+
docker tag image_ci pecan/db:ci
121+
docker push pecan/db:ci
122+
fi

0 commit comments

Comments
 (0)