1
1
#!/usr/bin/env python3
2
2
import argparse
3
3
import dataclasses
4
- import datetime
5
- import json
6
4
import os
7
- import re
8
5
import sys
9
6
import traceback
10
- from github import Github , Auth as GithubAuth
11
- from github .PullRequest import PullRequest
12
7
from enum import Enum
13
8
from operator import attrgetter
14
- from typing import List , Optional , Dict
9
+ from typing import List , Dict
15
10
from jinja2 import Environment , FileSystemLoader , StrictUndefined
16
11
from junit_utils import get_property_value , iter_xml_files
17
- from gh_status import update_pr_comment_text
18
12
from get_test_history import get_test_history
19
13
20
14
@@ -328,7 +322,7 @@ def gen_summary(public_dir, public_dir_url, paths, is_retry: bool, build_preset)
328
322
return summary
329
323
330
324
331
- def get_comment_text (pr : PullRequest , summary : TestSummary , summary_links : str , is_last_retry : bool )-> tuple [str , list [str ]]:
325
+ def get_comment_text (summary : TestSummary , summary_links : str , is_last_retry : bool )-> tuple [str , list [str ]]:
332
326
color = "red"
333
327
if summary .is_failed :
334
328
color = "red" if is_last_retry else "yellow"
@@ -379,6 +373,8 @@ def main():
379
373
parser .add_argument ('--status_report_file' , required = False )
380
374
parser .add_argument ('--is_retry' , required = True , type = int )
381
375
parser .add_argument ('--is_last_retry' , required = True , type = int )
376
+ parser .add_argument ('--comment_color_file' , required = True )
377
+ parser .add_argument ('--comment_text_file' , required = True )
382
378
parser .add_argument ("args" , nargs = "+" , metavar = "TITLE html_out path" )
383
379
args = parser .parse_args ()
384
380
@@ -397,21 +393,17 @@ def main():
397
393
else :
398
394
overall_status = "success"
399
395
400
- if os .environ .get ("GITHUB_EVENT_NAME" ) in ("pull_request" , "pull_request_target" ):
401
- gh = Github (auth = GithubAuth .Token (os .environ ["GITHUB_TOKEN" ]))
402
- run_number = int (os .environ .get ("GITHUB_RUN_NUMBER" ))
396
+ color , text = get_comment_text (summary , args .summary_links , is_last_retry = bool (args .is_last_retry ))
403
397
404
- with open (os . environ [ "GITHUB_EVENT_PATH" ] ) as fp :
405
- event = json . load ( fp )
398
+ with open (args . comment_color_file , "w" ) as f :
399
+ f . write ( color )
406
400
407
- pr = gh .create_from_raw_data (PullRequest , event ["pull_request" ])
408
- color , text = get_comment_text (pr , summary , args .summary_links , is_last_retry = bool (args .is_last_retry ))
401
+ with open (args .comment_text_file , "w" ) as f :
402
+ f .write ('\n ' .join (text ))
403
+ f .write ('\n ' )
409
404
410
- update_pr_comment_text (pr , args .build_preset , run_number , color , text = '\n ' .join (text ), rewrite = False )
411
-
412
- if args .status_report_file :
413
- with open (args .status_report_file , 'w' ) as fo :
414
- fo .write (overall_status )
405
+ with open (args .status_report_file , "w" ) as f :
406
+ f .write (overall_status )
415
407
416
408
417
409
if __name__ == "__main__" :
0 commit comments