mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
Merge pull request #36412 from ClickHouse/pr-info-api-fallback
Fallback to a default event data when API is broken
This commit is contained in:
commit
fac600830e
@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
|
||||
from unidiff import PatchSet # type: ignore
|
||||
@ -98,12 +99,20 @@ class PRInfo:
|
||||
if "pull_request" in github_event: # pull request and other similar events
|
||||
self.number = github_event["pull_request"]["number"]
|
||||
if pr_event_from_api:
|
||||
response = get_with_retries(
|
||||
f"https://api.github.com/repos/{GITHUB_REPOSITORY}"
|
||||
f"/pulls/{self.number}",
|
||||
sleep=RETRY_SLEEP,
|
||||
)
|
||||
github_event["pull_request"] = response.json()
|
||||
try:
|
||||
response = get_with_retries(
|
||||
f"https://api.github.com/repos/{GITHUB_REPOSITORY}"
|
||||
f"/pulls/{self.number}",
|
||||
sleep=RETRY_SLEEP,
|
||||
)
|
||||
github_event["pull_request"] = response.json()
|
||||
except Exception as e:
|
||||
logging.warning(
|
||||
"Unable to get pull request event %s from API, "
|
||||
"fallback to received event. Exception: %s",
|
||||
self.number,
|
||||
e,
|
||||
)
|
||||
|
||||
if "after" in github_event:
|
||||
self.sha = github_event["after"]
|
||||
|
Loading…
Reference in New Issue
Block a user