feat: add automated Heroku data health equivalency checks#864
Open
PRAteek-singHWY wants to merge 3 commits intoOWASP:mainfrom
Open
feat: add automated Heroku data health equivalency checks#864PRAteek-singHWY wants to merge 3 commits intoOWASP:mainfrom
PRAteek-singHWY wants to merge 3 commits intoOWASP:mainfrom
Conversation
Contributor
Author
|
Hi @Pa04rth @northdpole , quick update for #149:
Before merge, please run maintainer-side validation: re-enable |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #149.
This PR adds an automatic data health check for OpenCRE backups.
In simple terms: we now compare the latest Heroku backup with the latest known-good Heroku backup.
If they are not equivalent, the workflow fails.
Change Details + Verification
1) Canonical comparison for OpenCRE data
I added a canonical comparison layer for the core OpenCRE tables:
cre,node,cre_links, andcre_node_links.This comparison is ID-insensitive, so random internal UUID differences do not create false failures.
It also validates link integrity while building the snapshot.
Verification
application/tests/data_health_test.py.2) Script to compare two PostgreSQL datasets
I added
scripts/check_data_health.pyto compare two PostgreSQL DBs directly.The script prints row counts and digests for both sides, and gives a small diff summary if they differ.
Exit behavior is CI-friendly:
0when equal,1when not equal.Verification
3) Automated GitHub Action for data health checks
I added
.github/workflows/data-health-check.yml(scheduled + manual trigger).The workflow downloads the known-good backup artifact, captures/downloads the latest Heroku backup, restores both in local Postgres service DBs, and runs the comparison script.
Any mismatch fails the workflow.
Verification
4) Alignment with issue constraints
Issue guidance said known-good must be a Heroku backup (not local sqlite).
This implementation follows that requirement end-to-end in PostgreSQL backup flow.
Verification
Important Note for Maintainers (Required Before Merge)
I could not complete upstream end-to-end execution from my side due to environment/access limits.
To fully validate and merge safely, these maintainer-side steps are required:
Backupworkflow (currently disabled by inactivity).HEROKU_API_KEYis available inHeroku-DB-Backupenvironment secrets.Backuponmainonce so a freshopencreorg_db_backupartifact exists.Data Health Checkmanually (workflow_dispatch) and confirm expected behavior.