Skip to content

Optimization: 5/5 GitHub Portfolio Rating — Visibility, Community Health, SEO, and Social Proof #53

Optimization: 5/5 GitHub Portfolio Rating — Visibility, Community Health, SEO, and Social Proof

Optimization: 5/5 GitHub Portfolio Rating — Visibility, Community Health, SEO, and Social Proof #53

Workflow file for this run

name: Data Validation CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -e .
- name: Validate JSON data files
run: |
python3 -c "import json; json.load(open('data/political/political_layer_report.json')); print('political_layer_report.json OK')"
python3 -c "import json; json.load(open('data/political/fec_funding_profiles.json')); print('fec_funding_profiles.json OK')"
python3 -c "import json; json.load(open('data/political/fec_audit_log.json')); print('fec_audit_log.json OK')"
echo "✅ All JSON files valid"
- name: Validate metadata schema compliance
run: |
python3 -c "
import json, sys
files = [
'data/political/fec_funding_profiles.json',
'data/political/fec_excluded_self_funding.json',
'data/political/fec_quick_results.json',
'data/political/fec_audit_log.json',
'data/political/political_layer_report.json',
'data/political/employer_contribution_gap.json',
]
required = ['generated_by','generated_at','cycle','api_version','reconciliation_status','purpose','methodology','caveat']
valid_status = ['VALIDATED','INVESTIGATIVE','CALCULATED','ENRICHED','AUDIT']
errors = []
for fpath in files:
try:
d = json.load(open(fpath))
except FileNotFoundError:
print(f' SKIP {fpath} (not generated yet)')
continue
if '_metadata' not in d:
errors.append(f'{fpath}: missing _metadata wrapper')
continue
meta = d['_metadata']
for field in required:
if field not in meta:
errors.append(f'{fpath}: missing required field: {field}')
status = meta.get('reconciliation_status','')
if status not in valid_status:
errors.append(f'{fpath}: invalid reconciliation_status: {status!r}')
if errors:
for e in errors: print(f' ERROR: {e}')
sys.exit(1)
print('✅ All metadata schema checks passed')
"
- name: Validate CSV data files
run: |
python3 -c "import pandas as pd; df = pd.read_csv('data/dmv_macro_baselines.csv'); print(f'✅ CSV valid: {len(df)} rows, {len(df.columns)} columns')"
- name: Check exported figures exist
run: |
COUNT=$(ls figures/*.png 2>/dev/null | wc -l)
echo "Found $COUNT figure files"
if [ "$COUNT" -lt 10 ]; then
echo "❌ Expected at least 10 figures"
exit 1
fi
echo "✅ Figures check passed ($COUNT PNGs)"
- name: FEC data quality check
run: |
cat > /tmp/fec_check.py << 'EOF'
import json, sys
with open('data/political/fec_funding_profiles.json') as f:
data = json.load(f)
# Handle both wrapped (_metadata + data) and unwrapped formats
profiles = data.get('data', data) if isinstance(data, dict) else data
errors = 0
for p in profiles:
total = p.get('total_receipts', 0) or 0
itemized = sum([
p.get('business_contributions', 0),
p.get('labor_contributions', 0),
p.get('pac_committee_contributions', 0),
p.get('other_contributions', 0)
])
quality = p.get('data_quality', 'UNKNOWN')
if quality != 'VALID':
print(f'⚠️ {p["name"]}: {quality} — {p.get("validation_message", "")}')
errors += 1
else:
print(f'✅ {p["name"]}: {p.get("validation_message", "")}')
if errors > 0:
print(f'❌ {errors}/{len(profiles)} profiles failed data quality check')
sys.exit(1)
print(f'✅ All {len(profiles)} profiles passed data quality validation')
EOF
python3 /tmp/fec_check.py
- name: Check script syntax
run: |
python3 -m py_compile src/ui_index/*.py tools/*.py
find . -name __pycache__ -type d -prune -exec rm -rf {} +
echo "✅ All Python modules and tools compile successfully"
- name: Run data integrity tests
run: |
python -m pytest tests/ -v
echo "✅ All data integrity tests passed"
- name: Verify no __pycache__ committed
run: |
if git ls-files | grep -q __pycache__; then
echo "❌ __pycache__ files are tracked by git"
exit 1
fi
echo "✅ No __pycache__ committed"