Skip to content

Add users option to both GitHub and Gitea restricting project owners #394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MagicRB
Copy link
Contributor

@MagicRB MagicRB commented Feb 12, 2025

Hopefully closes #393

@MagicRB MagicRB marked this pull request as draft February 12, 2025 11:25
@MagicRB MagicRB force-pushed the add-users-option branch 2 times, most recently from 507b5ed to 1d57aab Compare February 12, 2025 13:11
@MagicRB
Copy link
Contributor Author

MagicRB commented Feb 12, 2025

@zowoq this looks good? I tested the Gitea backend at it works, didn't test the GitHub one as I don't have GitHub setup, but it should work. @Mic92 can you test?

@MagicRB MagicRB marked this pull request as ready for review February 12, 2025 13:12
@zowoq
Copy link
Contributor

zowoq commented Feb 13, 2025

Tested removing the topic and using only the repoAllowlist in nix-community, adding/removing repos works, did need to change the buildbot-nix topic default from build-with-buildbot to null.

-      topic = "nix-community-buildbot";
+      repoAllowlist = [
+        "nix-community/authentik-nix"
+        "nix-community/autofirma-nix"
+        "nix-community/dream2nix"
+        "nix-community/ethereum.nix"
+        "nix-community/infra"
+        "nix-community/lanzaboote"
+        "nix-community/neovim-nightly-overlay"
+        "nix-community/nix-direnv"
+        "nix-community/nix-index"
+        "nix-community/nix4nvchad"
+        "nix-community/NixNG"
+        "nix-community/nixos-facter"
+        "nix-community/nixos-facter-modules"
+        "nix-community/nixos-generators"
+        "nix-community/nixos-images"
+        "nix-community/nixpkgs-update"
+        "nix-community/nixpkgs-xr"
+        "nix-community/nixvim"
+        "nix-community/raspberry-pi-nix"
+        "nix-community/srvos"
+      ];
diff --git a/nix/master.nix b/nix/master.nix
index 2a75c8f74..3a3fc8854 100644
--- a/nix/master.nix
+++ b/nix/master.nix
@@ -374,7 +374,7 @@ in
         };
         topic = lib.mkOption {
           type = lib.types.nullOr lib.types.str;
-          default = "build-with-buildbot";
+          default = null;
           description = ''
             Projects that have this topic will be built by buildbot.
             If null, all projects that the buildbot Gitea user has access to, are built.
@@ -453,7 +453,7 @@ in
         };
         topic = lib.mkOption {
           type = lib.types.nullOr lib.types.str;
-          default = "build-with-buildbot";
+          default = null;
           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.

@MagicRB
Copy link
Contributor Author

MagicRB commented Feb 13, 2025

You should be able to just set it to null no? I think that building everything by default is not a good idea.

@Mic92
Copy link
Member

Mic92 commented Feb 13, 2025

You should be able to just set it to null no? I think that building everything by default is not a good idea.

I think this was just for testing not intended as the new default.

nix/master.nix Outdated
userAllowlist = lib.mkOption {
type = lib.types.nullOr (lib.types.listOf lib.types.str);
default = null;
description = "If non-null, specifies users/organizations that are allowed to use buildbot, i.e. buildbot-nix will ignore any repositories not owned by these users/organizations.";
Copy link
Member

@Mic92 Mic92 Feb 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mention here that this in addition to the buildbot github topic?

@zowoq
Copy link
Contributor

zowoq commented Feb 13, 2025

You should be able to just set it to null no? I think that building everything by default is not a good idea.

I think this was just for testing not intended as the new default.

Was kind of thinking of a new default. Could have an assert requiring that one or more of topic, userAllowlist, repoAllowlist is set? But maybe not be worth the disruption for other users.

@zowoq
Copy link
Contributor

zowoq commented May 23, 2025

Can we move forward with this?

@zowoq zowoq force-pushed the add-users-option branch from 1d57aab to 24f1150 Compare June 6, 2025 01:55
@zowoq
Copy link
Contributor

zowoq commented Jun 6, 2025

I've rebased to fix the merge conflict, are we okay with merging?

@Mic92
Copy link
Member

Mic92 commented Jun 6, 2025

@zowoq please merge if you have tested it in nix-community.

description = "If non-null, specifies users/organizations that are allowed to use buildbot, i.e. buildbot-nix will ignore any repositories not owned by these users/organizations.";
};

repoAllowlist = lib.mkOption {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be cool if you could add those options also to https://github.com/nix-community/buildbot-nix/blob/main/examples/master.nix
To have same example-driven documentation.

@zowoq
Copy link
Contributor

zowoq commented Jun 7, 2025

reload_github_projects fails when an a repo / github installation is removed, seems the various buildbot github app / project json files that are cached aren't regenerated so it fails trying to access the removed repo / installation.

Failed to reload project list: Traceback (most recent call last):
  File "/nix/store/hyrcaa8b7dqigaaailf3hh6ixfsp0hnj-python3-3.12.10-env/lib/python3.12/site-packages/twisted/python/threadpool.py", line 269, in inContext
    result = inContext.theWork()  # type: ignore[attr-defined]
  File "/nix/store/hyrcaa8b7dqigaaailf3hh6ixfsp0hnj-python3-3.12.10-env/lib/python3.12/site-packages/twisted/python/threadpool.py", line 285, in <lambda>
    inContext.theWork = lambda: context.call(  # type: ignore[attr-defined]
  File "/nix/store/hyrcaa8b7dqigaaailf3hh6ixfsp0hnj-python3-3.12.10-env/lib/python3.12/site-packages/twisted/python/context.py", line 117, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/nix/store/hyrcaa8b7dqigaaailf3hh6ixfsp0hnj-python3-3.12.10-env/lib/python3.12/site-packages/twisted/python/context.py", line 82, in callWithContext
    return func(*args, **kw)
  File "/nix/store/hyrcaa8b7dqigaaailf3hh6ixfsp0hnj-python3-3.12.10-env/lib/python3.12/site-packages/buildbot_nix/github_projects.py", line 193, in run_deferred
    v.get(),
  File "/nix/store/hyrcaa8b7dqigaaailf3hh6ixfsp0hnj-python3-3.12.10-env/lib/python3.12/site-packages/buildbot_nix/github/installation_token.py", line 99, in get
    self.verify()
  File "/nix/store/hyrcaa8b7dqigaaailf3hh6ixfsp0hnj-python3-3.12.10-env/lib/python3.12/site-packages/buildbot_nix/github/installation_token.py", line 107, in verify
    self.token, self.expiration = InstallationToken._generate_token(
  File "/nix/store/hyrcaa8b7dqigaaailf3hh6ixfsp0hnj-python3-3.12.10-env/lib/python3.12/site-packages/buildbot_nix/github/installation_token.py", line 46, in _generate_token
    token = InstallationToken._create_installation_access_token(
  File "/nix/store/hyrcaa8b7dqigaaailf3hh6ixfsp0hnj-python3-3.12.10-env/lib/python3.12/site-packages/buildbot_nix/github/installation_token.py", line 35, in _create_installation_access_token
    return http_request(
  File "/nix/store/hyrcaa8b7dqigaaailf3hh6ixfsp0hnj-python3-3.12.10-env/lib/python3.12/site-packages/buildbot_nix/common.py", line 98, in http_request
    raise HttpError(msg) from e
buildbot_nix.common.HttpError: Request for POST https://api.github.com/app/installations/70038369/access_tokens failed with 404 Not Found: {"message":"Not Found","documentation_url":"https://docs.github.com/rest/reference/apps#create-an-installation-access-token-for-an-app","status":"404"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add way to ignore installations based on the owner of the repository
3 participants