Skip to content

Commit 69779cf

Browse files
authored
Add a dashboard of build/test status to the nightly build page. (#1340)
* Update build script. * Add caching. * Clean up output in text mode. * Run most basic version of script. * Untabify * Fix python script * Install requests module * Fix command * Full script. * Tabs * Fix build report. * Tabs. * Preserve dashboard comment in test workflow. * Add script for updating issue comment. * Update workflow script to handle dashboard. * Finish script to update issue comment. * Add issue updating to the workflow. * Add comments. * Schedule build matrix earlier. * Don't include header if --nooutput_header is specified. * Change heading to Username * Remove extraneous newline causing bad formatting.
1 parent 70989bc commit 69779cf

File tree

4 files changed

+741
-21
lines changed

4 files changed

+741
-21
lines changed

.github/workflows/build-report.yml

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name: Generate Weekly Test Report
1+
name: Generate Test Report Table
22

33
on:
44
workflow_dispatch:
55
schedule:
6-
- cron: "0 16 * * *" # 4pm UTC = 8am PST / 9am PDT, 7 hours after testapps run
6+
- cron: "0 15 * * *" # 3pm UTC = 7am PST / 8am PDT, 6 hours after testapps run
77

88
env:
99
GITHUB_TOKEN: ${{ github.token }}
@@ -14,6 +14,56 @@ jobs:
1414
generate-report:
1515
runs-on: ubuntu-20.04
1616
steps:
17+
- name: Setup python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: 3.9
21+
- uses: actions/checkout@v3
22+
with:
23+
fetch-depth: 0
24+
- name: Install Desktop SDK prerequisites
25+
uses: nick-invision/retry@v2
26+
with:
27+
timeout_minutes: 15
28+
max_attempts: 3
29+
command: |
30+
python3 scripts/gha/install_prereqs_desktop.py --gha_build
31+
python3 -m pip install requests python-dateutil progress attrs
1732
- name: Fetch GitHub jobs
1833
run: |
19-
true
34+
python3 scripts/gha/report_build_status.py --token ${{ github.token }} --days ${{ env.numDays }} --write_cache build_status_short.cache
35+
python3 scripts/gha/report_build_status.py --token ${{ github.token }} --days ${{ env.numDaysExtended }} --write_cache build_status.cache
36+
- name: Generate report files
37+
run: |
38+
python3 scripts/gha/report_build_status.py --token ${{ github.token }} --days ${{ env.numDays }} --output_markdown --read_cache build_status_short.cache > report_short.md
39+
python3 scripts/gha/report_build_status.py --token ${{ github.token }} --days ${{ env.numDaysExtended }} --output_markdown --read_cache build_status.cache > report_extended.md
40+
python3 scripts/gha/report_build_status.py --token ${{ github.token }} --days ${{ env.numDays }} --nooutput_header --read_cache build_status_short.cache > report.txt
41+
- name: Generate comment string
42+
run: |
43+
echo -n > comment.md
44+
cat >> comment.md <<EOF
45+
46+
***
47+
48+
EOF
49+
cat report_short.md >> comment.md
50+
cat >> comment.md <<EOF
51+
52+
<details><summary>View extended history</summary>
53+
54+
EOF
55+
cat report_extended.md >> comment.md
56+
cat >> comment.md <<EOF
57+
</details>
58+
<details><summary>📄</summary><pre>
59+
EOF
60+
cat report.txt >> comment.md
61+
cat >> comment.md <<EOF
62+
</pre></details>
63+
EOF
64+
- name: Show comment string
65+
run: |
66+
cat comment.md
67+
- name: Update GitHub issue
68+
run: |
69+
python3 scripts/gha/update_issue_comment.py --token ${{ github.token }} --issue_title '[C++] Nightly Integration Testing Report' --start_tag build-dashboard-comment-start --end_tag build-dashboard-comment-end < comment.md

scripts/gha/it_workflow.py

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
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
1919
For PR comment, this script will update (create if not exist) the "Test Result" in comment.
2020
stage value: [start, progress, end]
@@ -27,7 +27,7 @@
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
3131
with title "Nightly Integration Testing Report" and label "nightly-testing".
3232
stage value: [report]
3333
USAGE:
@@ -61,8 +61,8 @@
6161
_LABEL_SUCCEED = "tests: succeeded"
6262

6363
_COMMENT_TITLE_PROGESS = "### ⏳&nbsp; Integration test in progress...\n"
64-
_COMMENT_TITLE_PROGESS_FLAKY = "### Integration test with FLAKINESS (but still ⏳&nbsp; in progress)\n"
65-
_COMMENT_TITLE_PROGESS_FAIL = "### ❌&nbsp; Integration test FAILED (but still ⏳&nbsp; in progress)\n"
64+
_COMMENT_TITLE_PROGESS_FLAKY = "### Integration test with FLAKINESS (but still ⏳&nbsp; in progress)\n"
65+
_COMMENT_TITLE_PROGESS_FAIL = "### ❌&nbsp; Integration test FAILED (but still ⏳&nbsp; in progress)\n"
6666
_COMMENT_TITLE_FLAKY = "### Integration test with FLAKINESS (succeeded after retry)\n"
6767
_COMMENT_TITLE_FAIL = "### ❌&nbsp; Integration test FAILED\n"
6868
_COMMENT_TITLE_SUCCEED = "### ✅&nbsp; Integration test succeeded!\n"
@@ -81,6 +81,10 @@
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

@@ -105,7 +109,7 @@
105109
"Different stage while running the workflow. Valid values in _BUILD_STAGES.")
106110

107111
flags.DEFINE_string(
108-
"token", None,
112+
"token", None,
109113
"github.token: A token to authenticate on your repository.")
110114

111115
flags.DEFINE_string(
@@ -127,7 +131,7 @@
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

132136
flags.DEFINE_string(
133137
"build_against", None,
@@ -151,7 +155,7 @@ def test_start(token, issue_number, actor, commit, run_id):
151155

152156

153157
def 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

176180
def 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

207211
def 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+
291312
def _get_comment_id(token, issue_number, comment_identifier):
292313
comments = github.list_comments(token, issue_number)
293314
for comment in comments:

0 commit comments

Comments
 (0)