Reformat gitea_projects.py, __init__.py, and github_projects.py

Signed-off-by: magic_rb <richard@brezak.sk>
This commit is contained in:
magic_rb 2024-07-24 21:22:46 +02:00
parent 19d5cdd29a
commit 0ecf33f8d4
Failed to generate hash of commit
4 changed files with 32 additions and 12 deletions

View file

@ -533,7 +533,7 @@ def nix_build_config(
updateSourceStamp=False,
doStepIf=do_register_gcroot_if,
copy_properties=["out_path", "attr"],
set_properties={"report_status": False}
set_properties={"report_status": False},
),
)
factory.addStep(
@ -598,7 +598,7 @@ def nix_skipped_build_config(
updateSourceStamp=False,
doStepIf=do_register_gcroot_if,
copy_properties=["out_path", "attr"],
set_properties={"report_status": False}
set_properties={"report_status": False},
),
)
return util.BuilderConfig(
@ -643,6 +643,7 @@ def nix_register_gcroot_config(
factory=factory,
)
def nix_build_combined_config(
project: GitProject,
worker_names: list[str],

View file

@ -180,4 +180,3 @@ def filter_for_combined_builds(reports: Any) -> Any | None:
if "report_status" in properties and not properties["report_status"][0]:
return None
return reports

View file

@ -1,7 +1,8 @@
import os
import signal
from collections.abc import Callable
from pathlib import Path
from typing import Any, Callable
from typing import Any
from urllib.parse import urlparse
from buildbot.config.builder import BuilderConfig
@ -13,9 +14,9 @@ from buildbot.www.avatar import AvatarBase
from buildbot_gitea.auth import GiteaAuth # type: ignore[import]
from buildbot_gitea.reporter import GiteaStatusPush # type: ignore[import]
from pydantic import BaseModel
from twisted.internet import defer
from twisted.logger import Logger
from twisted.python import log
from twisted.internet import defer
from .common import (
ThreadDeferredBuildStep,
@ -106,13 +107,22 @@ class GiteaProject(GitProject):
# TODO Gitea doesn't include this information
return False # self.data["owner"]["type"] == "Organization"
class ModifyingGiteaStatusPush(GiteaStatusPush):
def checkConfig(self, modifyingFilter: Callable[[Any], Any | None] = lambda x: x, **kwargs: Any) -> Any:
def checkConfig(
self,
modifyingFilter: Callable[[Any], Any | None] = lambda x: x, # noqa: N803
**kwargs: Any,
) -> Any:
self.modifyingFilter = modifyingFilter
return super().checkConfig(**kwargs)
def reconfigService(self, modifyingFilter: Callable[[Any], Any | None] = lambda x: x, **kwargs: Any) -> Any:
def reconfigService(
self,
modifyingFilter: Callable[[Any], Any | None] = lambda x: x, # noqa: N803
**kwargs: Any,
) -> Any:
self.modifyingFilter = modifyingFilter
return super().reconfigService(**kwargs)

View file

@ -2,10 +2,11 @@ import json
import os
import signal
from abc import ABC, abstractmethod
from collections.abc import Callable
from dataclasses import dataclass
from itertools import starmap
from pathlib import Path
from typing import Any, Callable
from typing import Any
from buildbot.config.builder import BuilderConfig
from buildbot.plugins import util
@ -18,9 +19,9 @@ from buildbot.www.auth import AuthBase
from buildbot.www.avatar import AvatarBase, AvatarGitHub
from buildbot.www.oauth2 import GitHubAuth
from pydantic import BaseModel, ConfigDict, Field
from twisted.internet import defer
from twisted.logger import Logger
from twisted.python import log
from twisted.internet import defer
from .common import (
ThreadDeferredBuildStep,
@ -311,13 +312,22 @@ class GithubAuthBackend(ABC):
) -> list[BuildStep]:
pass
class ModifyingGitHubStatusPush(GitHubStatusPush):
def checkConfig(self, modifyingFilter: Callable[[Any], Any | None] = lambda x: x, **kwargs: Any) -> Any:
def checkConfig(
self,
modifyingFilter: Callable[[Any], Any | None] = lambda x: x, # noqa: N803
**kwargs: Any,
) -> Any:
self.modifyingFilter = modifyingFilter
return super().checkConfig(**kwargs)
def reconfigService(self, modifyingFilter: Callable[[Any], Any | None] = lambda x: x, **kwargs: Any) -> Any:
def reconfigService(
self,
modifyingFilter: Callable[[Any], Any | None] = lambda x: x, # noqa: N803
**kwargs: Any,
) -> Any:
self.modifyingFilter = modifyingFilter
return super().reconfigService(**kwargs)
@ -331,6 +341,7 @@ class ModifyingGitHubStatusPush(GitHubStatusPush):
result = yield super().sendMessage(reports)
return result
class GithubLegacyAuthBackend(GithubAuthBackend):
auth_type: GitHubLegacyConfig
@ -438,7 +449,6 @@ class GithubAppAuthBackend(GithubAuthBackend):
self.project_id_map[props["projectname"]]
].get()
return ModifyingGitHubStatusPush(
token=WithProperties("%(github_token)s", github_token=get_github_token),
# Since we dynamically create build steps,