This repository includes an automated validation pipeline that ensures the BuildingCode.json file conforms to the defined schema before any changes are merged to the develop branch.
The validation pipeline automatically:
- Validates
BuildingCode.jsonagainstschema.jsonon every PR todevelop - Posts detailed validation results as PR comments
- Prevents merging PRs with validation errors
- Provides clear feedback on what needs to be fixed
.github/workflows/validate-json.yml- Main workflow that runs on PR creation/updates
.github/scripts/validate_json.py- Python script that performs the actual validation
- Trigger: When a PR is created or updated targeting the
developbranch - Validation: The workflow runs the Python validation script
- Results: Validation results are posted as PR comments
- Protection: Branch protection rules prevent merging if validation fails
- Comprehensive Error Reporting: Shows exact paths and error messages
- Large File Support: Handles the 60MB BuildingCode.json file efficiently
- Schema Compliance: Uses JSON Schema Draft 7 for validation
- Clear Feedback: Human-readable error messages in PR comment
The validation script checks:
- JSON syntax validity
- Schema compliance for all required fields
- Data type validation
- Structure validation for nested objects
- Array item validation
When validation fails:
- ❌ The GitHub Action fails
- 📝 Detailed errors are written to
validation_errors.txt - 💬 A comment is posted on the PR with error details
- 🚫 The PR cannot be merged until errors are fixed
When validation succeeds:
- ✅ The GitHub Action passes
- 💬 A success comment is posted on the PR
- 🎯 The PR is ready for review and merge
To test the validation pipeline:
- Create a test branch from
develop - Modify
BuildingCode.jsonto introduce a schema violation - Create a PR to
develop - Observe the validation workflow run and report errors
- Fix the errors and push again
- Verify the workflow passes
- The validation script uses Python 3.11 and the
jsonschemalibrary - No additional dependencies or setup required
- The workflow runs on Ubuntu latest in GitHub Actions
- All validation logic is contained in the Python script