make topic filter configurable

This commit is contained in:
Jörg Thalheim 2023-10-12 15:20:50 +02:00
parent dd95055cb6
commit cb35c312c1
4 changed files with 20 additions and 9 deletions

View file

@ -511,6 +511,7 @@ class GithubConfig:
webhook_secret_name: str = "github-webhook-secret"
token_secret_name: str = "github-token"
project_cache_file: Path = Path("github-project-cache.json")
topic_filter: str | None = "build-with-buildbot"
def token(self) -> str:
return read_secret_file(self.token_secret_name)
@ -633,7 +634,8 @@ class NixConfigurator(ConfiguratorBase):
def configure(self, config: dict[str, Any]) -> None:
projects = load_projects(self.github.token(), self.github.project_cache_file)
projects = [p for p in projects if "build-with-buildbot" in p.topics]
if self.github.topic_filter is not None:
projects = [p for p in projects if self.github.topic_filter in p.topics]
worker_config = json.loads(read_secret_file(self.nix_workers_secret_name))
worker_names = []
config["workers"] = config.get("workers", [])

View file

@ -29,8 +29,8 @@ in
webhookSecretFile = "/var/lib/secrets/buildbot-nix/github-webhook-secret";
oauthSecretFile = "/var/lib/secrets/buildbot-nix/github-oauth-secret";
oauthId = "aaaaaaaaaaaaaaaaaaaa";
githubUser = "mic92-buildbot";
githubAdmins = [ "Mic92" ];
user = "mic92-buildbot";
admins = [ "Mic92" ];
};
};
services.nginx.virtualHosts."buildbot2.thalheim.io" = {

View file

@ -15,8 +15,8 @@
webhookSecretFile = "/var/lib/secrets/buildbot-nix/github-webhook-secret";
oauthSecretFile = "/var/lib/secrets/buildbot-nix/github-oauth-secret";
oauthId = "aaaaaaaaaaaaaaaaaaaa";
githubUser = "mic92-buildbot";
githubAdmins = [ "Mic92" ];
user = "mic92-buildbot";
admins = [ "Mic92" ];
};
};
};

View file

@ -39,15 +39,23 @@ in
description = "Github oauth id. Used for the login button";
};
# Most likely you want to use the same user as for the buildbot
githubUser = lib.mkOption {
user = lib.mkOption {
type = lib.types.str;
description = "Github user that is used for the buildbot";
};
githubAdmins = lib.mkOption {
admins = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
description = "Users that are allowed to login to buildbot, trigger builds and change settings";
};
topic = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = "build-with-buildbot";
description = ''
Projects that have this topic will be built by buildbot.
If null, all projects that the buildbot github user has access to, are built.
'';
};
};
workersFile = lib.mkOption {
type = lib.types.path;
@ -97,8 +105,9 @@ in
NixConfigurator(
github=GithubConfig(
oauth_id=${builtins.toJSON cfg.github.oauthId},
admins=${builtins.toJSON cfg.github.githubAdmins},
buildbot_user=${builtins.toJSON cfg.github.githubUser},
admins=${builtins.toJSON cfg.github.admins},
buildbot_user=${builtins.toJSON cfg.github.user},
topic=${builtins.toJSON cfg.github.topic},
),
nix_eval_max_memory_size=${builtins.toJSON cfg.evalMaxMemorySize},
nix_supported_systems=${builtins.toJSON cfg.buildSystems},