-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: use custom test-reporter action to upload job results (#18004)
* ci: use custom action to upload job results
- Loading branch information
Conor
authored
Nov 1, 2022
1 parent
5d34b4e
commit dc15f56
Showing
2 changed files
with
160 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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 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,54 @@ | ||
import argparse | ||
import json | ||
import os | ||
|
||
|
||
''' | ||
This script is intended to be run in conjuction with https://github.com/EnricoMi/publish-unit-test-result-action to upload trimmed | ||
test results from the output to a GCS bucket for further analysis. | ||
The script takes as input the filename of the json output by the aforementioned action, trims it, and writes it out in jsonl format with ".jsonl" filename | ||
''' | ||
|
||
# Initiate the parser | ||
parser = argparse.ArgumentParser() | ||
|
||
# Add long and short argument | ||
parser.add_argument("--json", "-j", help="Path to the result json output by https://github.com/EnricoMi/publish-unit-test-result-action") | ||
|
||
def main(): | ||
# Read arguments from the command line | ||
args = parser.parse_args() | ||
|
||
f = open(args.json) | ||
d = json.load(f) | ||
out = [] | ||
|
||
check_run_id = int(d["check_url"].split("/")[-1]) | ||
|
||
for elem in d['cases']: | ||
for conclusion in ('success', 'failure', 'skipped'): | ||
if conclusion not in elem['states']: | ||
continue | ||
for i in range(len(elem['states'][conclusion])): | ||
output = { | ||
"test_name": elem['states'][conclusion][i]['test_name'], | ||
"class_name": elem['states'][conclusion][i]['class_name'], | ||
"result_file": elem['states'][conclusion][i]['result_file'], | ||
"time": elem['states'][conclusion][i]['time'], | ||
"state": conclusion, | ||
"check_run_id": check_run_id, | ||
"repo": "airbytehq/airbyte" | ||
} | ||
out.append(output) | ||
|
||
with open(args.json + "l", 'w') as f: | ||
for o in out: | ||
json.dump(o, f) | ||
f.write('\n') | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |