Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,274 changes: 2,274 additions & 0 deletions .gh_action_data/1.5.sql

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions .gh_action_data/run-schemadiff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

# Create SQL dump of the old schema (with updates applied)
dropdb --host=testdb --username=postgres cmsdbfortesting
createdb --host=testdb --username=postgres cmsdbfortesting
psql --host=testdb --username=postgres cmsdbfortesting < .gh_action_data/1.5.sql
psql --host=testdb --username=postgres cmsdbfortesting < cmscontrib/updaters/update_from_1.5.sql
pg_dump --host=testdb --username=postgres --schema-only cmsdbfortesting > .gh_action_data/updated_schema.sql

# Create SQL dump of the new schema
dropdb --host=testdb --username=postgres cmsdbfortesting
createdb --host=testdb --username=postgres cmsdbfortesting
cmsInitDB
pg_dump --host=testdb --username=postgres --schema-only cmsdbfortesting > .gh_action_data/new_schema.sql

# Compare the two schema dumps
diff .gh_action_data/updated_schema.sql .gh_action_data/new_schema.sql | grep -v '^--' | grep -v -e '^[[:space:]]*$' > .gh_action_data/schema_diff.txt
if [ -s .gh_action_data/schema_diff.txt ]
then
echo "Schema diff found:"
cat .gh_action_data/schema_diff.txt
exit 1
else
echo "No schema diff found."
exit 0
fi
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
# For things like schema changes, where we need to make sure that an updater is provided
/cms/db @wil93
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ci
name: Run unit and functional tests

on:
- push
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/schema_diff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Check DB schema differences

on:
- push
- pull_request

jobs:
test:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v2
with:
submodules: true

- name: Build docker image
run: |
docker compose -p cms -f docker-compose.test.yml build testcms

- name: Check schema diff
run: |
docker compose -p cms -f docker-compose.test.yml run --rm schemadiff
14 changes: 12 additions & 2 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:
- "./codecov:/home/cmsuser/cms/codecov"
privileged: true
cgroup: host
command: wait-for-it testdb:5432 -- ./_cms-test-internal.sh
command: wait-for-it testdb:5432 -- .gh_action_data/run-test.sh

stresstestcms:
build: .
Expand All @@ -28,4 +28,14 @@ services:
CMS_CONFIG: /usr/local/etc/cms-testdb.toml
privileged: true
cgroup: host
command: wait-for-it testdb:5432 -- ./_cms-stresstest-internal.sh
command: wait-for-it testdb:5432 -- .gh_action_data/run-stresstest.sh

schemadiff:
build: .
depends_on:
- "testdb"
environment:
CMS_CONFIG: /usr/local/etc/cms-testdb.toml
privileged: true
cgroup: host
command: wait-for-it testdb:5432 -- .gh_action_data/run-schemadiff.sh
Loading