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, updateSourceStamp=False,
doStepIf=do_register_gcroot_if, doStepIf=do_register_gcroot_if,
copy_properties=["out_path", "attr"], copy_properties=["out_path", "attr"],
set_properties={"report_status": False} set_properties={"report_status": False},
), ),
) )
factory.addStep( factory.addStep(
@ -598,7 +598,7 @@ def nix_skipped_build_config(
updateSourceStamp=False, updateSourceStamp=False,
doStepIf=do_register_gcroot_if, doStepIf=do_register_gcroot_if,
copy_properties=["out_path", "attr"], copy_properties=["out_path", "attr"],
set_properties={"report_status": False} set_properties={"report_status": False},
), ),
) )
return util.BuilderConfig( return util.BuilderConfig(
@ -643,6 +643,7 @@ def nix_register_gcroot_config(
factory=factory, factory=factory,
) )
def nix_build_combined_config( def nix_build_combined_config(
project: GitProject, project: GitProject,
worker_names: list[str], 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]: if "report_status" in properties and not properties["report_status"][0]:
return None return None
return reports return reports

View file

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

View file

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