1414
1515"""A utility for integration test workflow.
1616
17- This script helps to update PR/Issue comments and labels during testing process.
17+ This script helps to update PR/Issue comments and labels during testing process.
1818
1919For PR comment, this script will update (create if not exist) the "Test Result" in comment.
2020stage value: [start, progress, end]
2727 --run_id ${{github.run_id}} \
2828 [--new_token ${{steps.generate-token.outputs.token}}]
2929
30- For Daily Report, this script will update (create if not exist) the "Test Result" in Issue
30+ For Daily Report, this script will update (create if not exist) the "Test Result" in Issue
3131with title "Nightly Integration Testing Report" and label "nightly-testing".
3232stage value: [report]
3333USAGE:
6161_LABEL_SUCCEED = "tests: succeeded"
6262
6363_COMMENT_TITLE_PROGESS = "### ⏳ Integration test in progress...\n "
64- _COMMENT_TITLE_PROGESS_FLAKY = "### Integration test with FLAKINESS (but still ⏳ in progress)\n "
65- _COMMENT_TITLE_PROGESS_FAIL = "### ❌ Integration test FAILED (but still ⏳ in progress)\n "
64+ _COMMENT_TITLE_PROGESS_FLAKY = "### Integration test with FLAKINESS (but still ⏳ in progress)\n "
65+ _COMMENT_TITLE_PROGESS_FAIL = "### ❌ Integration test FAILED (but still ⏳ in progress)\n "
6666_COMMENT_TITLE_FLAKY = "### Integration test with FLAKINESS (succeeded after retry)\n "
6767_COMMENT_TITLE_FAIL = "### ❌ Integration test FAILED\n "
6868_COMMENT_TITLE_SUCCEED = "### ✅ Integration test succeeded!\n "
8181_COMMENT_IDENTIFIER = "integration-test-status-comment"
8282_COMMENT_HIDDEN_DIVIDER = f'\r \n <hidden value="{ _COMMENT_IDENTIFIER } "></hidden>\r \n '
8383
84- _COMMENT_IDENTIFIER_DASHBOARD = "build-dashboard-comment"
85- _COMMENT_DASHBOARD_START = f'\r \n <hidden value="{ _COMMENT_IDENTIFIER_DASHBOARD } "-start></hidden>\r \n '
86- _COMMENT_DASHBOARD_END = f'\r \n <hidden value="{ _COMMENT_IDENTIFIER_DASHBOARD } "-end></hidden>\r \n '
87-
8884_LOG_ARTIFACT_NAME = "log-artifact"
8985_LOG_OUTPUT_DIR = "test_results"
9086
109105 "Different stage while running the workflow. Valid values in _BUILD_STAGES." )
110106
111107flags .DEFINE_string (
112- "token" , None ,
108+ "token" , None ,
113109 "github.token: A token to authenticate on your repository." )
114110
115111flags .DEFINE_string (
131127 "new_token" , None ,
132128 "Only used with --stage end"
133129 "Use a different token to remove the \" in-progress\" label,"
134- "to allow the removal to trigger the \" Check Labels\" workflow." )
130+ "to allow the removal to trigger the \" Check Labels\" workflow." )
135131
136132flags .DEFINE_string (
137133 "build_against" , None ,
@@ -155,7 +151,7 @@ def test_start(token, issue_number, actor, commit, run_id):
155151
156152
157153def test_progress (token , issue_number , actor , commit , run_id ):
158- """In PR, when some test failed, update failure info and
154+ """In PR, when some test failed, update failure info and
159155 add label \" tests: failed\" """
160156 success_or_only_flakiness , log_summary = _get_summary_table (token , run_id )
161157 if success_or_only_flakiness and not log_summary :
@@ -178,7 +174,7 @@ def test_progress(token, issue_number, actor, commit, run_id):
178174
179175
180176def test_end (token , issue_number , actor , commit , run_id , new_token ):
181- """In PR, when some test end, update Test Result Report and
177+ """In PR, when some test end, update Test Result Report and
182178 update label: add \" tests: failed\" if test failed, add label
183179 \" tests: succeeded\" if test succeed"""
184180 success_or_only_flakiness , log_summary = _get_summary_table (token , run_id )
@@ -209,14 +205,11 @@ def test_end(token, issue_number, actor, commit, run_id, new_token):
209205
210206
211207def test_report (token , actor , commit , run_id , build_against , build_apis ):
212- """Update (create if not exist) a Daily/Nightly Report in Issue.
208+ """Update (create if not exist) a Daily/Nightly Report in Issue.
213209 The Issue with title _REPORT_TITLE and label _REPORT_LABEL:
214210 https://github.com/firebase/firebase-cpp-sdk/issues?q=is%3Aissue+label%3Anightly-testing
215211 The report is with the format below:
216212 PREFIX
217- HIDDEN DASHBOARD START - optional
218- BUILD DASHBOARD - optional
219- HIDDEN DASHBOARD END - optional
220213 HIDDEN DIVIDER
221214 REPORT (TEST AGAINST REPO)
222215 HIDDEN DIVIDER
@@ -229,24 +222,16 @@ def test_report(token, actor, commit, run_id, build_against, build_apis):
229222 report_title = _REPORT_TITLE
230223 firestore_issue_number = _get_issue_number (token , _REPORT_TITLE_FIRESTORE , _REPORT_LABEL )
231224 firestore_issue_url = "https://github.com/firebase/firebase-cpp-sdk/issues/%s" % firestore_issue_number
232- prefix = "Note: This report excludes Firestore . Please also check **[the report for Firestore ](%s). **\n ***\n " % firestore_issue_url
225+ prefix = "Note: This report excludes firestore . Please also check **[the report for firestore ](%s)**\n ***\n " % firestore_issue_url
233226
234227 issue_number = _get_issue_number (token , report_title , _REPORT_LABEL )
235228 previous_comment = github .get_issue_body (token , issue_number )
236- [previous_prefix , previous_comment_repo , previous_comment_sdk ,
237- previous_comment_tip ] = previous_comment .split (_COMMENT_HIDDEN_DIVIDER )
238- # If there is a build dashboard, preserve it.
239- if (_COMMENT_DASHBOARD_START in previous_prefix and
240- _COMMENT_DASHBOARD_END in previous_prefix ):
241- [_ , previous_dashboard_plus_the_rest ] = previous_prefix .split (_COMMENT_DASHBOARD_START )
242- [previous_dashboard , _ ] = previous_dashboard_plus_the_rest .split (_COMMENT_DASHBOARD_END )
243- prefix = prefix + _COMMENT_DASHBOARD_START + previous_dashboard + _COMMENT_DASHBOARD_END
244-
229+ [_ , previous_comment_repo , previous_comment_sdk , previous_comment_tip ] = previous_comment .split (_COMMENT_HIDDEN_DIVIDER )
245230 success_or_only_flakiness , log_summary = _get_summary_table (token , run_id )
246231 if success_or_only_flakiness and not log_summary :
247232 # succeeded (without flakiness)
248233 if build_against == _BUILD_AGAINST_REPO :
249- title = _COMMENT_TITLE_SUCCEED_REPO
234+ title = _COMMENT_TITLE_SUCCEED_REPO
250235 elif build_against == _BUILD_AGAINST_SDK :
251236 title = _COMMENT_TITLE_SUCCEED_SDK
252237 else :
@@ -256,21 +241,21 @@ def test_report(token, actor, commit, run_id, build_against, build_apis):
256241 if success_or_only_flakiness :
257242 # all failures/errors are due to flakiness (succeeded after retry)
258243 if build_against == _BUILD_AGAINST_REPO :
259- title = _COMMENT_TITLE_FLAKY_REPO
244+ title = _COMMENT_TITLE_FLAKY_REPO
260245 elif build_against == _BUILD_AGAINST_SDK :
261246 title = _COMMENT_TITLE_FLAKY_SDK
262247 else :
263248 title = _COMMENT_TITLE_FLAKY_TIP
264249 else :
265250 # failures/errors still exist after retry
266251 if build_against == _BUILD_AGAINST_REPO :
267- title = _COMMENT_TITLE_FAIL_REPO
252+ title = _COMMENT_TITLE_FAIL_REPO
268253 elif build_against == _BUILD_AGAINST_SDK :
269254 title = _COMMENT_TITLE_FAIL_SDK
270255 else :
271256 title = _COMMENT_TITLE_FAIL_TIP
272257 comment = title + _get_description (actor , commit , run_id ) + log_summary + _COMMENT_FLAKY_TRACKER
273-
258+
274259 if build_against == _BUILD_AGAINST_REPO :
275260 comment = prefix + _COMMENT_HIDDEN_DIVIDER + comment + _COMMENT_HIDDEN_DIVIDER + previous_comment_sdk + _COMMENT_HIDDEN_DIVIDER + previous_comment_tip
276261 elif build_against == _BUILD_AGAINST_SDK :
@@ -282,7 +267,7 @@ def test_report(token, actor, commit, run_id, build_against, build_apis):
282267 github .close_issue (token , issue_number )
283268 else :
284269 github .open_issue (token , issue_number )
285-
270+
286271 github .update_issue_comment (token , issue_number , comment )
287272
288273
@@ -291,13 +276,7 @@ def _get_issue_number(token, title, label):
291276 for issue in issues :
292277 if issue ["title" ] == title :
293278 return issue ["number" ]
294- empty_comment = (" " +
295- _COMMENT_DASHBOARD_START + " " +
296- _COMMENT_DASHBOARD_END + " " +
297- _COMMENT_HIDDEN_DIVIDER + " " +
298- _COMMENT_HIDDEN_DIVIDER + " " +
299- _COMMENT_HIDDEN_DIVIDER + " "
300- )
279+ empty_comment = _COMMENT_HIDDEN_DIVIDER + " " + _COMMENT_HIDDEN_DIVIDER + " " + _COMMENT_HIDDEN_DIVIDER
301280 return github .create_issue (token , title , label , empty_comment )["number" ]
302281
303282
@@ -308,7 +287,7 @@ def _update_comment(token, issue_number, comment):
308287 else :
309288 github .update_comment (token , comment_id , comment )
310289
311-
290+
312291def _get_comment_id (token , issue_number , comment_identifier ):
313292 comments = github .list_comments (token , issue_number )
314293 for comment in comments :
0 commit comments