File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- FROM williamfzc/srctx:v0.4.1
1+ FROM williamfzc/srctx:v0.4.2
22
3- RUN apk add --no-cache python3 py3-pip
3+ RUN apk add --no-cache python3 py3-pip graphviz
44
55COPY . /action_internal
66
Original file line number Diff line number Diff line change 1+ import base64
12import csv
23import json
34import os
1516support_langs = {"golang" , "python" }
1617csv_result_file = "./output.csv"
1718json_result_file = "./output.json"
19+ dot_result_file = "./output.dot"
1820
1921
2022def gen_index (lang : str ):
@@ -64,6 +66,8 @@ def gen_diff(before_sha: str, after_sha: str):
6466 csv_result_file ,
6567 "--outputJson" ,
6668 json_result_file ,
69+ "--outputDot" ,
70+ dot_result_file ,
6771 ]
6872 )
6973
@@ -132,6 +136,13 @@ def format_percentage(numerator, denominator):
132136 writer .writerow (row )
133137
134138
139+ def dot_to_svg_tag (dot_file ):
140+ svg_bytes = subprocess .check_output (["dot" , "-Tsvg" , dot_file ])
141+ svg_base64 = base64 .b64encode (svg_bytes ).decode ()
142+ svg = f'<img src="data:image/svg+xml;base64,{ svg_base64 } "/>'
143+ return svg
144+
145+
135146def main ():
136147 args = sys .argv [1 :]
137148 lang = args [0 ]
@@ -172,12 +183,15 @@ def main():
172183 logger .info (f"ai resp: { ai_content } " )
173184
174185 repo_name = os .getenv ("GITHUB_REPOSITORY" )
175- process_json (csv_result_file )
186+ process_json (json_result_file , csv_result_file )
176187 md_table_raw = convert_csv_to_md (csv_result_file )
188+ svg_tag = dot_to_svg_tag (dot_result_file )
177189
178190 final_content = f"""
179191## [DiffCtx](https://github.com/williamfzc/diffctx) Report
180192
193+ { svg_tag }
194+
181195{ md_table_raw }
182196"""
183197 logger .info (f"final comment: { final_content } " )
You can’t perform that action at this time.
0 commit comments