Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ venv/
ENV/
env.bak/
venv.bak/
.envrc

# Spyder project settings
.spyderproject
Expand Down
22 changes: 18 additions & 4 deletions webhook_server_container/libs/github_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from webhook_server_container.utils.constants import (
ADD_STR,
APPROVED_BY_LABEL_PREFIX,
APPROVED_LABEL_STR,
BRANCH_LABEL_PREFIX,
BUILD_AND_PUSH_CONTAINER_STR,
BUILD_CONTAINER_STR,
Expand Down Expand Up @@ -555,7 +556,7 @@ def _error(_out: str, _err: str) -> None:

commands: List[str] = [
f"uvx {uv_cmd_dir} twine check {_dist_dir}/{tar_gz_file}",
f"uvx {uv_cmd_dir} twine upload --username __token__ --password {self.pypi["token"]} {_dist_dir}/{tar_gz_file} --skip-existing",
f"uvx {uv_cmd_dir} twine upload --username __token__ --password {self.pypi['token']} {_dist_dir}/{tar_gz_file} --skip-existing",
Comment thread
myakove marked this conversation as resolved.
]
for cmd in commands:
rc, out, err = run_command(command=cmd, log_prefix=self.log_prefix)
Expand Down Expand Up @@ -696,6 +697,12 @@ def label_by_user_comment(
label_func = self._remove_label if remove else self._add_label
label_func(label=user_requested_label)

def set_approved_check_queued(self) -> None:
return self.set_check_run_status(check_run=APPROVED_LABEL_STR, status=QUEUED_STR)

def set_approved_check_success(self, output: Dict[str, Any]) -> None:
return self.set_check_run_status(check_run=APPROVED_LABEL_STR, conclusion=SUCCESS_STR, output=output)

def set_verify_check_queued(self) -> None:
return self.set_check_run_status(check_run=VERIFIED_LABEL_STR, status=QUEUED_STR)

Expand Down Expand Up @@ -955,8 +962,15 @@ def process_pull_request_webhook_data(self) -> None:
if labeled.startswith(CHANGED_REQUESTED_BY_LABEL_PREFIX):
_reviewer = labeled.split(CHANGED_REQUESTED_BY_LABEL_PREFIX)[-1]

_approved_output: Dict[str, Any] = {"title": "Approved", "summary": "", "text": ""}
_approved = False
if _reviewer in self.approvers:
_check_for_merge = True
_approved = True
_approved_output["text"] += f"Approved by {_reviewer}.\n"

if _approved:
self.set_approved_check_success(output=_approved_output)

if self.verified_job and labeled == VERIFIED_LABEL_STR:
_check_for_merge = True
Expand Down Expand Up @@ -1401,7 +1415,7 @@ def check_if_can_be_merged(self) -> None:
missing_approvers = [approver for approver in self.approvers if approver != self.parent_committer]
failure_output += f"Missing lgtm/approved from approvers: {', '.join(missing_approvers)}\n"

if pr_approved and not failure_output:
if not failure_output:
self._add_label(label=CAN_BE_MERGED_STR)
self.set_merge_check_success()

Expand Down Expand Up @@ -1576,8 +1590,7 @@ def send_slack_message(self, message: str, webhook_url: str) -> None:
)
if response.status_code != 200:
raise ValueError(
f"Request to slack returned an error {response.status_code} with the following message: "
f"{response.text}"
f"Request to slack returned an error {response.status_code} with the following message: {response.text}"
)

def _process_verified_for_update_or_new_pull_request(self) -> None:
Expand Down Expand Up @@ -1620,6 +1633,7 @@ def process_opened_or_synchronize_pull_request(self) -> None:
prepare_pull_futures.append(executor.submit(self._process_verified_for_update_or_new_pull_request))
prepare_pull_futures.append(executor.submit(self.add_size_label))
prepare_pull_futures.append(executor.submit(self.add_pull_request_owner_as_assingee))
prepare_pull_futures.append(executor.submit(self.set_approved_check_queued))

prepare_pull_futures.append(executor.submit(self._run_tox))
prepare_pull_futures.append(executor.submit(self._run_pre_commit))
Expand Down
1 change: 1 addition & 0 deletions webhook_server_container/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
COMMENTED_BY_LABEL_PREFIX: str = "commented-"
BRANCH_LABEL_PREFIX: str = "branch-"
VERIFIED_LABEL_STR: str = "verified"
APPROVED_LABEL_STR: str = "approved"
NEEDS_REBASE_LABEL_STR: str = "needs-rebase"
HAS_CONFLICTS_LABEL_STR: str = "has-conflicts"
HOLD_LABEL_STR: str = "hold"
Expand Down
9 changes: 8 additions & 1 deletion webhook_server_container/utils/github_repository_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from webhook_server_container.libs.config import Config
from webhook_server_container.utils.constants import (
APPROVED_LABEL_STR,
BUILD_CONTAINER_STR,
CAN_BE_MERGED_STR,
IN_PROGRESS_STR,
Expand Down Expand Up @@ -108,6 +109,9 @@ def get_required_status_checks(
if data.get("pypi"):
default_status_checks.append(PYTHON_MODULE_INSTALL_STR)

if data.get("pre-commit"):
default_status_checks.append(PRE_COMMIT_STR)

with contextlib.suppress(UnknownObjectException):
repo.get_contents(".pre-commit-config.yaml")
default_status_checks.append("pre-commit.ci - pr")
Expand Down Expand Up @@ -161,7 +165,10 @@ def set_repositories_settings(config_: Config, github_api: Github) -> None:

logger.info("Processing repositories")
config_data = config_.data
default_status_checks: List[str] = config_data.get("default-status-checks", [])
default_status_checks: List[str] = config_data.get("default-status-checks", []) + [
CAN_BE_MERGED_STR,
APPROVED_LABEL_STR,
]
docker: Optional[Dict[str, str]] = config_data.get("docker")
if docker:
logger.info("Login in to docker.io")
Expand Down