-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
34d9e92
commit 6bc28a1
Showing
1 changed file
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: Test PostgreSQL database creation and TAP_SCHEMA upload | ||
on: | ||
push: | ||
|
||
jobs: | ||
|
||
test: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
env: | ||
PGHOST: localhost | ||
PGPORT: 5432 | ||
PGUSER: rubin | ||
PGPASSWORD: rubin | ||
PGDATABASE: sdm_schemas_test | ||
|
||
services: | ||
postgres: | ||
image: postgres:13 | ||
env: | ||
POSTGRES_USER: rubin | ||
POSTGRES_PASSWORD: rubin | ||
POSTGRES_DB: sdm_schemas_test | ||
ports: | ||
- 5432:5432 | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
steps: | ||
|
||
- name: Check out repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.12" | ||
cache: "pip" | ||
|
||
- name: Install yq | ||
run: sudo snap install yq | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip uv | ||
uv pip install --system -r requirements.txt | ||
- name: Set engine URL | ||
run: echo "FELIS_ENGINE_URL=postgresql+psycopg2://rubin:rubin@localhost:5432/sdm_schemas_test" >> $GITHUB_ENV | ||
|
||
# Create databases from YAML files. Drop existing databases since some of | ||
# the schema names are duplicated and also ignore constraints since many | ||
# schemas are missing required indices for FK constraints. | ||
- name: Create databases | ||
run: ./scripts/create-databases.sh | ||
|
||
- name: Create SQL files | ||
run: ./scripts/generate-sql-files.sh postgresql | ||
|
||
- name: Load SQL files | ||
run: ./scripts/test-load-sql-postgres.sh | ||
|
||
- name: Initialize TAP_SCHEMA database | ||
run: | | ||
felis init-tap $FELIS_ENGINE_URL | ||
# Upload to TAP_SCHEMA database. Clear the tables after each upload to | ||
# avoid conflicts between schemas. | ||
- name: Upload to TAP_SCHEMA database | ||
run: | | ||
set +e | ||
for yaml_file in yml/*.yaml; do | ||
filename=$(basename "yaml_file" .yaml) | ||
echo "Uploading to TAP_SCHEMA from $yaml_file..." | ||
felis --log-level ERROR load-tap "$yaml_file" | ||
echo "Done uploading to TAP_SCHEMA from $yaml_file" | ||
psql -q -c "TRUNCATE TABLE columns, key_columns, keys, schemas, tables;" &> /dev/null | ||
done | ||
set -e |