Add debug and fix cancel_rerun lambda

This commit is contained in:
Mikhail f. Shiryaev 2022-04-08 12:28:25 +02:00
parent 53793537da
commit 811178da54
No known key found for this signature in database
GPG Key ID: 4B02ED204C7D93F4

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from collections import namedtuple from collections import namedtuple
from typing import Any, Dict
import json import json
import time import time
@ -21,6 +22,8 @@ API_URL = "https://api.github.com/repos/ClickHouse/ClickHouse"
MAX_RETRY = 5 MAX_RETRY = 5
DEBUG_INFO = {} # type: Dict[str, Any]
def get_installation_id(jwt_token): def get_installation_id(jwt_token):
headers = { headers = {
@ -110,6 +113,10 @@ def get_workflows_description_for_pull_request(pull_request_event):
workflow_descriptions = [] workflow_descriptions = []
for workflow in workflows_data: for workflow in workflows_data:
DEBUG_INFO["workflow"] = workflow
# Some time workflow["head_repository"]["full_name"] is None
if workflow["head_repository"] is None:
continue
# unfortunately we cannot filter workflows from forks in request to API # unfortunately we cannot filter workflows from forks in request to API
# so doing it manually # so doing it manually
if ( if (
@ -162,7 +169,8 @@ def exec_workflow_url(urls_to_cancel, token):
def main(event): def main(event):
token = get_token_from_aws() token = get_token_from_aws()
event_data = json.loads(event["body"]) DEBUG_INFO["event_body"] = event["body"]
event_data = event["body"]
print("Got event for PR", event_data["number"]) print("Got event for PR", event_data["number"])
action = event_data["action"] action = event_data["action"]
@ -210,4 +218,9 @@ def main(event):
def handler(event, _): def handler(event, _):
main(event) try:
main(event)
except Exception:
for name, value in DEBUG_INFO.items():
print(f"Value of {name}: ", value)
raise