2021-09-29 07:47:15 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import logging
|
2024-02-06 12:39:34 +00:00
|
|
|
|
|
|
|
# isort: off
|
2021-10-27 07:03:23 +00:00
|
|
|
from github import Github
|
2021-11-26 14:00:09 +00:00
|
|
|
|
2024-02-06 12:39:34 +00:00
|
|
|
# isort: on
|
|
|
|
|
2023-04-06 09:40:32 +00:00
|
|
|
from commit_status_helper import (
|
2023-04-20 11:55:33 +00:00
|
|
|
CI_STATUS_NAME,
|
2023-04-06 09:40:32 +00:00
|
|
|
get_commit,
|
|
|
|
get_commit_filtered_statuses,
|
|
|
|
post_commit_status,
|
2023-08-07 16:06:50 +00:00
|
|
|
update_mergeable_check,
|
2023-04-06 09:40:32 +00:00
|
|
|
)
|
2023-04-20 11:55:33 +00:00
|
|
|
from get_robot_token import get_best_robot_token
|
|
|
|
from pr_info import PRInfo
|
2024-02-06 12:39:34 +00:00
|
|
|
from report import PENDING, SUCCESS
|
2021-09-29 07:47:15 +00:00
|
|
|
|
2021-11-26 14:00:09 +00:00
|
|
|
|
2023-04-20 11:55:33 +00:00
|
|
|
def main():
|
2021-09-29 07:47:15 +00:00
|
|
|
logging.basicConfig(level=logging.INFO)
|
|
|
|
|
2021-11-26 14:00:09 +00:00
|
|
|
pr_info = PRInfo(need_orgs=True)
|
2022-07-30 05:07:22 +00:00
|
|
|
gh = Github(get_best_robot_token(), per_page=100)
|
2021-09-29 07:47:15 +00:00
|
|
|
commit = get_commit(gh, pr_info.sha)
|
2023-12-21 10:53:01 +00:00
|
|
|
# Update the Mergeable Check at the final step
|
|
|
|
update_mergeable_check(commit, pr_info, CI_STATUS_NAME)
|
2021-09-29 07:47:15 +00:00
|
|
|
|
2023-04-20 11:55:33 +00:00
|
|
|
statuses = [
|
|
|
|
status
|
|
|
|
for status in get_commit_filtered_statuses(commit)
|
|
|
|
if status.context == CI_STATUS_NAME
|
|
|
|
]
|
|
|
|
if not statuses:
|
|
|
|
return
|
2023-08-07 16:06:50 +00:00
|
|
|
# Take the latest status
|
|
|
|
status = statuses[-1]
|
2024-02-06 12:39:34 +00:00
|
|
|
if status.state == PENDING:
|
2023-04-20 11:55:33 +00:00
|
|
|
post_commit_status(
|
|
|
|
commit,
|
2024-02-06 12:39:34 +00:00
|
|
|
SUCCESS,
|
2023-12-18 08:07:22 +00:00
|
|
|
status.target_url,
|
2023-04-20 11:55:33 +00:00
|
|
|
"All checks finished",
|
|
|
|
CI_STATUS_NAME,
|
|
|
|
pr_info,
|
2023-12-18 08:07:22 +00:00
|
|
|
dump_to_file=True,
|
2023-04-20 11:55:33 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|