shields icon indicating copy to clipboard operation
shields copied to clipboard

Badge request: Copr Build System

Open xsuchy opened this issue 5 years ago • 11 comments

The Copr build system: https://copr.fedorainfracloud.org/ provides badges showing the status of the build (fail, success,s or in progress).

An example of such badge is: https://copr.fedorainfracloud.org/coprs/g/copr/copr/package/copr-backend/status_image/last_build.png The documentation is here: https://docs.pagure.org/copr.copr/user_documentation.html#status-badges

The format is

  • https://copr.fedorainfracloud.org/coprs///package/<package_name>/status_image/last_build.png for a user. If it is team (group) project, then:
  • https://copr.fedorainfracloud.org/coprs/g/<group_name>//package/<package_name>/status_image/last_build.png

Motivation: Better visibility that there is an option to add badges on your project page. E.g. like we have on https://pagure.io/copr/copr/

Love Shields? Please consider donating $10 to sustain our activities:

Done. Thank you for the service.

xsuchy avatar Jan 20 '21 11:01 xsuchy

In order for Shields to be able to provide badges for a service, we need to be able to retrieve the raw data over HTTP, with a strong preference for REST APIs. In a handful of the somewhat more exceptional cases we are able to get the requisite data by scraping svg badges provided by the upstream provider, but we definitely cannot scrape someone else's pngs.

Do you have any information you could share about the API? I'm having trouble finding anything other than this short page that in turn just points the docs for a python client, which isn't a viable option for us.

calebcartwright avatar Jan 31 '21 00:01 calebcartwright

You can retrieve the data in JSON from:

https://copr.fedorainfracloud.org/api_3/package?ownername=OWNER&projectname=PROJECT&packagename=PACKAGE&with_latest_build=True

e.g.: The last status of https://copr.fedorainfracloud.org/coprs/msuchy/nanoblogger/package/nanoblogger/ is:

https://copr.fedorainfracloud.org/api_3/package?ownername=msuchy&projectname=nanoblogger&packagename=nanoblogger&with_latest_build=True

when the OWNER is a group then it starts with @. E.g.: the last status of https://copr.fedorainfracloud.org/coprs/g/mock/mock/package/mock-core-configs/ is

https://copr.fedorainfracloud.org/api_3/package?ownername=@mock&projectname=mock&packagename=mock-core-configs&with_latest_build=True

The result is JSON and you are interested in builds/latest/state which can be one of these (pasted from code with description):

        "failed": "Build failed. See logs for more details.",
        "succeeded": "Successfully built.",                                                                                                                                                  
        "canceled": "The build has been cancelled manually.",
        "running": "Build in progress.",
        "pending": "Build is waiting in queue for a backend worker.",
        "skipped": "This package has already been built previously.",
        "starting": "Backend worker is trying to acquire a builder machine.",
        "importing": "Package sources are being imported into Copr DistGit.",
        "waiting": "Task is waiting for something else to finish.",
        "imported": "Package was successfully imported into Copr DistGit.",
        "forked": "Build has been forked from another build.",

xsuchy avatar Jan 31 '21 01:01 xsuchy

Thanks that's helpful! Is the endpoint documented any where?

calebcartwright avatar Jan 31 '21 01:01 calebcartwright

https://copr.fedoraproject.org/api/ says we need a token, but the example calls posted seem to allow anonymous access :thinking: It would be useful to know if any rate limits apply for anonymous access

chris48s avatar Jan 31 '21 14:01 chris48s

The endpoints are not documented. :( I never realized that - as we use the python bindings. I will raise this and we will try do something about it. Though, it will likely take few weeks till it gets to the top of our TODO list. The token is needed only for actions that modify something. For queries, it is not needed. There are no rate limits at all.

xsuchy avatar Feb 01 '21 08:02 xsuchy

The endpoints are not documented. :( I never realized that - as we use the python bindings. I will raise this and we will try do something about it.

No worries, and thanks for raising that! This doesn't need to block us, but if/when the docs become available it'd be great if someone could drop us a note to let us know. We just integrate with so many upstream tools/services, many of which we have 0 familiarity with, that every bit of documentation is extremely helpful.

calebcartwright avatar Feb 01 '21 21:02 calebcartwright

Hi, has there been any progress on copr badges? This would be quite nice to have.

pbrezina avatar Oct 19 '21 11:10 pbrezina

If anyone wants :)

https://img.shields.io/badge/dynamic/json?color=blue&label=copr&query=builds.latest.state&url=YOUR_URL_HERE

URL (replace OWNER, PROJECT and PACKAGE with copr ones)

https://copr.fedorainfracloud.org/api_3/package?ownername=OWNER&projectname=PROJECT&packagename=PACKAGE&with_latest_build=True

Then copy your edited URL and paste it instead of YOUR_URL_HERE

daudix avatar Aug 22 '22 03:08 daudix

Works great :+1: Of course the copr url has to be URL-encoded.

felfert avatar Jun 07 '23 21:06 felfert

To follow up request in comment 1 - we already have documentation to API https://copr.fedorainfracloud.org/api_3/docs

xsuchy avatar Jun 08 '23 12:06 xsuchy

It seems like the requisite pieces are indeed in place to be able to move forward with adding this badge!

While we'd like to see it, I think it's highly unlikely that any maintainers will have bandwidth to add this badge ourselves. We've got a pretty thorough tutorial for adding new badges if anyone would like to work on it, and we're happy to answer any questions along the way.

calebcartwright avatar Jun 18 '23 19:06 calebcartwright