bisect_ppx icon indicating copy to clipboard operation
bisect_ppx copied to clipboard

Emit JSON for a Shields.io badge in the HTML report

Open aantron opened this issue 4 years ago • 23 comments

See https://shields.io/endpoint. This will allow an uploaded report to be used for rendering coverage percentages with shields.io. The server probably has to know to set the right Content-Type, though.

{
  "schemaVersion": 1,
  "label": "hello",
  "message": "sweet world",
  "color": "orange"
}

I would still use Coveralls for the bot and GitHub status, but link to the Bisect_ppx report and use its badge for the more accurate statistics (and IMO better-looking presentation).

aantron avatar Mar 09 '21 23:03 aantron

@aantron have you considered using OCamlPro/ocb ?

redianthus avatar Aug 12 '21 13:08 redianthus

Thanks for the link.

I've looked at it now. The issue with using it is that if a repo has other dynamically generated badges, it can probably only get a consistent look between them if it uses shields.io or a similar service.

aantron avatar Aug 22 '21 08:08 aantron

What kind of look are you thinking of that is missing in ocb ? In ocb's README the exemple is made with the flat style but the classic one is also available. :)

EDIT: I just made osh, it's been made quick and dirty but it works as a PoC, using dream :grin:, a preview is online.

I'm already using bisect_ppx + dream to get a coverage badge, e.g. here and I'm doing it this way, it's a little bit ugly so I'd love to have support for this directly in bisect_ppx, but I'd also like not having to depend on an external service (except if it's written in OCaml :-)).

redianthus avatar Aug 22 '21 10:08 redianthus

@zapashcanon I didn't see your edit (it doesn't trigger an email), but it sounds great. I've thought many times about making an OCaml clone of shields.io, but never did it because I already worry I have too many projects sometimes :)

The issue was not with the looks, but with the availability of dynamic integrations, which were provided by the shields.io server. Is osh meant to provide that? If so, I'd be glad to use it. osh looks down at the moment.

aantron avatar Sep 22 '21 13:09 aantron

@aantron I'll deploy it on a proper environment, I'll let you know once it's done

redianthus avatar Sep 23 '21 14:09 redianthus

@aantron see osh.ocamlpro.com, the code is available at gitlab.ocamlpro.com/OCamlPro/osh. There's not a lot of documentation atm but it shouldn't be hard to achieve what you want. Let me know if you have a question or want me to add a feature.

I'll also publish it on opam once I found the time to write some documentation.

redianthus avatar Sep 23 '21 17:09 redianthus

Nice. I just tried it.

The issue is that I would want to use one service to ensure consistency between all badges. shields.io is capable of querying e.g. CI build status on its end, instead of repo maintainers (me in this case) having to do the integration. For Bisect badges, there is no such thing to query anyway — Bisect would generate the badge URL itself, so there is no difference between using osh and shields.io. But my repos also have CI or other badges, so if I switch to osh for coverage, I have to either risk losing visual consistency if I keep using shields.io for the other badges, or do integration work to either generate badge URLs repo-side, or contribute higher-level integrations to osh (which is the right thing to do).

aantron avatar Sep 24 '21 10:09 aantron

OK so IIUC, you'd like osh to provide something like: https://osh.ocamlpro.com/badge/cibuildstatus/?url=https://github.com/aantron/bisect_ppx ? And allow to override each parameter with additional parameters (style, label...).

redianthus avatar Sep 24 '21 12:09 redianthus

Yes, something equivalent to (a subset of) the endpoints on this page: https://shields.io/category/build (edited)

aantron avatar Sep 24 '21 12:09 aantron

Oops, linked to wrong page. https://shields.io/category/build

aantron avatar Sep 24 '21 12:09 aantron

The single endpoint that is the most valuable to me is a GitHub Actions endpoint. After that, I could probably help out by contributing any other endpoints I may eventually need.

aantron avatar Sep 24 '21 12:09 aantron

@aantron, I've implemented it and tested it quickly, it seems to work well. Let me know if something is missing.

I can't deploy it for now as it needs a new release of c-cube/ezcurl (no user agent was set and we were rejected by the GitHub API, I fixed this in a PR that has been merged, now we just have to wait it lands in opam). cc @c-cube :)

redianthus avatar Sep 29 '21 13:09 redianthus

(btw, I had a look at how it's implemented in shields.io and what they do is fetching the gitHub generated SVG, grep inside it to get the status and then, generate their own badge from it... I went with the GitHub API :D)

redianthus avatar Sep 29 '21 13:09 redianthus

@aantron, it's online now. :)

redianthus avatar Oct 06 '21 15:10 redianthus

Very nice! I put in my queue to switch over to these gradually/make some contributions! It'll become clear what to do with this issue in particular along the way. Maybe we can even host Bisect_ppx reports :P But that seems like a pretty big project since a full coverage hosting service would need a lot of integrations and the like. So I'll probably stick with just outputting a badge URL.

aantron avatar Oct 16 '21 17:10 aantron

@zapashcanon I've reached this issue and I want to work with osh. I see that it is hosted on the OCP GitLab. However, I can't find any way (in a few minutes) to create a user account there. What should I do?

aantron avatar Nov 06 '21 22:11 aantron

We're discussing it, I'll come back to you very soon. You need an account to access the source code ? Or to contribute to osh ?

redianthus avatar Nov 07 '21 07:11 redianthus

Contribute. I can see the code.

aantron avatar Nov 07 '21 09:11 aantron

@aantron can you send me an email to *** so we can create your account ?

redianthus avatar Nov 08 '21 12:11 redianthus

Sent an email.

I want to ask about the "meta" of this. In case osh becomes widely used (and I will try to help that), it will likely attract more contributors that want to add new badge endpoints. If they have to get individual accounts in this way, it will be an obstacle.

aantron avatar Nov 08 '21 12:11 aantron

Yes, we know about the issue. We'll see if it's possible to open registration but we need to consider some potential issues first. Another solution would be to have a mirror on GitHub and to merge manually things into our GitLab. I'll let you know once we decided the way we go.

redianthus avatar Nov 08 '21 12:11 redianthus

Great, thanks!

aantron avatar Nov 08 '21 12:11 aantron

@aantron it's now possible to register easily on our gitlab (the account will have to be allowed by an admin but we'll get a notification and either accept it or send an e-mail to know who's the person creating the account if we can't guess)

redianthus avatar Jan 31 '22 16:01 redianthus

I'm going to close this for now, as I was formerly the only interested user, but I've since moved away from most badges, as changes to the GitHub page layout have made most badges redundant. Coverage badges are basically the only ones I still use, but I probably wouldn't introduce them in a new repo of mine.

aantron avatar Apr 14 '23 02:04 aantron