-
Notifications
You must be signed in to change notification settings - Fork 124
chore: Add github step summaries for e2e test suites #2670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
chmouel
wants to merge
2
commits into
tektoncd:main
Choose a base branch
from
chmouel:add-github-step-summary
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+136
β2
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| #!/usr/bin/env python3 | ||
| """Parse gotestsum JSON output and generate a GitHub Step Summary in markdown.""" | ||
|
|
||
| import collections | ||
| import json | ||
| import sys | ||
|
|
||
|
|
||
| def main(): | ||
| if len(sys.argv) != 3: | ||
| print(f"Usage: {sys.argv[0]} <json-file> <provider-name>", file=sys.stderr) | ||
| sys.exit(1) | ||
|
|
||
| json_file = sys.argv[1] | ||
| target = sys.argv[2] | ||
|
|
||
| results = {} # test_name -> {action, elapsed} | ||
| test_output = collections.defaultdict(list) | ||
|
|
||
| with open(json_file) as fh: | ||
| for line in fh: | ||
| line = line.strip() | ||
| if not line: | ||
| continue | ||
| try: | ||
| entry = json.loads(line) | ||
| except json.JSONDecodeError: | ||
| continue | ||
| test = entry.get("Test") | ||
| if not test: | ||
| continue | ||
| action = entry.get("Action", "") | ||
| if action == "output": | ||
| test_output[test].append(entry.get("Output", "")) | ||
| elif action in ("pass", "fail", "skip"): | ||
| results[test] = { | ||
| "action": action, | ||
| "elapsed": entry.get("Elapsed", 0), | ||
| } | ||
|
|
||
| passed = sorted([t for t, r in results.items() if r["action"] == "pass"]) | ||
| failed = sorted([t for t, r in results.items() if r["action"] == "fail"]) | ||
| skipped = sorted([t for t, r in results.items() if r["action"] == "skip"]) | ||
|
|
||
| # Filter to top-level tests only (no subtests) for counts | ||
| top_passed = [t for t in passed if "/" not in t] | ||
| top_failed = [t for t in failed if "/" not in t] | ||
| top_skipped = [t for t in skipped if "/" not in t] | ||
|
|
||
| status = ":x: FAILED" if top_failed else ":white_check_mark: PASSED" | ||
|
|
||
| lines = [] | ||
| lines.append(f"## E2E Tests: {target} {status}") | ||
| lines.append("") | ||
| lines.append( | ||
| f":white_check_mark: **{len(top_passed)}** passed" | ||
| f" | :x: **{len(top_failed)}** failed" | ||
| f" | :fast_forward: **{len(top_skipped)}** skipped" | ||
| ) | ||
| lines.append("") | ||
|
|
||
| if top_failed: | ||
| lines.append("### Failed Tests") | ||
| lines.append("") | ||
| for t in top_failed: | ||
| elapsed = results[t]["elapsed"] | ||
| lines.append(f"<details><summary>:x: {t} ({elapsed:.1f}s)</summary>") | ||
| lines.append("") | ||
| lines.append("```") | ||
| output = "".join(test_output.get(t, [])) | ||
| # Include subtest output too | ||
| for sub, r in sorted(results.items()): | ||
| if sub.startswith(t + "/") and r["action"] == "fail": | ||
| output += "".join(test_output.get(sub, [])) | ||
| lines.append(output.rstrip()) | ||
| lines.append("```") | ||
| lines.append("") | ||
| lines.append("</details>") | ||
| lines.append("") | ||
chmouel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if top_passed: | ||
| lines.append("<details><summary>Passed Tests</summary>") | ||
| lines.append("") | ||
| for t in top_passed: | ||
| elapsed = results[t]["elapsed"] | ||
| lines.append(f"- :white_check_mark: {t} ({elapsed:.1f}s)") | ||
| lines.append("") | ||
| lines.append("</details>") | ||
| lines.append("") | ||
|
|
||
| if top_skipped: | ||
| lines.append("<details><summary>Skipped Tests</summary>") | ||
| lines.append("") | ||
| for t in top_skipped: | ||
| lines.append(f"- :fast_forward: {t}") | ||
| lines.append("") | ||
| lines.append("</details>") | ||
|
|
||
| print("\n".join(lines)) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.