Skip to content

Commit 4366051

Browse files
authored
Create Separate Integration Test Nightly Report for Firestore (#830)
1 parent cf20054 commit 4366051

File tree

3 files changed

+84
-23
lines changed

3 files changed

+84
-23
lines changed

.github/workflows/cpp-packaging.yml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -788,13 +788,35 @@ jobs:
788788
if [[ -z ${USE_EXPANDED_MATRIX} ]]; then
789789
USE_EXPANDED_MATRIX=0
790790
fi
791-
if [[ "${{ github.event_name }}" == "schedule" ]]; then
792-
# reuse flag --test_pull_request=nightly-packaging to generate report
793-
generate_report=(-p test_pull_request nightly-packaging)
794-
fi
795791
verbose_flag=
796792
if [[ -n "${{ github.event.inputs.verboseBuild }}" && "${{ github.event.inputs.verboseBuild }}" -ne 0 ]]; then
797793
verbose_flag=-v
798794
fi
799795
set -e
800-
python scripts/gha/trigger_workflow.py -t ${{ steps.generate-token.outputs.token }} -w integration_tests.yml -p test_packaged_sdk ${{ github.run_id }} -p use_expanded_matrix ${USE_EXPANDED_MATRIX} ${generate_report[*]} -s 10 -A ${verbose_flag}
796+
if [[ "${{ github.event_name }}" == "schedule" ]]; then
797+
# trigger integration tests and generate two reports for nightly workflow run: one for firestore, one for the rest.
798+
python scripts/gha/trigger_workflow.py -t ${{ steps.generate-token.outputs.token }} \
799+
-w integration_tests.yml \
800+
-p test_packaged_sdk ${{ github.run_id }} \
801+
-p use_expanded_matrix ${USE_EXPANDED_MATRIX} \
802+
-p apis "admob,analytics,auth,database,dynamic_links,functions,installations,messaging,remote_config,storage" \
803+
-p test_pull_request nightly-packaging \
804+
-s 10 \
805+
-A ${verbose_flag}
806+
python scripts/gha/trigger_workflow.py -t ${{ steps.generate-token.outputs.token }} \
807+
-w integration_tests.yml \
808+
-p test_packaged_sdk ${{ github.run_id }} \
809+
-p use_expanded_matrix ${USE_EXPANDED_MATRIX} \
810+
-p apis "firestore" \
811+
-p test_pull_request nightly-packaging \
812+
-s 10 \
813+
-A ${verbose_flag}
814+
else
815+
# trigger integration tests
816+
python scripts/gha/trigger_workflow.py -t ${{ steps.generate-token.outputs.token }} \
817+
-w integration_tests.yml \
818+
-p test_packaged_sdk ${{ github.run_id }} \
819+
-p use_expanded_matrix ${USE_EXPANDED_MATRIX} \
820+
-s 10 \
821+
-A ${verbose_flag}
822+
fi

.github/workflows/integration_tests.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ name: Integration tests
22

33
on:
44
schedule:
5-
- cron: "0 9 * * *" # 9am UTC = 1am PST / 2am PDT
5+
- cron: "0 9 * * *" # 9am UTC = 1am PST / 2am PDT. for all testapps except firestore
6+
- cron: "0 10 * * *" # 10am UTC = 2am PST / 3am PDT. for firestore test only
7+
68
pull_request:
79
types: [ labeled, closed ]
810

@@ -169,7 +171,15 @@ jobs:
169171
170172
# To feed input into the job matrix, we first need to convert to a JSON
171173
# list. Then we can use fromJson to define the field in the matrix for the tests job.
172-
apis=$( python scripts/gha/print_matrix_configuration.py -c -w integration_tests -k apis -o "${{github.event.inputs.apis}}" ${TEST_MATRIX_PARAM} )
174+
if [[ "${{ github.event.schedule }}" == "0 9 * * *" ]]; then
175+
# at 1am PST / 2am PDT. Running integration tests and generate test report for all testapps except firestore
176+
apis="admob,analytics,auth,database,dynamic_links,functions,installations,messaging,remote_config,storage"
177+
elif [[ "${{ github.event.schedule }}" == "0 10 * * *" ]]; then
178+
# at 2am PST / 3am PDT. Running integration tests for firestore and generate test report
179+
apis="firestore"
180+
else
181+
apis=$( python scripts/gha/print_matrix_configuration.py -c -w integration_tests -k apis -o "${{github.event.inputs.apis}}" ${TEST_MATRIX_PARAM} )
182+
fi
173183
echo "::set-output name=apis::${apis}"
174184
echo "::set-output name=matrix_platform::$( python scripts/gha/print_matrix_configuration.py -w integration_tests ${TEST_MATRIX_PARAM} -k platform -o "${{github.event.inputs.platforms}}" --apis ${apis} )"
175185
echo "::set-output name=matrix_os::$( python scripts/gha/print_matrix_configuration.py -w integration_tests ${TEST_MATRIX_PARAM} -k os -o "${{github.event.inputs.operating_systems}}")"
@@ -1166,6 +1176,11 @@ jobs:
11661176
else
11671177
additional_flags=(--build_against repo)
11681178
fi
1179+
if [[ "${{ needs.check_and_prepare.outputs.apis }}" == "firestore" ]]; then
1180+
additional_flags+=(--build_apis firestore)
1181+
else
1182+
additional_flags+=(--build_apis all_except_firestore)
1183+
fi
11691184
python scripts/gha/it_workflow.py --stage report \
11701185
--token ${{github.token}} \
11711186
--actor ${{github.actor}} \

scripts/gha/it_workflow.py

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252

5353
_REPORT_LABEL = "nightly-testing"
5454
_REPORT_TITLE = "Nightly Integration Testing Report"
55+
_REPORT_TITLE_FIRESTORE = "Nightly Integration Testing Report for Firestore"
5556

5657
_LABEL_TRIGGER_FULL = "tests-requested: full"
5758
_LABEL_TRIGGER_QUICK = "tests-requested: quick"
@@ -75,7 +76,7 @@
7576
_COMMENT_FLAKY_TRACKER = "\n\nAdd flaky tests to **[go/fpl-cpp-flake-tracker](http://go/fpl-cpp-flake-tracker)**\n"
7677

7778
_COMMENT_IDENTIFIER = "integration-test-status-comment"
78-
_COMMENT_SUFFIX = f'\n<hidden value="{_COMMENT_IDENTIFIER}"></hidden>'
79+
_COMMENT_HIDDEN_DIVIDER = f'\n<hidden value="{_COMMENT_IDENTIFIER}"></hidden>\n'
7980

8081
_LOG_ARTIFACT_NAME = "log-artifact"
8182
_LOG_OUTPUT_DIR = "test_results"
@@ -89,6 +90,10 @@
8990
_BUILD_AGAINST_SDK = "sdk"
9091
_BUILD_AGAINST_REPO = "repo"
9192

93+
_BUILD_API_ALL = "all"
94+
_BUILD_API_FIRESTORE = "firestore"
95+
_BUILD_API_ALL_EXCEPT_FIRESTORE = "all_except_firestore"
96+
9297
FLAGS = flags.FLAGS
9398

9499
flags.DEFINE_string(
@@ -124,6 +129,10 @@
124129
"build_against", None,
125130
"Integration testapps could either build against packaged SDK or repo")
126131

132+
flags.DEFINE_string(
133+
"build_apis", None,
134+
"Generate spearate report for different apis.")
135+
127136

128137
def test_start(token, issue_number, actor, commit, run_id):
129138
"""In PR, when start testing, add comment and label \"tests: in-progress\""""
@@ -133,7 +142,7 @@ def test_start(token, issue_number, actor, commit, run_id):
133142

134143
comment = (_COMMENT_TITLE_PROGESS +
135144
_get_description(actor, commit, run_id) +
136-
_COMMENT_SUFFIX)
145+
_COMMENT_HIDDEN_DIVIDER)
137146
_update_comment(token, issue_number, comment)
138147

139148

@@ -156,7 +165,7 @@ def test_progress(token, issue_number, actor, commit, run_id):
156165
_get_description(actor, commit, run_id) +
157166
log_summary +
158167
_COMMENT_FLAKY_TRACKER +
159-
_COMMENT_SUFFIX)
168+
_COMMENT_HIDDEN_DIVIDER)
160169
_update_comment(token, issue_number, comment)
161170

162171

@@ -170,7 +179,7 @@ def test_end(token, issue_number, actor, commit, run_id, new_token):
170179
github.add_label(token, issue_number, _LABEL_SUCCEED)
171180
comment = (_COMMENT_TITLE_SUCCEED +
172181
_get_description(actor, commit, run_id) +
173-
_COMMENT_SUFFIX)
182+
_COMMENT_HIDDEN_DIVIDER)
174183
_update_comment(token, issue_number, comment)
175184
else:
176185
if success_or_only_flakiness:
@@ -185,20 +194,35 @@ def test_end(token, issue_number, actor, commit, run_id, new_token):
185194
_get_description(actor, commit, run_id) +
186195
log_summary +
187196
_COMMENT_FLAKY_TRACKER +
188-
_COMMENT_SUFFIX)
197+
_COMMENT_HIDDEN_DIVIDER)
189198
_update_comment(token, issue_number, comment)
190199

191200
github.delete_label(new_token, issue_number, _LABEL_PROGRESS)
192201

193202

194-
def test_report(token, actor, commit, run_id, build_against):
195-
"""Update (create if not exist) a Daily Report in Issue.
203+
def test_report(token, actor, commit, run_id, build_against, build_apis):
204+
"""Update (create if not exist) a Daily/Nightly Report in Issue.
196205
The Issue with title _REPORT_TITLE and label _REPORT_LABEL:
197206
https://github.com/firebase/firebase-cpp-sdk/issues?q=is%3Aissue+label%3Anightly-testing
207+
The report is with the format below:
208+
PREFIX
209+
HIDDEN DIVIDER
210+
REPORT (TEST AGAINST REPO)
211+
HIDDEN DIVIDER
212+
REPORT (TEST AGAINST SDK)
198213
"""
199-
issue_number = _get_issue_number(token, _REPORT_TITLE, _REPORT_LABEL)
214+
if build_apis == _BUILD_API_FIRESTORE:
215+
report_title = _REPORT_TITLE_FIRESTORE
216+
prefix = ""
217+
else:
218+
report_title = _REPORT_TITLE
219+
firestore_issue_number = _get_issue_number(token, _REPORT_TITLE_FIRESTORE, _REPORT_LABEL)
220+
firestore_issue_url = "https://github.com/firebase/firebase-cpp-sdk/issues/%s" % firestore_issue_number
221+
prefix = "Note: This report excludes firestore. Please also check **[the report for firestore](%s)**\n***\n" % firestore_issue_url
222+
223+
issue_number = _get_issue_number(token, report_title, _REPORT_LABEL)
200224
previous_comment = github.get_issue_body(token, issue_number)
201-
[previous_comment_repo, previous_comment_sdk] = previous_comment.split(_COMMENT_SUFFIX)
225+
[_, previous_comment_repo, previous_comment_sdk] = previous_comment.split(_COMMENT_HIDDEN_DIVIDER)
202226
success_or_only_flakiness, log_summary = _get_summary_table(token, run_id)
203227
if success_or_only_flakiness and not log_summary:
204228
# succeeded (without flakiness)
@@ -214,9 +238,9 @@ def test_report(token, actor, commit, run_id, build_against):
214238
comment = title + _get_description(actor, commit, run_id) + log_summary + _COMMENT_FLAKY_TRACKER
215239

216240
if build_against==_BUILD_AGAINST_REPO:
217-
comment = comment + _COMMENT_SUFFIX + previous_comment_sdk
218-
else:
219-
comment = previous_comment_repo + _COMMENT_SUFFIX + comment
241+
comment = prefix + _COMMENT_HIDDEN_DIVIDER + comment + _COMMENT_HIDDEN_DIVIDER + previous_comment_sdk
242+
elif build_against==_BUILD_AGAINST_SDK:
243+
comment = prefix + _COMMENT_HIDDEN_DIVIDER + previous_comment_repo + _COMMENT_HIDDEN_DIVIDER + comment
220244

221245
if (_COMMENT_TITLE_SUCCEED_REPO in comment) and (_COMMENT_TITLE_SUCCEED_SDK in comment):
222246
github.close_issue(token, issue_number)
@@ -231,12 +255,12 @@ def _get_issue_number(token, title, label):
231255
for issue in issues:
232256
if issue["title"] == title:
233257
return issue["number"]
234-
235-
return github.create_issue(token, title, label, _COMMENT_SUFFIX)["number"]
258+
empty_comment = _COMMENT_HIDDEN_DIVIDER + " " + _COMMENT_HIDDEN_DIVIDER
259+
return github.create_issue(token, title, label, empty_comment)["number"]
236260

237261

238262
def _update_comment(token, issue_number, comment):
239-
comment_id = _get_comment_id(token, issue_number, _COMMENT_SUFFIX)
263+
comment_id = _get_comment_id(token, issue_number, _COMMENT_HIDDEN_DIVIDER)
240264
if not comment_id:
241265
github.add_comment(token, issue_number, comment)
242266
else:
@@ -288,7 +312,7 @@ def main(argv):
288312
elif FLAGS.stage == _BUILD_STAGES_END:
289313
test_end(FLAGS.token, FLAGS.issue_number, FLAGS.actor, FLAGS.commit, FLAGS.run_id, FLAGS.new_token)
290314
elif FLAGS.stage == _BUILD_STAGES_REPORT:
291-
test_report(FLAGS.token, FLAGS.actor, FLAGS.commit, FLAGS.run_id, FLAGS.build_against)
315+
test_report(FLAGS.token, FLAGS.actor, FLAGS.commit, FLAGS.run_id, FLAGS.build_against, FLAGS.build_apis)
292316
else:
293317
print("Invalid stage value. Valid value: " + ",".join(_BUILD_STAGES))
294318

0 commit comments

Comments
 (0)