|
| 1 | +name: 'Run Inferno ONC Tests' |
| 2 | +description: 'Executes Inferno ONC Program Edition tests and generates compliance reports' |
| 3 | + |
| 4 | +inputs: |
| 5 | + test_stage: |
| 6 | + description: 'Testing stage: alpha, beta, or production' |
| 7 | + required: true |
| 8 | + inferno_container_id: |
| 9 | + description: 'Container ID of the running Inferno instance' |
| 10 | + required: true |
| 11 | + test_config_path: |
| 12 | + description: 'Path to the Inferno test configuration file' |
| 13 | + required: true |
| 14 | + fhir_server_url: |
| 15 | + description: 'FHIR server URL being tested' |
| 16 | + required: true |
| 17 | + test_timeout: |
| 18 | + description: 'Maximum time to wait for tests to complete (in seconds)' |
| 19 | + required: false |
| 20 | + default: '1800' |
| 21 | + |
| 22 | +outputs: |
| 23 | + test_session_id: |
| 24 | + description: 'ID of the created test session' |
| 25 | + value: ${{ steps.run-tests.outputs.session_id }} |
| 26 | + test_results_path: |
| 27 | + description: 'Path to the test results directory' |
| 28 | + value: ${{ steps.run-tests.outputs.results_path }} |
| 29 | + compliance_status: |
| 30 | + description: 'Overall compliance test status (passed/failed)' |
| 31 | + value: ${{ steps.analyze-results.outputs.status }} |
| 32 | + |
| 33 | +runs: |
| 34 | + using: 'composite' |
| 35 | + steps: |
| 36 | + - name: Create Inferno test directories |
| 37 | + shell: bash |
| 38 | + run: | |
| 39 | + echo "π Creating Inferno-specific test directories..." |
| 40 | + mkdir -p testing/${{ inputs.test_stage }}/reports/inferno |
| 41 | + mkdir -p testing/${{ inputs.test_stage }}/data |
| 42 | +
|
| 43 | + - name: Verify Inferno is running |
| 44 | + shell: bash |
| 45 | + run: | |
| 46 | + echo "π Verifying Inferno container is running..." |
| 47 | + if ! docker ps | grep -q "${{ inputs.inferno_container_id }}"; then |
| 48 | + echo "β Inferno container is not running" |
| 49 | + exit 1 |
| 50 | + fi |
| 51 | + echo "β
Inferno container is running" |
| 52 | +
|
| 53 | + - name: Validate FHIR server for Inferno testing |
| 54 | + shell: bash |
| 55 | + run: | |
| 56 | + echo "π₯ Validating FHIR server for Inferno compliance testing..." |
| 57 | + |
| 58 | + # Test FHIR capability statement (required for Inferno) |
| 59 | + echo "Testing FHIR capability statement..." |
| 60 | + if curl -f -H "Accept: application/fhir+json" "${{ inputs.fhir_server_url }}/metadata" > testing/${{ inputs.test_stage }}/reports/inferno/capability_statement.json; then |
| 61 | + echo "β
FHIR capability statement retrieved" |
| 62 | + else |
| 63 | + echo "β Failed to retrieve FHIR capability statement" |
| 64 | + exit 1 |
| 65 | + fi |
| 66 | + |
| 67 | + # Test SMART configuration (required for ONC certification) |
| 68 | + echo "Testing SMART configuration..." |
| 69 | + if curl -f -H "Accept: application/json" "${{ inputs.fhir_server_url }}/.well-known/smart_configuration" > testing/${{ inputs.test_stage }}/reports/inferno/smart_configuration.json; then |
| 70 | + echo "β
SMART configuration retrieved" |
| 71 | + else |
| 72 | + echo "β οΈ SMART configuration not available (may be expected for some implementations)" |
| 73 | + fi |
| 74 | +
|
| 75 | + - name: Run Inferno ONC tests |
| 76 | + id: run-tests |
| 77 | + shell: bash |
| 78 | + run: | |
| 79 | + echo "π₯ Starting Inferno ONC Program Edition tests for ${{ inputs.test_stage }}..." |
| 80 | + |
| 81 | + # Create test session via Inferno API |
| 82 | + echo "Creating new test session..." |
| 83 | + SESSION_RESPONSE=$(curl -X POST http://localhost:4567/api/test_sessions \ |
| 84 | + -H "Content-Type: application/json" \ |
| 85 | + -d @${{ inputs.test_config_path }} \ |
| 86 | + --fail --silent --show-error) || { |
| 87 | + echo "β Failed to create Inferno test session" |
| 88 | + echo "Response: $SESSION_RESPONSE" |
| 89 | + exit 1 |
| 90 | + } |
| 91 | + |
| 92 | + # Extract session ID from response |
| 93 | + SESSION_ID=$(echo "$SESSION_RESPONSE" | jq -r '.id // empty') |
| 94 | + if [ -z "$SESSION_ID" ]; then |
| 95 | + echo "β Failed to extract session ID from response" |
| 96 | + echo "Response: $SESSION_RESPONSE" |
| 97 | + exit 1 |
| 98 | + fi |
| 99 | + |
| 100 | + echo "session_id=$SESSION_ID" >> $GITHUB_OUTPUT |
| 101 | + echo "results_path=testing/${{ inputs.test_stage }}/reports/inferno" >> $GITHUB_OUTPUT |
| 102 | + echo "β
Test session created with ID: $SESSION_ID" |
| 103 | + |
| 104 | + # Start the test execution |
| 105 | + echo "Starting test execution..." |
| 106 | + curl -X POST "http://localhost:4567/api/test_sessions/$SESSION_ID/start" \ |
| 107 | + -H "Content-Type: application/json" \ |
| 108 | + --fail || { |
| 109 | + echo "β Failed to start test execution" |
| 110 | + exit 1 |
| 111 | + } |
| 112 | + |
| 113 | + # Monitor test progress |
| 114 | + echo "β³ Monitoring test progress..." |
| 115 | + start_time=$(date +%s) |
| 116 | + timeout_time=$((start_time + ${{ inputs.test_timeout }})) |
| 117 | + |
| 118 | + while [ $(date +%s) -lt $timeout_time ]; do |
| 119 | + # Check test session status |
| 120 | + STATUS_RESPONSE=$(curl -s "http://localhost:4567/api/test_sessions/$SESSION_ID" || echo "{}") |
| 121 | + STATUS=$(echo "$STATUS_RESPONSE" | jq -r '.status // "unknown"') |
| 122 | + |
| 123 | + case "$STATUS" in |
| 124 | + "completed") |
| 125 | + echo "β
Tests completed successfully" |
| 126 | + break |
| 127 | + ;; |
| 128 | + "failed"|"error") |
| 129 | + echo "β Tests failed or encountered an error" |
| 130 | + echo "Status response: $STATUS_RESPONSE" |
| 131 | + break |
| 132 | + ;; |
| 133 | + "running"|"started") |
| 134 | + echo "π Tests still running... ($(date))" |
| 135 | + sleep 30 |
| 136 | + ;; |
| 137 | + *) |
| 138 | + echo "β οΈ Unknown status: $STATUS" |
| 139 | + sleep 30 |
| 140 | + ;; |
| 141 | + esac |
| 142 | + done |
| 143 | + |
| 144 | + # Final status check |
| 145 | + FINAL_STATUS=$(curl -s "http://localhost:4567/api/test_sessions/$SESSION_ID" | jq -r '.status // "timeout"') |
| 146 | + if [ "$FINAL_STATUS" != "completed" ]; then |
| 147 | + echo "β οΈ Tests did not complete successfully. Final status: $FINAL_STATUS" |
| 148 | + fi |
| 149 | + |
| 150 | + echo "π Downloading test results..." |
| 151 | + # Download test results |
| 152 | + curl -s "http://localhost:4567/api/test_sessions/$SESSION_ID/results" > testing/${{ inputs.test_stage }}/reports/inferno/test_results.json |
| 153 | + curl -s "http://localhost:4567/api/test_sessions/$SESSION_ID/report" > testing/${{ inputs.test_stage }}/reports/inferno/test_report.html |
| 154 | +
|
| 155 | + - name: Analyze test results |
| 156 | + id: analyze-results |
| 157 | + shell: bash |
| 158 | + run: | |
| 159 | + echo "π Analyzing Inferno test results..." |
| 160 | + |
| 161 | + RESULTS_FILE="testing/${{ inputs.test_stage }}/reports/inferno/test_results.json" |
| 162 | + |
| 163 | + if [ ! -f "$RESULTS_FILE" ]; then |
| 164 | + echo "β Test results file not found" |
| 165 | + echo "status=failed" >> $GITHUB_OUTPUT |
| 166 | + exit 1 |
| 167 | + fi |
| 168 | + |
| 169 | + # Parse test results |
| 170 | + TOTAL_TESTS=$(jq '.test_results | length // 0' "$RESULTS_FILE") |
| 171 | + PASSED_TESTS=$(jq '[.test_results[] | select(.result == "pass")] | length // 0' "$RESULTS_FILE") |
| 172 | + FAILED_TESTS=$(jq '[.test_results[] | select(.result == "fail")] | length // 0' "$RESULTS_FILE") |
| 173 | + SKIPPED_TESTS=$(jq '[.test_results[] | select(.result == "skip")] | length // 0' "$RESULTS_FILE") |
| 174 | + |
| 175 | + echo "π Test Results Summary:" |
| 176 | + echo " Total: $TOTAL_TESTS" |
| 177 | + echo " Passed: $PASSED_TESTS" |
| 178 | + echo " Failed: $FAILED_TESTS" |
| 179 | + echo " Skipped: $SKIPPED_TESTS" |
| 180 | + |
| 181 | + # Determine overall status |
| 182 | + if [ "$FAILED_TESTS" -eq 0 ] && [ "$PASSED_TESTS" -gt 0 ]; then |
| 183 | + OVERALL_STATUS="passed" |
| 184 | + echo "β
All tests passed!" |
| 185 | + elif [ "$FAILED_TESTS" -gt 0 ]; then |
| 186 | + OVERALL_STATUS="failed" |
| 187 | + echo "β Some tests failed" |
| 188 | + else |
| 189 | + OVERALL_STATUS="unknown" |
| 190 | + echo "β οΈ No clear test results" |
| 191 | + fi |
| 192 | + |
| 193 | + echo "status=$OVERALL_STATUS" >> $GITHUB_OUTPUT |
| 194 | +
|
| 195 | + - name: Generate compliance report |
| 196 | + shell: bash |
| 197 | + run: | |
| 198 | + echo "π Generating compliance report..." |
| 199 | + |
| 200 | + REPORT_FILE="testing/${{ inputs.test_stage }}/reports/inferno/compliance_report.md" |
| 201 | + |
| 202 | + cat > "$REPORT_FILE" << EOF |
| 203 | + # ONC Inferno Compliance Report |
| 204 | + |
| 205 | + **Test Stage**: ${{ inputs.test_stage }} |
| 206 | + **FHIR Server**: ${{ inputs.fhir_server_url }} |
| 207 | + **Test Session ID**: ${{ steps.run-tests.outputs.session_id }} |
| 208 | + **Generated**: $(date -u) |
| 209 | + **Overall Status**: ${{ steps.analyze-results.outputs.status }} |
| 210 | + |
| 211 | + ## Test Configuration |
| 212 | + - **Inferno Module**: ONC Program Edition |
| 213 | + - **Test Focus**: $(jq -r '.inferno.test_focus // "Unknown"' ${{ inputs.test_config_path }}) |
| 214 | + - **Test Sequences**: $(jq -r '.inferno.sequences | length // 0' ${{ inputs.test_config_path }}) sequences configured |
| 215 | + |
| 216 | + ## Results Summary |
| 217 | + - **Test Results**: Available in \`test_results.json\` |
| 218 | + - **HTML Report**: Available in \`test_report.html\` |
| 219 | + - **FHIR Capability**: Available in \`capability_statement.json\` |
| 220 | + - **SMART Config**: Available in \`smart_configuration.json\` |
| 221 | + |
| 222 | + ## Next Steps |
| 223 | + EOF |
| 224 | + |
| 225 | + if [ "${{ steps.analyze-results.outputs.status }}" = "passed" ]; then |
| 226 | + cat >> "$REPORT_FILE" << EOF |
| 227 | + β
**All tests passed** - Ready for ONC certification submission |
| 228 | + |
| 229 | + 1. Review detailed test report in \`test_report.html\` |
| 230 | + 2. Verify all required sequences completed successfully |
| 231 | + 3. Prepare certification documentation |
| 232 | + 4. Submit to ONC for official certification review |
| 233 | + EOF |
| 234 | + else |
| 235 | + cat >> "$REPORT_FILE" << EOF |
| 236 | + β **Some tests failed** - Review and address issues before certification |
| 237 | + |
| 238 | + 1. Review failed tests in \`test_results.json\` |
| 239 | + 2. Check detailed error messages in \`test_report.html\` |
| 240 | + 3. Address compliance gaps in FHIR implementation |
| 241 | + 4. Re-run tests after fixes are implemented |
| 242 | + EOF |
| 243 | + fi |
| 244 | + |
| 245 | + echo "β
Compliance report generated at $REPORT_FILE" |
| 246 | +
|
| 247 | + - name: Export container logs |
| 248 | + if: always() |
| 249 | + shell: bash |
| 250 | + run: | |
| 251 | + echo "π Exporting Inferno container logs..." |
| 252 | + docker logs "${{ inputs.inferno_container_id }}" > testing/${{ inputs.test_stage }}/reports/inferno/inferno_container.log 2>&1 || true |
| 253 | + echo "β
Container logs exported" |
| 254 | +
|
| 255 | + - name: Cleanup Inferno container |
| 256 | + if: always() |
| 257 | + shell: bash |
| 258 | + run: | |
| 259 | + echo "π§Ή Cleaning up Inferno container..." |
| 260 | + docker stop "${{ inputs.inferno_container_id }}" || true |
| 261 | + docker rm "${{ inputs.inferno_container_id }}" || true |
| 262 | + echo "β
Inferno container cleaned up" |
0 commit comments