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

Dynamic build group membership via file #1099

Closed
mathstuf opened this issue Dec 16, 2020 · 11 comments
Closed

Dynamic build group membership via file #1099

mathstuf opened this issue Dec 16, 2020 · 11 comments

Comments

@mathstuf
Copy link
Contributor

Dynamic build groups are great, but maintaining them is a pain. It'd be nice if it were possible to host a file containing the list of expected builds in a repository and have CDash fetch it periodically (daily seems reasonable).

Something like:

[
  { "from-group": "master", "site": "gitlab-ci", "build-name": { "operation": "contains", "name": "[fedora31-plain]" }
]

Syntax can be bikeshed (JSON vs. YAML; no idea which is easier for CDash). If an update is invalid, an email should be sent to administrator(s) of the project and the last-valid state should be used instead (verifying that it is valid upon initial submission of the URL).

Each dynamic group should be able to use its own URL (e.g., ParaView's CDash gets info from paraview/paraview and paraview/paraview-superbuild and has a dynamic group for each).

@zackgalbreath
Copy link
Contributor

We actually have something kinda like this in CDash already. Our API (which needs better documentation) accepts a list of dynamic builds via PUT. Here's an example of how to use it in python:

#!/usr/bin/env python

import requests
import sys

if __name__ == "__main__":
    headers = {"Authorization": "Bearer <token goes here>"}
    url = "https://<cdash-url>/api/v1/buildgroup.php"
    payload = {
      "projectid": 1,
      "buildgroupid": 7,
      "dynamiclist": [
        { "match": 'foo', "parentgroupid": 15, "siteid": 22, },
        { "match": 'bar', "parentgroupid": 15, "siteid": 22, },
        { "match": 'baz', "parentgroupid": 15, "siteid": 22, },
      ]
    }
    r = requests.put(url, json=payload, headers=headers)
    if not r.ok:
      print("Problem: {0} / {1}\n".format(r.status_code, r.text))
      sys.exit(1)
    else:
      print "success"

It's a little fiddly since you need to know numeric ids for your project, source group, and destination group. Nonetheless, let me know if this would serve for your use case, or if you had something else in mind.

@mathstuf
Copy link
Contributor Author

Nifty :) . If we could programmatically grab the id numbers, this could be made into a script that we run instead of having CDash fetch it for us. Are there endpoints for that?

@zackgalbreath
Copy link
Contributor

Yes. For ParaView specifically, this one should give you everything you need:

https://open.cdash.org/api/v1/manageBuildGroup.php?projectid=9

Please let us know if anything is missing.

@mathstuf
Copy link
Contributor Author

Hmm, that just gives requireslogin: 1 for me. Are there docs on the auth requirements?

@mathstuf
Copy link
Contributor Author

Ah, I think I found this which is probably a decent starting point: https://www.paraview.org/Wiki/CDash:API

@zackgalbreath
Copy link
Contributor

Yup, you found it. Particularly the "auth token" section. If you're doing this from a script you'll need to provide that as a Bearer Token in the header, as I demonstrated above.

@mathstuf
Copy link
Contributor Author

I made a token on open.cdash.org, but it is still saying 'requirelogin: 1when I pass that token as anAuthorization` header. I tried doing the login mentioned on the wiki, but it is CSRF-guarded.

@mathstuf
Copy link
Contributor Author

It's a 401 HTTP error if that helps.

@zackgalbreath
Copy link
Contributor

Thanks for giving it a shot, I'll take a closer look & let you know what I find.

@zackgalbreath
Copy link
Contributor

Hey Ben,

Thanks for pointing this out. It turns out that we weren't consistently checking for bearer tokens across all our API endpoints. This is fixed now.

Let us know if you run into any more trouble setting this up.

@mathstuf
Copy link
Contributor Author

There is now this script which can use files which look like this.

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

No branches or pull requests

2 participants