test-dispatch-with-artifacts #15
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
| name: "Home-CI External Test Results Processing" | |
| on: | |
| repository_dispatch: | |
| types: [dispatch-with-artifacts, test-dispatch-with-artifacts] | |
| jobs: | |
| process-test-results: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Install yq | |
| run: | | |
| sudo apt-get update && sudo apt-get install -y python3-pip | |
| pip3 install yq | |
| - name: Display test metadata | |
| run: | | |
| echo "๐ Processing test results from home-ci" | |
| echo "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ" | |
| echo "๐ Branch: ${{ github.event.client_payload.branch }}" | |
| echo "๐ Commit: ${{ github.event.client_payload.commit }}" | |
| echo "๐ Success: ${{ github.event.client_payload.success }}" | |
| echo "๐ Source: ${{ github.event.client_payload.source }}" | |
| echo "๐ Timestamp: ${{ github.event.client_payload.timestamp }}" | |
| echo "๐ Artifact: ${{ github.event.client_payload.artifact_name }}" | |
| echo "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ" | |
| - name: Process test logs | |
| run: | | |
| echo "๐ Processing test execution logs..." | |
| # Check if artifacts exist and process them | |
| if [ "${{ toJson(github.event.client_payload.artifacts) }}" != "null" ]; then | |
| echo "โ Test artifacts found" | |
| # Create artifacts directory | |
| mkdir -p test-artifacts | |
| # List available artifacts | |
| echo "๐ฆ Available artifacts:" | |
| echo '${{ toJson(github.event.client_payload.artifacts) }}' | jq -r 'keys[]' | while read artifact; do | |
| echo " - $artifact" | |
| done | |
| else | |
| echo "โ ๏ธ No artifacts found in payload" | |
| fi | |
| - name: Process e2e test report | |
| if: github.event.client_payload.artifacts | |
| run: | | |
| echo "๐ Processing e2e test report..." | |
| # Extract YAML e2e report files | |
| echo '${{ toJson(github.event.client_payload.artifacts) }}' | jq -r ' | |
| to_entries[] | | |
| select(.key | endswith("-e2e-report.yaml")) | | |
| "REPORT_FILE=\(.key)\nREPORT_CONTENT=\(.value.content)" | |
| ' > report_vars.env | |
| if [ -f report_vars.env ] && [ -s report_vars.env ]; then | |
| source report_vars.env | |
| # Decode and save e2e report content | |
| if [ ! -z "$REPORT_CONTENT" ] && [ "$REPORT_CONTENT" != "null" ]; then | |
| echo "$REPORT_CONTENT" | base64 -d > "test-artifacts/$REPORT_FILE" | |
| echo "โ Saved e2e report: test-artifacts/$REPORT_FILE" | |
| # Parse and display e2e report information | |
| echo "" | |
| echo "๐งช E2E Test Report Summary:" | |
| echo "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ" | |
| # Extract general info using yq (if available) or basic grep/awk | |
| if command -v yq >/dev/null 2>&1; then | |
| echo "๐ Test Run Info:" | |
| echo " Start time: $(yq '.test_run.start_time' test-artifacts/$REPORT_FILE 2>/dev/null | tr -d '"' || echo 'N/A')" | |
| echo " Runner: $(yq '.test_run.runner' test-artifacts/$REPORT_FILE 2>/dev/null | tr -d '"' || echo 'N/A')" | |
| echo " OS: $(yq '.environment.os' test-artifacts/$REPORT_FILE 2>/dev/null | tr -d '"' || echo 'N/A')" | |
| echo " Architecture: $(yq '.environment.arch' test-artifacts/$REPORT_FILE 2>/dev/null | tr -d '"' || echo 'N/A')" | |
| echo "" | |
| echo "๐ Test Summary:" | |
| echo " End time: $(yq '.summary.end_time' test-artifacts/$REPORT_FILE 2>/dev/null | tr -d '"' || echo 'N/A')" | |
| echo " Duration: $(yq '.summary.duration_seconds' test-artifacts/$REPORT_FILE 2>/dev/null | tr -d '"' || echo 'N/A') seconds" | |
| echo " Overall status: $(yq '.summary.overall_status' test-artifacts/$REPORT_FILE 2>/dev/null | tr -d '"' || echo 'N/A')" | |
| echo " Success rate: $(yq '.summary.success_rate' test-artifacts/$REPORT_FILE 2>/dev/null | tr -d '"' || echo 'N/A')" | |
| echo " Total steps: $(yq '.summary.total_steps' test-artifacts/$REPORT_FILE 2>/dev/null | tr -d '"' || echo 'N/A')" | |
| echo " Passed steps: $(yq '.summary.passed_steps' test-artifacts/$REPORT_FILE 2>/dev/null | tr -d '"' || echo 'N/A')" | |
| echo " Failed steps: $(yq '.summary.failed_steps' test-artifacts/$REPORT_FILE 2>/dev/null | tr -d '"' || echo 'N/A')" | |
| echo "" | |
| echo "๐ Test Steps:" | |
| yq '.steps[] | " " + .phase + ": " + .status + " (" + .timestamp + ")"' test-artifacts/$REPORT_FILE 2>/dev/null | tr -d '"' || echo " Unable to parse steps" | |
| else | |
| echo "โ ๏ธ yq not available, showing raw summary info" | |
| grep -A 10 "summary:" test-artifacts/$REPORT_FILE || echo " Unable to extract summary" | |
| fi | |
| else | |
| echo "โ ๏ธ E2E report content is empty or null" | |
| fi | |
| else | |
| echo "โน๏ธ No e2e report files found in artifacts" | |
| fi | |
| - name: Decode and save test logs | |
| if: github.event.client_payload.artifacts | |
| run: | | |
| echo "๐พ Extracting test logs..." | |
| # Extract log files (find files with .log extension in artifacts) | |
| echo '${{ toJson(github.event.client_payload.artifacts) }}' | jq -r ' | |
| to_entries[] | | |
| select(.key | endswith(".log")) | | |
| "LOG_FILE=\(.key)\nLOG_CONTENT=\(.value.content)" | |
| ' > log_vars.env | |
| if [ -f log_vars.env ] && [ -s log_vars.env ]; then | |
| source log_vars.env | |
| # Decode and save log content | |
| if [ ! -z "$LOG_CONTENT" ] && [ "$LOG_CONTENT" != "null" ]; then | |
| echo "$LOG_CONTENT" | base64 -d > "test-artifacts/$LOG_FILE" | |
| echo "โ Saved log file: test-artifacts/$LOG_FILE" | |
| # Show log summary | |
| echo "" | |
| echo "๐ Log file summary:" | |
| echo " Size: $(wc -c < test-artifacts/$LOG_FILE) bytes" | |
| echo " Lines: $(wc -l < test-artifacts/$LOG_FILE) lines" | |
| else | |
| echo "โ ๏ธ Log content is empty or null" | |
| fi | |
| else | |
| echo "โน๏ธ No log files found in artifacts" | |
| fi | |
| - name: Create test result summary | |
| run: | | |
| echo "๐ Creating test result summary..." | |
| # Determine status emoji and message | |
| if [ "${{ github.event.client_payload.success }}" == "true" ]; then | |
| STATUS_EMOJI="โ " | |
| STATUS_MSG="SUCCESS" | |
| STATUS_COLOR="๐ข" | |
| else | |
| STATUS_EMOJI="โ" | |
| STATUS_MSG="FAILURE" | |
| STATUS_COLOR="๐ด" | |
| fi | |
| echo "" | |
| echo "โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ" | |
| echo "โ TEST RESULT SUMMARY โ" | |
| echo "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค" | |
| echo "โ Status: $STATUS_COLOR $STATUS_EMOJI $STATUS_MSG" | |
| echo "โ Branch: ${{ github.event.client_payload.branch }}" | |
| echo "โ Commit: ${{ github.event.client_payload.commit }}" | |
| echo "โ Source: ${{ github.event.client_payload.source }}" | |
| echo "โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ" | |
| # Show test steps if available | |
| if [ -d test-artifacts ]; then | |
| REPORT_FILE=$(find test-artifacts -name "*-e2e-report.yaml" | head -1) | |
| if [ -f "$REPORT_FILE" ] && command -v yq >/dev/null 2>&1; then | |
| echo "" | |
| echo "๐ Test Steps Summary:" | |
| yq '.steps[] | " " + .phase + ": " + .status + " (" + .timestamp + ")"' "$REPORT_FILE" 2>/dev/null | tr -d '"' || echo " No steps data available" | |
| fi | |
| fi | |
| # Create summary for GitHub Actions summary | |
| { | |
| echo "## $STATUS_EMOJI External Test Results - $STATUS_MSG" | |
| echo "" | |
| echo "**Test Details:**" | |
| echo "- **Status**: $STATUS_EMOJI $STATUS_MSG" | |
| echo "- **Branch**: \`${{ github.event.client_payload.branch }}\`" | |
| echo "- **Commit**: \`${{ github.event.client_payload.commit }}\`" | |
| echo "- **Source**: ${{ github.event.client_payload.source }}" | |
| echo "- **Timestamp**: $(date -d @${{ github.event.client_payload.timestamp }} 2>/dev/null || echo "${{ github.event.client_payload.timestamp }}")" | |
| echo "" | |
| echo "**Artifact**: ${{ github.event.client_payload.artifact_name }}" | |
| # Add test steps to GitHub summary if available | |
| if [ -d test-artifacts ]; then | |
| REPORT_FILE=$(find test-artifacts -name "*-e2e-report.yaml" | head -1) | |
| if [ -f "$REPORT_FILE" ] && command -v yq >/dev/null 2>&1; then | |
| echo "" | |
| echo "### ๐ Test Steps" | |
| echo "" | |
| yq '.steps[] | "- **" + .phase + "**: " + .status + " _(" + .timestamp + ")_"' "$REPORT_FILE" 2>/dev/null | tr -d '"' || echo "No steps data available" | |
| fi | |
| fi | |
| } >> $GITHUB_STEP_SUMMARY | |
| - name: Upload artifacts | |
| if: github.event.client_payload.artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: external-test-results-${{ github.event.client_payload.artifact_name }} | |
| path: test-artifacts/ | |
| retention-days: 30 |