Skip to content
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

nix: enable buildbot badges #90

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

Conversation

zimbatm
Copy link
Member

@zimbatm zimbatm commented Jan 30, 2024

Just enough config to make this easily extensible in the future.

@zimbatm
Copy link
Member Author

zimbatm commented Jan 30, 2024

It needs more work. When deploying this, the process starts fine, but nginx still return 500 errors.

nix/master.nix Outdated

extraConfig = ''
# WOOT
c['www'] = json.loads(
Copy link
Member

@Mic92 Mic92 Jan 30, 2024

Choose a reason for hiding this comment

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

I think you are overwriting existing www settings here.

c['www'].update(json.loads(${builtins.toJSON www_config}))

I kind of avoided using extraConfig just now because the ordering is not clear to me. It might be also an option to pass it to the configurator above and merge it there.

Copy link
Member

@Mic92 Mic92 Jan 30, 2024

Choose a reason for hiding this comment

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

the upstream nixos module currently does this:

  defaultMasterCfg = pkgs.writeText "master.cfg" ''
    from buildbot.plugins import *
    ${cfg.extraImports}
    factory = util.BuildFactory()
    c = BuildmasterConfig = dict(
     workers       = [${concatStringsSep "," cfg.workers}],
     protocols     = { 'pb': {'port': ${toString cfg.pbPort} } },
     title         = '${escapeStr cfg.title}',
     titleURL      = '${escapeStr cfg.titleUrl}',
     buildbotURL   = '${escapeStr cfg.buildbotUrl}',
     db            = dict(db_url='${escapeStr cfg.dbUrl}'),
     www           = dict(port=${toString cfg.port}),
     change_source = [ ${concatStringsSep "," cfg.changeSource} ],
     schedulers    = [ ${concatStringsSep "," cfg.schedulers} ],
     builders      = [ ${concatStringsSep "," cfg.builders} ],
     services      = [ ${concatStringsSep "," cfg.reporters} ],
     configurators = [ ${concatStringsSep "," cfg.configurators} ],
    )
    for step in [ ${concatStringsSep "," cfg.factorySteps} ]:
      factory.addStep(step)

    ${cfg.extraConfig}
  '';

Maybe it should more look like this:

  defaultMasterCfg = pkgs.writeText "master.cfg" ''
    from buildbot.plugins import *
    ${cfg.extraImports}
    factory = util.BuildFactory()
    c = BuildmasterConfig = dict(
     workers       = [${concatStringsSep "," cfg.workers}],
     protocols     = { 'pb': {'port': ${toString cfg.pbPort} } },
     title         = '${escapeStr cfg.title}',
     titleURL      = '${escapeStr cfg.titleUrl}',
     buildbotURL   = '${escapeStr cfg.buildbotUrl}',
     db            = dict(db_url='${escapeStr cfg.dbUrl}'),
     www           = dict(port=${toString cfg.port}, **json.load(${builtins.toJSON www_config})),
     change_source = [ ${concatStringsSep "," cfg.changeSource} ],
     schedulers    = [ ${concatStringsSep "," cfg.schedulers} ],
     builders      = [ ${concatStringsSep "," cfg.builders} ],
     services      = [ ${concatStringsSep "," cfg.reporters} ],
     configurators = [ ${concatStringsSep "," cfg.configurators} ],
    )
    for step in [ ${concatStringsSep "," cfg.factorySteps} ]:
      factory.addStep(step)

    ${cfg.extraConfig}
  '';

Copy link
Member

Choose a reason for hiding this comment

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

Mhm. I though about it and it might be not feasible with just plain json:

i.e you need classes in there:

            config["www"]["auth"] = util.GitHubAuth(
                self.github.oauth_id,
                read_secret_file(self.github.oauth_secret_name),
                apiVersion=4,
            )

Copy link
Member Author

Choose a reason for hiding this comment

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

Taking a step back, it's probably only worth doing something like this either directly upstream, or by merging the upstream module into this one. Otherwise both are fighting to control the base data structures.

We could have "settings" that also supports python code snippets as a value type. It wouldn't be great for programming, but probably OK for small snippets like that.

The other option is to have a pure data-only pass to fill the tree, and then ask the user to complement it with code snippest in a second pass.

@zimbatm
Copy link
Member Author

zimbatm commented Jan 31, 2024

https://github.com/buildbot/buildbot/blob/bb4354043f45be5f32e80deb90896a96fcfa3971/www/badges/buildbot_badges/__init__.py#L84-L94

This plugin may not work for us. Our builder names have slashes in them and I think their router doesn't support that.

@Mic92
Copy link
Member

Mic92 commented Jul 13, 2024

This one might help: buildbot/buildbot#7805

@Mic92
Copy link
Member

Mic92 commented Jul 13, 2024

Might be fixed with: buildbot/buildbot#7805

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.

2 participants