Skip to content

Commit

Permalink
9pm: add new result file with github emojis
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Alpe <[email protected]>
  • Loading branch information
rical committed Oct 2, 2023
1 parent 817d089 commit d80f8cf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
run: python3 9pm.py --option cmdl-supplied unit_tests/auto.yaml

- name: Publish Test Result
run: cat ~/9pm_log/last/result.md >> $GITHUB_STEP_SUMMARY
run: cat ~/9pm_log/last/result-gh.md >> $GITHUB_STEP_SUMMARY
33 changes: 28 additions & 5 deletions 9pm.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,20 +240,43 @@ def parse_suite(fpath, pname, options, name=None):
sys.exit(1)
return suite

def write_result_md_tree(md, data, base):
def get_github_emoji(result):
if result == "pass":
return ":white_check_mark:"
if result == "fail":
return ":red_circle:"
if result == "skip":
return ":large_orange_diamond:"
if result == "masked-fail":
return ":o:"
if result == "masked-skip":
return ":small_orange_diamond:"

return result

def write_result_md_tree(md, gh, data, base):
for test in data['suite']:
with open(md, 'a') as file:
file.write("{}- {} : {}\n".format(base, test['result'].upper(), test['name']))

with open(gh, 'a') as file:
mark = get_github_emoji(test['result'])
file.write("{}- {} : {}\n".format(base, mark, test['name']))

if 'suite' in test:
write_result_md_tree(md, test, base + " ")
write_result_md_tree(md, gh, test, base + " ")

def write_result_md(data):
def write_result_files(data):
md = os.path.join(LOGDIR, 'result.md')
gh = os.path.join(LOGDIR, 'result-gh.md')

with open(md, 'a') as file:
file.write("# Test Result\n")
write_result_md_tree(md, data, "")

with open(gh, 'a') as file:
file.write("# Test Result\n")

write_result_md_tree(md, gh, data, "")

def print_result_tree(data, base):
i = 1
Expand Down Expand Up @@ -509,7 +532,7 @@ def main():
cprint(pcolor.green, "\no Execution")

print_result_tree(cmdl, "")
write_result_md(cmdl)
write_result_files(cmdl)

db.close()
sys.exit(err)
Expand Down

0 comments on commit d80f8cf

Please sign in to comment.