Skip to content

Commit 4b97d0e

Browse files
cynthiajoanCynthia Jiang
andauthored
rename github.py to firebase_github.py (#1377)
Co-authored-by: Cynthia Jiang <[email protected]>
1 parent 4fd4ce9 commit 4b97d0e

File tree

7 files changed

+41
-41
lines changed

7 files changed

+41
-41
lines changed

scripts/gha/create_pull_request.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from absl import flags
3333
from absl import logging
3434

35-
import github
35+
import firebase_github
3636

3737
FLAGS = flags.FLAGS
3838
_DEFAULT_MESSAGE = "Creating pull request."
@@ -60,9 +60,9 @@
6060
def main(argv):
6161
if len(argv) > 1:
6262
raise app.UsageError("Too many command-line arguments.")
63-
if github.create_pull_request(FLAGS.token, FLAGS.head, FLAGS.base, FLAGS.title, FLAGS.body, True):
63+
if firebase_github.create_pull_request(FLAGS.token, FLAGS.head, FLAGS.base, FLAGS.title, FLAGS.body, True):
6464
# Find the most recent pull_request with the given base and head, that's ours.
65-
pull_requests = github.list_pull_requests(FLAGS.token, "open", FLAGS.head, FLAGS.base)
65+
pull_requests = firebase_github.list_pull_requests(FLAGS.token, "open", FLAGS.head, FLAGS.base)
6666
print(pull_requests[0]['number'])
6767
else:
6868
exit(1)

scripts/gha/dismiss_reviews.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from absl import flags
3131
from absl import logging
3232

33-
import github
33+
import firebase_github
3434

3535
FLAGS = flags.FLAGS
3636
_DEFAULT_MESSAGE = "Dismissing stale review."
@@ -60,7 +60,7 @@ def main(argv):
6060
if len(argv) > 1:
6161
raise app.UsageError("Too many command-line arguments.")
6262
# Get list of reviews from PR.
63-
reviews = github.get_reviews(FLAGS.token, FLAGS.pull_number)
63+
reviews = firebase_github.get_reviews(FLAGS.token, FLAGS.pull_number)
6464
logging.debug("Found %d reviews", len(reviews))
6565

6666
# Filter out already-dismissed reviews.
@@ -76,7 +76,7 @@ def main(argv):
7676
review_ids = [r['id'] for r in reviews]
7777
logging.debug("Dismissing reviews: %s", review_ids)
7878
for review_id in review_ids:
79-
github.dismiss_review(FLAGS.token, FLAGS.pull_number,
79+
firebase_github.dismiss_review(FLAGS.token, FLAGS.pull_number,
8080
review_id, FLAGS.message)
8181

8282
if __name__ == "__main__":
File renamed without changes.

scripts/gha/it_workflow.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
from absl import flags
4848
from absl import logging
4949

50-
import github
50+
import firebase_github
5151
import summarize_test_results as summarize
5252

5353
_REPORT_LABEL = "nightly-testing"
@@ -144,9 +144,9 @@
144144

145145
def test_start(token, issue_number, actor, commit, run_id):
146146
"""In PR, when start testing, add comment and label \"tests: in-progress\""""
147-
github.add_label(token, issue_number, _LABEL_PROGRESS)
147+
firebase_github.add_label(token, issue_number, _LABEL_PROGRESS)
148148
for label in [_LABEL_TRIGGER_FULL, _LABEL_TRIGGER_QUICK, _LABEL_FAILED, _LABEL_SUCCEED]:
149-
github.delete_label(token, issue_number, label)
149+
firebase_github.delete_label(token, issue_number, label)
150150

151151
comment = (_COMMENT_TITLE_PROGESS +
152152
_get_description(actor, commit, run_id) +
@@ -168,7 +168,7 @@ def test_progress(token, issue_number, actor, commit, run_id):
168168
else:
169169
# failures/errors still exist after retry
170170
title = _COMMENT_TITLE_PROGESS_FAIL
171-
github.add_label(token, issue_number, _LABEL_FAILED)
171+
firebase_github.add_label(token, issue_number, _LABEL_FAILED)
172172
comment = (title +
173173
_get_description(actor, commit, run_id) +
174174
log_summary +
@@ -184,7 +184,7 @@ def test_end(token, issue_number, actor, commit, run_id, new_token):
184184
success_or_only_flakiness, log_summary = _get_summary_table(token, run_id)
185185
if success_or_only_flakiness and not log_summary:
186186
# succeeded (without flakiness)
187-
github.add_label(token, issue_number, _LABEL_SUCCEED)
187+
firebase_github.add_label(token, issue_number, _LABEL_SUCCEED)
188188
comment = (_COMMENT_TITLE_SUCCEED +
189189
_get_description(actor, commit, run_id) +
190190
_COMMENT_HIDDEN_DIVIDER)
@@ -193,19 +193,19 @@ def test_end(token, issue_number, actor, commit, run_id, new_token):
193193
if success_or_only_flakiness:
194194
# all failures/errors are due to flakiness (succeeded after retry)
195195
title = _COMMENT_TITLE_FLAKY
196-
github.add_label(token, issue_number, _LABEL_SUCCEED)
196+
firebase_github.add_label(token, issue_number, _LABEL_SUCCEED)
197197
else:
198198
# failures/errors still exist after retry
199199
title = _COMMENT_TITLE_FAIL
200-
github.add_label(token, issue_number, _LABEL_FAILED)
200+
firebase_github.add_label(token, issue_number, _LABEL_FAILED)
201201
comment = (title +
202202
_get_description(actor, commit, run_id) +
203203
log_summary +
204204
_COMMENT_FLAKY_TRACKER +
205205
_COMMENT_HIDDEN_DIVIDER)
206206
_update_comment(token, issue_number, comment)
207207

208-
github.delete_label(new_token, issue_number, _LABEL_PROGRESS)
208+
firebase_github.delete_label(new_token, issue_number, _LABEL_PROGRESS)
209209

210210

211211
def test_report(token, actor, commit, run_id, build_against, build_apis):
@@ -232,7 +232,7 @@ def test_report(token, actor, commit, run_id, build_against, build_apis):
232232
prefix = "Note: This report excludes Firestore. Please also check **[the report for Firestore](%s).**\n***\n" % firestore_issue_url
233233

234234
issue_number = _get_issue_number(token, report_title, _REPORT_LABEL)
235-
previous_comment = github.get_issue_body(token, issue_number)
235+
previous_comment = firebase_github.get_issue_body(token, issue_number)
236236
[previous_prefix, previous_comment_repo, previous_comment_sdk,
237237
previous_comment_tip] = previous_comment.split(_COMMENT_HIDDEN_DIVIDER)
238238
logging.info("Previous prefix: %s", previous_prefix)
@@ -284,15 +284,15 @@ def test_report(token, actor, commit, run_id, build_against, build_apis):
284284
comment = prefix + _COMMENT_HIDDEN_DIVIDER + previous_comment_repo + _COMMENT_HIDDEN_DIVIDER + previous_comment_sdk + _COMMENT_HIDDEN_DIVIDER + comment
285285

286286
if (_COMMENT_TITLE_SUCCEED_REPO in comment) and (_COMMENT_TITLE_SUCCEED_SDK in comment) and (build_apis != _BUILD_API_FIRESTORE or _COMMENT_TITLE_SUCCEED_TIP in comment):
287-
github.close_issue(token, issue_number)
287+
firebase_github.close_issue(token, issue_number)
288288
else:
289-
github.open_issue(token, issue_number)
289+
firebase_github.open_issue(token, issue_number)
290290

291-
github.update_issue_comment(token, issue_number, comment)
291+
firebase_github.update_issue_comment(token, issue_number, comment)
292292

293293

294294
def _get_issue_number(token, title, label):
295-
issues = github.search_issues_by_label(label)
295+
issues = firebase_github.search_issues_by_label(label)
296296
for issue in issues:
297297
if issue["title"] == title:
298298
return issue["number"]
@@ -303,19 +303,19 @@ def _get_issue_number(token, title, label):
303303
_COMMENT_HIDDEN_DIVIDER + " " +
304304
_COMMENT_HIDDEN_DIVIDER + " "
305305
)
306-
return github.create_issue(token, title, label, empty_comment)["number"]
306+
return firebase_github.create_issue(token, title, label, empty_comment)["number"]
307307

308308

309309
def _update_comment(token, issue_number, comment):
310310
comment_id = _get_comment_id(token, issue_number, _COMMENT_HIDDEN_DIVIDER)
311311
if not comment_id:
312-
github.add_comment(token, issue_number, comment)
312+
firebase_github.add_comment(token, issue_number, comment)
313313
else:
314-
github.update_comment(token, comment_id, comment)
314+
firebase_github.update_comment(token, comment_id, comment)
315315

316316

317317
def _get_comment_id(token, issue_number, comment_identifier):
318-
comments = github.list_comments(token, issue_number)
318+
comments = firebase_github.list_comments(token, issue_number)
319319
for comment in comments:
320320
if comment_identifier in comment['body']:
321321
return comment['id']
@@ -342,7 +342,7 @@ def _get_summary_table(token, run_id):
342342

343343

344344
def _get_artifact_id(token, run_id, name):
345-
artifacts = github.list_artifacts(token, run_id)
345+
artifacts = firebase_github.list_artifacts(token, run_id)
346346
for artifact in artifacts:
347347
if artifact["name"] == name:
348348
return artifact["id"]

scripts/gha/report_build_status.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
from absl import flags
4747
from absl import logging
4848

49-
import github
49+
import firebase_github
5050
import summarize_test_results
5151

5252
FLAGS = flags.FLAGS
@@ -369,7 +369,7 @@ def main(argv):
369369

370370
with progress.bar.Bar('Reading jobs...', max=3) as bar:
371371
workflow_id = _WORKFLOW_TESTS
372-
all_runs = github.list_workflow_runs(FLAGS.token, workflow_id, _BRANCH, 'schedule', _LIMIT)
372+
all_runs = firebase_github.list_workflow_runs(FLAGS.token, workflow_id, _BRANCH, 'schedule', _LIMIT)
373373
bar.next()
374374
source_tests = {}
375375
for run in reversed(all_runs):
@@ -387,7 +387,7 @@ def main(argv):
387387
# firestore_tests[day] = run
388388

389389
workflow_id = _WORKFLOW_PACKAGING
390-
all_runs = github.list_workflow_runs(FLAGS.token, workflow_id, _BRANCH, 'schedule', _LIMIT)
390+
all_runs = firebase_github.list_workflow_runs(FLAGS.token, workflow_id, _BRANCH, 'schedule', _LIMIT)
391391
bar.next()
392392
packaging_runs = {}
393393
packaging_run_ids = set()
@@ -404,7 +404,7 @@ def main(argv):
404404
packaging_run_ids.add(str(run['id']))
405405

406406
workflow_id = _WORKFLOW_TESTS
407-
all_runs = github.list_workflow_runs(FLAGS.token, workflow_id, _BRANCH, 'workflow_dispatch', _LIMIT)
407+
all_runs = firebase_github.list_workflow_runs(FLAGS.token, workflow_id, _BRANCH, 'workflow_dispatch', _LIMIT)
408408
bar.next()
409409
package_tests_all = []
410410
for run in reversed(all_runs):
@@ -456,10 +456,10 @@ def main(argv):
456456
run = tests[day]
457457
run['log_success'] = True
458458
run['log_results'] = ''
459-
artifacts = github.list_artifacts(FLAGS.token, run['id'])
459+
artifacts = firebase_github.list_artifacts(FLAGS.token, run['id'])
460460
if 'log-artifact' in [a['name'] for a in artifacts]:
461461
artifact_id = [a['id'] for a in artifacts if a['name'] == 'log-artifact'][0]
462-
artifact_contents = github.download_artifact(FLAGS.token, artifact_id)
462+
artifact_contents = firebase_github.download_artifact(FLAGS.token, artifact_id)
463463
if artifact_contents:
464464
artifact_data = io.BytesIO(artifact_contents)
465465
artifact_zip = zipfile.ZipFile(artifact_data)

scripts/gha/trigger_workflow.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,30 @@
3232
import subprocess
3333
import time
3434
import urllib.parse
35-
import github
35+
import firebase_github
3636

3737
def main():
3838
args = parse_cmdline_args()
3939
if args.branch is None:
4040
args.branch=subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).decode('utf-8').rstrip('\n')
4141
print('autodetected branch: %s' % args.branch)
4242
if args.repo: # else use default firebase/firebase-cpp-sdk repo
43-
if not github.set_repo_url(args.repo):
43+
if not firebase_github.set_repo_url(args.repo):
4444
exit(2)
4545
else:
46-
print('set repo url to: %s' % github.GITHUB_API_URL)
46+
print('set repo url to: %s' % firebase_github.GITHUB_API_URL)
4747

4848
json_params = {}
4949
for param in args.param:
5050
json_params[param[0]] = param[1]
5151
if args.verbose or args.dryrun:
52-
print(f'request_url: {github.GITHUB_API_URL}/actions/workflows/{args.workflow}/dispatches')
52+
print(f'request_url: {firebase_github.GITHUB_API_URL}/actions/workflows/{args.workflow}/dispatches')
5353
print(f'request_body: ref: {args.branch}, inputs: {json_params}')
5454
if args.dryrun:
5555
return(0)
5656

5757
print('Sending request to GitHub API...')
58-
if not github.create_workflow_dispatch(args.token, args.workflow, args.branch, json_params):
58+
if not firebase_github.create_workflow_dispatch(args.token, args.workflow, args.branch, json_params):
5959
print('%sFailed to trigger workflow %s' % (
6060
'::error ::' if args.in_github_action else '', args.workflow))
6161
return(-1)
@@ -64,7 +64,7 @@ def main():
6464
time.sleep(args.sleep) # Give a few seconds for the job to become queued.
6565
# Unfortunately, the GitHub REST API doesn't return the new workflow's run ID.
6666
# Query the list of workflows to find the one we just added.
67-
workflows = github.list_workflows(args.token, args.workflow, args.branch)
67+
workflows = firebase_github.list_workflows(args.token, args.workflow, args.branch)
6868
run_id = 0
6969
if "workflow_runs" in workflows:
7070
branch_sha = subprocess.check_output(['git', 'rev-parse', args.branch]).decode('utf-8').rstrip('\n')
@@ -82,7 +82,7 @@ def main():
8282
else:
8383
# Couldn't get a run ID, use a generic URL.
8484
workflow_url = '%s/actions/workflows/%s?query=%s+%s' % (
85-
github.GITHUB_API_URL, args.workflow,
85+
firebase_github.GITHUB_API_URL, args.workflow,
8686
urllib.parse.quote('event:workflow_dispatch', safe=''),
8787
urllib.parse.quote('branch:'+args.branch, safe=''))
8888
print('%sStarted workflow %s: %s' % ('::warning ::' if args.in_github_action else '',

scripts/gha/update_issue_comment.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from absl import flags
3636
from absl import logging
3737

38-
import github
38+
import firebase_github
3939

4040
FLAGS = flags.FLAGS
4141

@@ -62,7 +62,7 @@
6262

6363
def get_issue_number(token, title, label):
6464
"""Get the GitHub isssue number for a given issue title and label"""
65-
issues = github.search_issues_by_label(label)
65+
issues = firebase_github.search_issues_by_label(label)
6666
for issue in issues:
6767
if issue["title"] == title:
6868
return issue["number"]
@@ -83,7 +83,7 @@ def main(argv):
8383
FLAGS.issue_title)
8484
logging.info("Found issue number: %d", issue_number)
8585

86-
previous_comment = github.get_issue_body(FLAGS.token, issue_number)
86+
previous_comment = firebase_github.get_issue_body(FLAGS.token, issue_number)
8787
if comment_start not in previous_comment:
8888
logging.fatal("Couldn't find start tag '%s' in previous comment", comment_start)
8989
if comment_end not in previous_comment:
@@ -98,7 +98,7 @@ def main(argv):
9898
new_text = sys.stdin.read()
9999
comment = prefix + comment_start + new_text + comment_end + suffix
100100

101-
github.update_issue_comment(FLAGS.token, issue_number, comment)
101+
firebase_github.update_issue_comment(FLAGS.token, issue_number, comment)
102102

103103

104104

0 commit comments

Comments
 (0)