|
25 | 25 |
|
26 | 26 | permissions: |
27 | 27 | contents: read |
28 | | - actions: read |
29 | | - checks: write |
30 | 28 |
|
31 | 29 | jobs: |
32 | 30 | cli-e2e: |
@@ -67,17 +65,71 @@ jobs: |
67 | 65 | echo "No CLI E2E packages to test after exclusions." |
68 | 66 | exit 1 |
69 | 67 | fi |
70 | | - # gotestsum requires --packages when --rerun-fails is combined with go test args after --. |
71 | | - packages_arg=$(printf '%s\n' "$packages" | paste -sd' ' -) |
72 | | - go run gotest.tools/gotestsum@v1.12.3 --rerun-fails=2 --rerun-fails-max-failures=20 --packages="$packages_arg" --format testname --junitfile cli-e2e-report.xml -- -count=1 -v |
| 68 | + go run gotest.tools/gotestsum@v1.12.3 --format testname --junitfile cli-e2e-report.xml -- -count=1 -v $packages |
73 | 69 |
|
74 | | - - name: Publish CLI E2E test report |
| 70 | + - name: Summarize CLI E2E test report |
75 | 71 | if: ${{ !cancelled() }} |
76 | | - uses: dorny/test-reporter@a43b3a5f7366b97d083190328d2c652e1a8b6aa2 # v3.0.0 |
77 | | - with: |
78 | | - name: CLI E2E Tests |
79 | | - path: cli-e2e-report.xml |
80 | | - reporter: java-junit |
81 | | - use-actions-summary: true |
82 | | - list-suites: all |
83 | | - list-tests: all |
| 72 | + run: | |
| 73 | + python3 - <<'PY' |
| 74 | + import os |
| 75 | + import xml.etree.ElementTree as ET |
| 76 | +
|
| 77 | + report_path = "cli-e2e-report.xml" |
| 78 | + summary_path = os.environ["GITHUB_STEP_SUMMARY"] |
| 79 | +
|
| 80 | + root = ET.parse(report_path).getroot() |
| 81 | + suites = [root] if root.tag == "testsuite" else root.findall("testsuite") |
| 82 | +
|
| 83 | + tests = failures = errors = skipped = 0 |
| 84 | + failed_cases = [] |
| 85 | + skipped_cases = [] |
| 86 | +
|
| 87 | + for suite in suites: |
| 88 | + tests += int(suite.attrib.get("tests", 0)) |
| 89 | + failures += int(suite.attrib.get("failures", 0)) |
| 90 | + errors += int(suite.attrib.get("errors", 0)) |
| 91 | + skipped += int(suite.attrib.get("skipped", 0)) |
| 92 | +
|
| 93 | + for case in suite.findall("testcase"): |
| 94 | + classname = case.attrib.get("classname", "") |
| 95 | + name = case.attrib.get("name", "") |
| 96 | + label = f"{classname}.{name}" if classname else name |
| 97 | +
|
| 98 | + failure = case.find("failure") |
| 99 | + error = case.find("error") |
| 100 | + skipped_node = case.find("skipped") |
| 101 | +
|
| 102 | + if failure is not None or error is not None: |
| 103 | + message = "" |
| 104 | + node = failure if failure is not None else error |
| 105 | + if node is not None: |
| 106 | + message = node.attrib.get("message", "") or (node.text or "").strip() |
| 107 | + failed_cases.append((label, message)) |
| 108 | + elif skipped_node is not None: |
| 109 | + message = skipped_node.attrib.get("message", "") or (skipped_node.text or "").strip() |
| 110 | + skipped_cases.append((label, message)) |
| 111 | +
|
| 112 | + passed = tests - failures - errors - skipped |
| 113 | +
|
| 114 | + with open(summary_path, "a", encoding="utf-8") as f: |
| 115 | + f.write("## CLI E2E Test Report\n\n") |
| 116 | + f.write(f"- Total: {tests}\n") |
| 117 | + f.write(f"- Passed: {passed}\n") |
| 118 | + f.write(f"- Failed: {failures}\n") |
| 119 | + f.write(f"- Errors: {errors}\n") |
| 120 | + f.write(f"- Skipped: {skipped}\n\n") |
| 121 | +
|
| 122 | + if failed_cases: |
| 123 | + f.write("### Failed Tests\n\n") |
| 124 | + for label, message in failed_cases: |
| 125 | + detail = f" - {message}" if message else "" |
| 126 | + f.write(f"- `{label}`{detail}\n") |
| 127 | + f.write("\n") |
| 128 | +
|
| 129 | + if skipped_cases: |
| 130 | + f.write("### Skipped Tests\n\n") |
| 131 | + for label, message in skipped_cases: |
| 132 | + detail = f" - {message}" if message else "" |
| 133 | + f.write(f"- `{label}`{detail}\n") |
| 134 | + f.write("\n") |
| 135 | + PY |
0 commit comments