Skip to content

Commit 66c3cb2

Browse files
committed
Add test results JSON
1 parent 319f31a commit 66c3cb2

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed
File renamed without changes.
File renamed without changes.

runtime-tests-results/table_generator.py renamed to runtime-test-results/table_generator.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,22 @@
1212
data = json.load(f)
1313
tests = sorted(data["stats"]["suite_details"], key=lambda x: x["name"])
1414

15+
# Get commit SHA from command line argument or environment variable
16+
commit_sha = None
17+
if len(sys.argv) < 2 or len(sys.argv) > 3:
18+
print("Usage: python table_generator.py <test_results.json> [commit_sha]")
19+
sys.exit(1)
20+
elif len(sys.argv) == 3: # Commit SHA is provided as argument
21+
commit_sha = sys.argv[2]
22+
elif "GITHUB_SHA" in os.environ: # Commit SHA is provided as environment variable
23+
commit_sha = os.environ["GITHUB_SHA"]
24+
else: # Commit SHA is not provided
25+
print("Commit SHA is not provided. Please provide it as an argument or set the GITHUB_SHA environment variable.")
26+
sys.exit(1)
27+
1528
# Generate the table
1629

17-
print("## Runtime Tests Report")
30+
print("## Runtime Test Results")
1831
print("")
1932

2033
try:
@@ -99,6 +112,21 @@
99112
print("")
100113

101114
try:
102-
print(f"[Build, Hardware and QEMU run](https://github.com/{os.environ['GITHUB_REPOSITORY']}/actions/runs/{os.environ['BUILD_RUN_ID']}) / [Wokwi run](https://github.com/{os.environ['GITHUB_REPOSITORY']}/actions/runs/{os.environ['WOKWI_RUN_ID']})")
115+
print(f"[Commit](https://github.com/{os.environ['GITHUB_REPOSITORY']}/commit/{commit_sha}) / [Build, Hardware and QEMU run](https://github.com/{os.environ['GITHUB_REPOSITORY']}/actions/runs/{os.environ['BUILD_RUN_ID']}) / [Wokwi run](https://github.com/{os.environ['GITHUB_REPOSITORY']}/actions/runs/{os.environ['WOKWI_RUN_ID']})")
103116
except KeyError:
104117
pass
118+
119+
# Save test results to JSON file
120+
results_data = {
121+
"commit_sha": commit_sha,
122+
"tests_failed": os.environ["IS_FAILING"] == "true",
123+
"test_data": proc_test_data,
124+
"generated_at": datetime.now().isoformat()
125+
}
126+
127+
with open("test_results.json", "w") as f:
128+
json.dump(results_data, f, indent=2)
129+
130+
print(f"\nTest results saved to test_results.json")
131+
print(f"Commit SHA: {commit_sha}")
132+
print(f"Tests failed: {results_data['tests_failed']}")

0 commit comments

Comments
 (0)