-
Notifications
You must be signed in to change notification settings - Fork 19
CoRIM SFR Profile and Example #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
attzonko
wants to merge
8
commits into
opencomputeproject:main
Choose a base branch
from
attzonko:corim
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e111fde
Adding CoRIM Profile Spec and Schema
attzonko 4a5bc7a
Adding back GitHub actions
attzonko bc0a6e1
Fixing syntax issue...
attzonko aa534f5
Trying to fix syntax by using same Python version as dev env
attzonko 7385e6f
Enhancing human readable helper script + comments
attzonko 051c0c5
Pinning Upstream Corim dependency to draft-08
attzonko be7283a
Addressing comments/issues
attzonko 981cbff
Trying to fix the failure from integration
attzonko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| name: Validate CDDL and Example | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| pull_request: | ||
| paths: | ||
| - 'Documentation/corim_profile/*.cddl' | ||
| - 'Documentation/corim_profile/examples/*.diag' | ||
|
|
||
| jobs: | ||
| validate: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Install Ruby cddl and cbor-diag gems | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y ruby | ||
| sudo gem install cddl | ||
| sudo gem install cddlc | ||
| sudo gem install cbor-diag | ||
|
|
||
| - name: Convert DIAG to CBOR | ||
| run: | | ||
| diag2cbor.rb Documentation/corim_profile/examples/ocp-safe-sfr-fw-example.diag > example.cbor | ||
|
|
||
| - name: Fetch latest upstream CoRIM CDDL | ||
| run: | | ||
| curl -L -o corim-base-upstream.cddl https://github.com/ietf-rats-wg/draft-ietf-rats-corim/releases/latest/download/corim-autogen.cddl | ||
|
|
||
| - name: Concatenate the CDDLs | ||
| run: | | ||
| cddlc -t cddl corim-base-upstream.cddl Documentation/corim_profile/ocp-safe-sfr-profile.cddl > combined.cddl | ||
|
|
||
| - name: Validate CBOR against CDDL | ||
| run: | | ||
| cddl combined.cddl validate example.cbor | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,243 @@ | ||
| name: Validate SFR Reports | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| pull_request: | ||
| paths: | ||
| - 'Reports/**/*.json' | ||
| - 'Reports/**/*.cbor' | ||
| - 'shortform_report-main/**' | ||
| - 'Documentation/corim_profile/*.cddl' | ||
| - 'Documentation/corim_profile/examples/*.diag' | ||
| push: | ||
| paths: | ||
| - 'Reports/**/*.json' | ||
| - 'Reports/**/*.cbor' | ||
| - 'shortform_report-main/**' | ||
| - 'Documentation/corim_profile/*.cddl' | ||
| - 'Documentation/corim_profile/examples/*.diag' | ||
|
|
||
| jobs: | ||
| validate-cbor-reports: | ||
| runs-on: ubuntu-latest | ||
| name: Validate CBOR CoRIM Reports | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '3.12' | ||
|
|
||
| - name: Install Ruby and CDDL tools | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y ruby | ||
| sudo gem install cddl | ||
| sudo gem install cddlc | ||
| sudo gem install cbor-diag | ||
|
|
||
| - name: Install Python dependencies | ||
| run: | | ||
| cd shortform_report-main | ||
| pip install -r requirements.txt | ||
|
|
||
| - name: Find CBOR reports | ||
| id: find-cbor | ||
| run: | | ||
| # Find all CBOR files in Reports directory | ||
| cbor_files=$(find Reports/ -name "*.cbor" 2>/dev/null || echo "") | ||
| if [ -n "$cbor_files" ]; then | ||
| echo "found=true" >> $GITHUB_OUTPUT | ||
| echo "files<<EOF" >> $GITHUB_OUTPUT | ||
| echo "$cbor_files" >> $GITHUB_OUTPUT | ||
| echo "EOF" >> $GITHUB_OUTPUT | ||
| echo "Found CBOR files:" | ||
| echo "$cbor_files" | ||
| else | ||
| echo "found=false" >> $GITHUB_OUTPUT | ||
| echo "No CBOR files found in Reports directory" | ||
| fi | ||
|
|
||
| - name: Prepare CDDL schema | ||
| run: | | ||
| # Fetch latest upstream CoRIM CDDL | ||
| curl -L -o corim-base-upstream.cddl https://github.com/ietf-rats-wg/draft-ietf-rats-corim/releases/latest/download/corim-autogen.cddl | ||
|
|
||
| # Concatenate the CDDLs | ||
| cddlc -t cddl corim-base-upstream.cddl Documentation/corim_profile/ocp-safe-sfr-profile.cddl > combined.cddl | ||
|
|
||
| echo "✅ CDDL schema prepared" | ||
|
|
||
| - name: Validate CBOR against CDDL schema | ||
| if: steps.find-cbor.outputs.found == 'true' | ||
| run: | | ||
| echo "Validating CBOR files against CDDL schema..." | ||
|
|
||
| validation_failed=false | ||
|
|
||
| echo "${{ steps.find-cbor.outputs.files }}" | while read -r file; do | ||
| if [ -n "$file" ] && [ -f "$file" ]; then | ||
| echo "Validating $file..." | ||
| if cddl combined.cddl validate "$file"; then | ||
| echo "✅ $file: Valid CBOR structure" | ||
| else | ||
| echo "❌ $file: CDDL validation failed" | ||
| validation_failed=true | ||
| fi | ||
| fi | ||
| done | ||
|
|
||
| if [ "$validation_failed" = true ]; then | ||
| echo "❌ Some CBOR files failed CDDL validation" | ||
| exit 1 | ||
| else | ||
| echo "🎉 All CBOR files passed CDDL validation!" | ||
| fi | ||
|
|
||
| - name: Test CoRIM generation | ||
| run: | | ||
| cd shortform_report-main | ||
| echo "Testing CoRIM generation functionality..." | ||
|
|
||
| # Run the comprehensive test suite | ||
| python tests/test_corim_generation.py | ||
|
|
||
| # Run CDDL validation test | ||
| python tests/test_cddl_validation.py | ||
|
|
||
| echo "✅ CoRIM generation tests completed" | ||
|
|
||
| validate-cddl-schema: | ||
| runs-on: ubuntu-latest | ||
| name: Validate CDDL Schema and Examples | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Ruby and CDDL tools | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y ruby | ||
| sudo gem install cddl | ||
| sudo gem install cddlc | ||
| sudo gem install cbor-diag | ||
|
|
||
| - name: Convert DIAG to CBOR | ||
| run: | | ||
| diag2cbor.rb Documentation/corim_profile/examples/ocp-safe-sfr-fw-example.diag > example.cbor | ||
|
|
||
| - name: Fetch latest upstream CoRIM CDDL | ||
| run: | | ||
| curl -L -o corim-base-upstream.cddl https://github.com/ietf-rats-wg/draft-ietf-rats-corim/releases/latest/download/corim-autogen.cddl | ||
|
|
||
| - name: Concatenate the CDDLs | ||
| run: | | ||
| cddlc -t cddl corim-base-upstream.cddl Documentation/corim_profile/ocp-safe-sfr-profile.cddl > combined.cddl | ||
|
|
||
| - name: Validate CBOR against CDDL | ||
| run: | | ||
| cddl combined.cddl validate example.cbor | ||
|
|
||
| integration-test: | ||
| runs-on: ubuntu-latest | ||
| name: Integration Test - JSON to CoRIM Conversion | ||
| needs: validate-cddl-schema | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '3.12' | ||
|
|
||
| - name: Install Ruby and CDDL tools | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y ruby | ||
| sudo gem install cddl | ||
| sudo gem install cddlc | ||
| sudo gem install cbor-diag | ||
|
|
||
| - name: Install Python dependencies | ||
| run: | | ||
| cd shortform_report-main | ||
| pip install -r requirements.txt | ||
|
|
||
| - name: Prepare CDDL schema | ||
| run: | | ||
| curl -L -o corim-base-upstream.cddl https://github.com/ietf-rats-wg/draft-ietf-rats-corim/releases/latest/download/corim-autogen.cddl | ||
| cddlc -t cddl corim-base-upstream.cddl Documentation/corim_profile/ocp-safe-sfr-profile.cddl > combined.cddl | ||
|
|
||
| - name: Test JSON to CoRIM conversion | ||
| run: | | ||
| cd shortform_report-main | ||
|
|
||
| # Find a sample JSON file to test conversion | ||
| sample_json=$(find ../Reports/ -name "*.json" -not -name "*_converted*" | head -1) | ||
attzonko marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| if [ -n "$sample_json" ] && [ -f "$sample_json" ]; then | ||
| echo "Testing conversion of: $sample_json" | ||
|
|
||
| # Convert JSON to CoRIM | ||
| python tests/json_to_corim_converter.py "$sample_json" -o test_converted.cbor | ||
|
|
||
| # Validate the converted CBOR against CDDL | ||
| if [ -f "test_converted.cbor" ]; then | ||
| echo "Validating converted CBOR against CDDL..." | ||
| cd .. | ||
| if cddl combined.cddl validate shortform_report-main/test_converted.cbor; then | ||
| echo "✅ JSON to CoRIM conversion successful and CDDL compliant!" | ||
| else | ||
| echo "❌ Converted CBOR failed CDDL validation" | ||
| exit 1 | ||
| fi | ||
| else | ||
| echo "❌ Conversion failed - no output file generated" | ||
| exit 1 | ||
| fi | ||
| else | ||
| echo "ℹ️ No sample JSON files found for conversion testing" | ||
| echo "Running final validation summary instead..." | ||
| cd shortform_report-main | ||
| python tests/final_validation_summary.py | ||
| fi | ||
|
|
||
| summary: | ||
| runs-on: ubuntu-latest | ||
| name: Validation Summary | ||
| needs: [validate-cbor-reports, validate-cddl-schema, integration-test] | ||
| if: always() | ||
| steps: | ||
| - name: Report Results | ||
| run: | | ||
| echo "## SFR Report Validation Summary" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
|
|
||
| if [ "${{ needs.validate-cbor-reports.result }}" = "success" ]; then | ||
| echo "✅ CBOR Reports: PASSED" >> $GITHUB_STEP_SUMMARY | ||
| else | ||
| echo "❌ CBOR Reports: FAILED" >> $GITHUB_STEP_SUMMARY | ||
| fi | ||
|
|
||
| if [ "${{ needs.validate-cddl-schema.result }}" = "success" ]; then | ||
| echo "✅ CDDL Schema: PASSED" >> $GITHUB_STEP_SUMMARY | ||
| else | ||
| echo "❌ CDDL Schema: FAILED" >> $GITHUB_STEP_SUMMARY | ||
| fi | ||
|
|
||
| if [ "${{ needs.integration-test.result }}" = "success" ]; then | ||
| echo "✅ Integration Test: PASSED" >> $GITHUB_STEP_SUMMARY | ||
| else | ||
| echo "❌ Integration Test: FAILED" >> $GITHUB_STEP_SUMMARY | ||
| fi | ||
|
|
||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "### Validation Coverage" >> $GITHUB_STEP_SUMMARY | ||
| echo "- JSON SFR report structure validation" >> $GITHUB_STEP_SUMMARY | ||
| echo "- CBOR CoRIM CDDL schema compliance" >> $GITHUB_STEP_SUMMARY | ||
| echo "- CoRIM generation functionality" >> $GITHUB_STEP_SUMMARY | ||
| echo "- JSON to CoRIM conversion" >> $GITHUB_STEP_SUMMARY | ||
| echo "- End-to-end integration testing" >> $GITHUB_STEP_SUMMARY | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.