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+
8488_LOG_ARTIFACT_NAME = "log-artifact"
8589_LOG_OUTPUT_DIR = "test_results"
8690
105109 "Different stage while running the workflow. Valid values in _BUILD_STAGES." )
106110
107111flags .DEFINE_string (
108- "token" , None ,
112+ "token" , None ,
109113 "github.token: A token to authenticate on your repository." )
110114
111115flags .DEFINE_string (
127131 "new_token" , None ,
128132 "Only used with --stage end"
129133 "Use a different token to remove the \" in-progress\" label,"
130- "to allow the removal to trigger the \" Check Labels\" workflow." )
134+ "to allow the removal to trigger the \" Check Labels\" workflow." )
131135
132136flags .DEFINE_string (
133137 "build_against" , None ,
@@ -151,7 +155,7 @@ def test_start(token, issue_number, actor, commit, run_id):
151155
152156
153157def test_progress (token , issue_number , actor , commit , run_id ):
154- """In PR, when some test failed, update failure info and
158+ """In PR, when some test failed, update failure info and
155159 add label \" tests: failed\" """
156160 success_or_only_flakiness , log_summary = _get_summary_table (token , run_id )
157161 if success_or_only_flakiness and not log_summary :
@@ -174,7 +178,7 @@ def test_progress(token, issue_number, actor, commit, run_id):
174178
175179
176180def test_end (token , issue_number , actor , commit , run_id , new_token ):
177- """In PR, when some test end, update Test Result Report and
181+ """In PR, when some test end, update Test Result Report and
178182 update label: add \" tests: failed\" if test failed, add label
179183 \" tests: succeeded\" if test succeed"""
180184 success_or_only_flakiness , log_summary = _get_summary_table (token , run_id )
@@ -205,11 +209,14 @@ def test_end(token, issue_number, actor, commit, run_id, new_token):
205209
206210
207211def test_report (token , actor , commit , run_id , build_against , build_apis ):
208- """Update (create if not exist) a Daily/Nightly Report in Issue.
212+ """Update (create if not exist) a Daily/Nightly Report in Issue.
209213 The Issue with title _REPORT_TITLE and label _REPORT_LABEL:
210214 https://github.com/firebase/firebase-cpp-sdk/issues?q=is%3Aissue+label%3Anightly-testing
211215 The report is with the format below:
212216 PREFIX
217+ HIDDEN DASHBOARD START - optional
218+ BUILD DASHBOARD - optional
219+ HIDDEN DASHBOARD END - optional
213220 HIDDEN DIVIDER
214221 REPORT (TEST AGAINST REPO)
215222 HIDDEN DIVIDER
@@ -222,16 +229,24 @@ def test_report(token, actor, commit, run_id, build_against, build_apis):
222229 report_title = _REPORT_TITLE
223230 firestore_issue_number = _get_issue_number (token , _REPORT_TITLE_FIRESTORE , _REPORT_LABEL )
224231 firestore_issue_url = "https://github.com/firebase/firebase-cpp-sdk/issues/%s" % firestore_issue_number
225- prefix = "Note: This report excludes firestore . Please also check **[the report for firestore ](%s)**\n ***\n " % firestore_issue_url
232+ prefix = "Note: This report excludes Firestore . Please also check **[the report for Firestore ](%s). **\n ***\n " % firestore_issue_url
226233
227234 issue_number = _get_issue_number (token , report_title , _REPORT_LABEL )
228235 previous_comment = github .get_issue_body (token , issue_number )
229- [_ , previous_comment_repo , previous_comment_sdk , previous_comment_tip ] = previous_comment .split (_COMMENT_HIDDEN_DIVIDER )
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+
230245 success_or_only_flakiness , log_summary = _get_summary_table (token , run_id )
231246 if success_or_only_flakiness and not log_summary :
232247 # succeeded (without flakiness)
233248 if build_against == _BUILD_AGAINST_REPO :
234- title = _COMMENT_TITLE_SUCCEED_REPO
249+ title = _COMMENT_TITLE_SUCCEED_REPO
235250 elif build_against == _BUILD_AGAINST_SDK :
236251 title = _COMMENT_TITLE_SUCCEED_SDK
237252 else :
@@ -241,21 +256,21 @@ def test_report(token, actor, commit, run_id, build_against, build_apis):
241256 if success_or_only_flakiness :
242257 # all failures/errors are due to flakiness (succeeded after retry)
243258 if build_against == _BUILD_AGAINST_REPO :
244- title = _COMMENT_TITLE_FLAKY_REPO
259+ title = _COMMENT_TITLE_FLAKY_REPO
245260 elif build_against == _BUILD_AGAINST_SDK :
246261 title = _COMMENT_TITLE_FLAKY_SDK
247262 else :
248263 title = _COMMENT_TITLE_FLAKY_TIP
249264 else :
250265 # failures/errors still exist after retry
251266 if build_against == _BUILD_AGAINST_REPO :
252- title = _COMMENT_TITLE_FAIL_REPO
267+ title = _COMMENT_TITLE_FAIL_REPO
253268 elif build_against == _BUILD_AGAINST_SDK :
254269 title = _COMMENT_TITLE_FAIL_SDK
255270 else :
256271 title = _COMMENT_TITLE_FAIL_TIP
257272 comment = title + _get_description (actor , commit , run_id ) + log_summary + _COMMENT_FLAKY_TRACKER
258-
273+
259274 if build_against == _BUILD_AGAINST_REPO :
260275 comment = prefix + _COMMENT_HIDDEN_DIVIDER + comment + _COMMENT_HIDDEN_DIVIDER + previous_comment_sdk + _COMMENT_HIDDEN_DIVIDER + previous_comment_tip
261276 elif build_against == _BUILD_AGAINST_SDK :
@@ -267,7 +282,7 @@ def test_report(token, actor, commit, run_id, build_against, build_apis):
267282 github .close_issue (token , issue_number )
268283 else :
269284 github .open_issue (token , issue_number )
270-
285+
271286 github .update_issue_comment (token , issue_number , comment )
272287
273288
@@ -276,7 +291,13 @@ def _get_issue_number(token, title, label):
276291 for issue in issues :
277292 if issue ["title" ] == title :
278293 return issue ["number" ]
279- empty_comment = _COMMENT_HIDDEN_DIVIDER + " " + _COMMENT_HIDDEN_DIVIDER + " " + _COMMENT_HIDDEN_DIVIDER
294+ empty_comment = (" " +
295+ _COMMENT_DASHBOARD_START + " " +
296+ _COMMENT_DASHBOARD_END + " " +
297+ _COMMENT_HIDDEN_DIVIDER + " " +
298+ _COMMENT_HIDDEN_DIVIDER + " " +
299+ _COMMENT_HIDDEN_DIVIDER + " "
300+ )
280301 return github .create_issue (token , title , label , empty_comment )["number" ]
281302
282303
@@ -287,7 +308,7 @@ def _update_comment(token, issue_number, comment):
287308 else :
288309 github .update_comment (token , comment_id , comment )
289310
290-
311+
291312def _get_comment_id (token , issue_number , comment_identifier ):
292313 comments = github .list_comments (token , issue_number )
293314 for comment in comments :
0 commit comments