|
| 1 | +name: Validate SFR Reports |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + pull_request: |
| 6 | + paths: |
| 7 | + - 'Reports/**/*.json' |
| 8 | + - 'Reports/**/*.cbor' |
| 9 | + - 'shortform_report-main/**' |
| 10 | + - 'Documentation/corim_profile/*.cddl' |
| 11 | + - 'Documentation/corim_profile/examples/*.diag' |
| 12 | + push: |
| 13 | + paths: |
| 14 | + - 'Reports/**/*.json' |
| 15 | + - 'Reports/**/*.cbor' |
| 16 | + - 'shortform_report-main/**' |
| 17 | + - 'Documentation/corim_profile/*.cddl' |
| 18 | + - 'Documentation/corim_profile/examples/*.diag' |
| 19 | + |
| 20 | +jobs: |
| 21 | + validate-cbor-reports: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + name: Validate CBOR CoRIM Reports |
| 24 | + steps: |
| 25 | + - name: Checkout repository |
| 26 | + uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - name: Set up Python |
| 29 | + uses: actions/setup-python@v4 |
| 30 | + with: |
| 31 | + python-version: '3.12' |
| 32 | + |
| 33 | + - name: Install Ruby and CDDL tools |
| 34 | + run: | |
| 35 | + sudo apt-get update |
| 36 | + sudo apt-get install -y ruby |
| 37 | + sudo gem install cddl |
| 38 | + sudo gem install cddlc |
| 39 | + sudo gem install cbor-diag |
| 40 | +
|
| 41 | + - name: Install Python dependencies |
| 42 | + run: | |
| 43 | + cd shortform_report-main |
| 44 | + pip install -r requirements.txt |
| 45 | +
|
| 46 | + - name: Find CBOR reports |
| 47 | + id: find-cbor |
| 48 | + run: | |
| 49 | + # Find all CBOR files in Reports directory |
| 50 | + cbor_files=$(find Reports/ -name "*.cbor" 2>/dev/null || echo "") |
| 51 | + if [ -n "$cbor_files" ]; then |
| 52 | + echo "found=true" >> $GITHUB_OUTPUT |
| 53 | + echo "files<<EOF" >> $GITHUB_OUTPUT |
| 54 | + echo "$cbor_files" >> $GITHUB_OUTPUT |
| 55 | + echo "EOF" >> $GITHUB_OUTPUT |
| 56 | + echo "Found CBOR files:" |
| 57 | + echo "$cbor_files" |
| 58 | + else |
| 59 | + echo "found=false" >> $GITHUB_OUTPUT |
| 60 | + echo "No CBOR files found in Reports directory" |
| 61 | + fi |
| 62 | +
|
| 63 | + - name: Prepare CDDL schema |
| 64 | + run: | |
| 65 | + # Fetch latest upstream CoRIM CDDL |
| 66 | + curl -L -o corim-base-upstream.cddl https://github.com/ietf-rats-wg/draft-ietf-rats-corim/releases/download/cddl-draft-ietf-rats-corim-08/corim-autogen.cddl |
| 67 | + |
| 68 | + # Concatenate the CDDLs |
| 69 | + cddlc -t cddl corim-base-upstream.cddl Documentation/corim_profile/ocp-safe-sfr-profile.cddl > combined.cddl |
| 70 | + |
| 71 | + echo "✅ CDDL schema prepared" |
| 72 | +
|
| 73 | + - name: Validate CBOR against CDDL schema |
| 74 | + if: steps.find-cbor.outputs.found == 'true' |
| 75 | + run: | |
| 76 | + echo "Validating CBOR files against CDDL schema..." |
| 77 | + |
| 78 | + validation_failed=false |
| 79 | + |
| 80 | + echo "${{ steps.find-cbor.outputs.files }}" | while read -r file; do |
| 81 | + if [ -n "$file" ] && [ -f "$file" ]; then |
| 82 | + echo "Validating $file..." |
| 83 | + if cddl combined.cddl validate "$file"; then |
| 84 | + echo "✅ $file: Valid CBOR structure" |
| 85 | + else |
| 86 | + echo "❌ $file: CDDL validation failed" |
| 87 | + validation_failed=true |
| 88 | + fi |
| 89 | + fi |
| 90 | + done |
| 91 | + |
| 92 | + if [ "$validation_failed" = true ]; then |
| 93 | + echo "❌ Some CBOR files failed CDDL validation" |
| 94 | + exit 1 |
| 95 | + else |
| 96 | + echo "🎉 All CBOR files passed CDDL validation!" |
| 97 | + fi |
| 98 | +
|
| 99 | + - name: Test CoRIM generation |
| 100 | + run: | |
| 101 | + cd shortform_report-main |
| 102 | + echo "Testing CoRIM generation functionality..." |
| 103 | + |
| 104 | + # Run the comprehensive test suite |
| 105 | + python tests/test_corim_generation.py |
| 106 | + |
| 107 | + # Run CDDL validation test |
| 108 | + python tests/test_cddl_validation.py |
| 109 | + |
| 110 | + echo "✅ CoRIM generation tests completed" |
| 111 | +
|
| 112 | + validate-cddl-schema: |
| 113 | + runs-on: ubuntu-latest |
| 114 | + name: Validate CDDL Schema and Examples |
| 115 | + steps: |
| 116 | + - name: Checkout repository |
| 117 | + uses: actions/checkout@v4 |
| 118 | + |
| 119 | + - name: Install Ruby and CDDL tools |
| 120 | + run: | |
| 121 | + sudo apt-get update |
| 122 | + sudo apt-get install -y ruby |
| 123 | + sudo gem install cddl |
| 124 | + sudo gem install cddlc |
| 125 | + sudo gem install cbor-diag |
| 126 | +
|
| 127 | + - name: Convert DIAG to CBOR |
| 128 | + run: | |
| 129 | + diag2cbor.rb Documentation/corim_profile/examples/ocp-safe-sfr-fw-example.diag > example.cbor |
| 130 | +
|
| 131 | + - name: Fetch latest upstream CoRIM CDDL |
| 132 | + run: | |
| 133 | + curl -L -o corim-base-upstream.cddl https://github.com/ietf-rats-wg/draft-ietf-rats-corim/releases/download/cddl-draft-ietf-rats-corim-08/corim-autogen.cddl |
| 134 | +
|
| 135 | + - name: Concatenate the CDDLs |
| 136 | + run: | |
| 137 | + cddlc -t cddl corim-base-upstream.cddl Documentation/corim_profile/ocp-safe-sfr-profile.cddl > combined.cddl |
| 138 | +
|
| 139 | + - name: Validate CBOR against CDDL |
| 140 | + run: | |
| 141 | + cddl combined.cddl validate example.cbor |
| 142 | +
|
| 143 | + integration-test: |
| 144 | + runs-on: ubuntu-latest |
| 145 | + name: Integration Test - JSON to CoRIM Conversion |
| 146 | + needs: validate-cddl-schema |
| 147 | + steps: |
| 148 | + - name: Checkout repository |
| 149 | + uses: actions/checkout@v4 |
| 150 | + |
| 151 | + - name: Set up Python |
| 152 | + uses: actions/setup-python@v4 |
| 153 | + with: |
| 154 | + python-version: '3.12' |
| 155 | + |
| 156 | + - name: Install Ruby and CDDL tools |
| 157 | + run: | |
| 158 | + sudo apt-get update |
| 159 | + sudo apt-get install -y ruby |
| 160 | + sudo gem install cddl |
| 161 | + sudo gem install cddlc |
| 162 | + sudo gem install cbor-diag |
| 163 | +
|
| 164 | + - name: Install Python dependencies |
| 165 | + run: | |
| 166 | + cd shortform_report-main |
| 167 | + pip install -r requirements.txt |
| 168 | +
|
| 169 | + - name: Prepare CDDL schema |
| 170 | + run: | |
| 171 | + curl -L -o corim-base-upstream.cddl https://github.com/ietf-rats-wg/draft-ietf-rats-corim/releases/download/cddl-draft-ietf-rats-corim-08/corim-autogen.cddl |
| 172 | + cddlc -t cddl corim-base-upstream.cddl Documentation/corim_profile/ocp-safe-sfr-profile.cddl > combined.cddl |
| 173 | +
|
| 174 | + - name: Test JSON to CoRIM conversion |
| 175 | + run: | |
| 176 | + cd shortform_report-main |
| 177 | + |
| 178 | + # Use a specific JSON file for testing conversion |
| 179 | + sample_json="../Reports/AMD/2024/MI300X/OCP_SAFE_-_amd_asp_-_BL_-_Boot_Access_Module.json" |
| 180 | + |
| 181 | + if [ -f "$sample_json" ]; then |
| 182 | + echo "Testing conversion of: $sample_json" |
| 183 | + |
| 184 | + # Convert JSON to CoRIM |
| 185 | + python tests/json_to_corim_converter.py "$sample_json" -o test_converted.cbor |
| 186 | + |
| 187 | + # Validate the converted CBOR against CDDL |
| 188 | + if [ -f "test_converted.cbor" ]; then |
| 189 | + echo "Validating converted CBOR against CDDL..." |
| 190 | + cd .. |
| 191 | + if cddl combined.cddl validate shortform_report-main/test_converted.cbor; then |
| 192 | + echo "✅ JSON to CoRIM conversion successful and CDDL compliant!" |
| 193 | + else |
| 194 | + echo "❌ Converted CBOR failed CDDL validation" |
| 195 | + exit 1 |
| 196 | + fi |
| 197 | + else |
| 198 | + echo "❌ Conversion failed - no output file generated" |
| 199 | + exit 1 |
| 200 | + fi |
| 201 | + else |
| 202 | + echo "ℹ️ Test JSON file not found: $sample_json" |
| 203 | + echo "Running final validation summary instead..." |
| 204 | + python tests/final_validation_summary.py |
| 205 | + fi |
| 206 | +
|
| 207 | + summary: |
| 208 | + runs-on: ubuntu-latest |
| 209 | + name: Validation Summary |
| 210 | + needs: [validate-cbor-reports, validate-cddl-schema, integration-test] |
| 211 | + if: always() |
| 212 | + steps: |
| 213 | + - name: Report Results |
| 214 | + run: | |
| 215 | + echo "## SFR Report Validation Summary" >> $GITHUB_STEP_SUMMARY |
| 216 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 217 | + |
| 218 | + if [ "${{ needs.validate-cbor-reports.result }}" = "success" ]; then |
| 219 | + echo "✅ CBOR Reports: PASSED" >> $GITHUB_STEP_SUMMARY |
| 220 | + else |
| 221 | + echo "❌ CBOR Reports: FAILED" >> $GITHUB_STEP_SUMMARY |
| 222 | + fi |
| 223 | + |
| 224 | + if [ "${{ needs.validate-cddl-schema.result }}" = "success" ]; then |
| 225 | + echo "✅ CDDL Schema: PASSED" >> $GITHUB_STEP_SUMMARY |
| 226 | + else |
| 227 | + echo "❌ CDDL Schema: FAILED" >> $GITHUB_STEP_SUMMARY |
| 228 | + fi |
| 229 | + |
| 230 | + if [ "${{ needs.integration-test.result }}" = "success" ]; then |
| 231 | + echo "✅ Integration Test: PASSED" >> $GITHUB_STEP_SUMMARY |
| 232 | + else |
| 233 | + echo "❌ Integration Test: FAILED" >> $GITHUB_STEP_SUMMARY |
| 234 | + fi |
| 235 | + |
| 236 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 237 | + echo "### Validation Coverage" >> $GITHUB_STEP_SUMMARY |
| 238 | + echo "- JSON SFR report structure validation" >> $GITHUB_STEP_SUMMARY |
| 239 | + echo "- CBOR CoRIM CDDL schema compliance" >> $GITHUB_STEP_SUMMARY |
| 240 | + echo "- CoRIM generation functionality" >> $GITHUB_STEP_SUMMARY |
| 241 | + echo "- JSON to CoRIM conversion" >> $GITHUB_STEP_SUMMARY |
| 242 | + echo "- End-to-end integration testing" >> $GITHUB_STEP_SUMMARY |
0 commit comments