-
Notifications
You must be signed in to change notification settings - Fork 35
242 lines (204 loc) · 8.4 KB
/
validate-reports.yml
File metadata and controls
242 lines (204 loc) · 8.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
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/download/cddl-draft-ietf-rats-corim-08/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/download/cddl-draft-ietf-rats-corim-08/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/download/cddl-draft-ietf-rats-corim-08/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
# Use a specific JSON file for testing conversion
sample_json="../Reports/AMD/2024/MI300X/OCP_SAFE_-_amd_asp_-_BL_-_Boot_Access_Module.json"
if [ -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 "ℹ️ Test JSON file not found: $sample_json"
echo "Running final validation summary instead..."
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