Closed matentzn closed 2 years ago
You can actually stick pretty arbitrary stuff into badges with https://shields.io, even coming from a JSON endpoint
E.g., I have a YAML file on the OBO Community report that I can turn a part of into a badge with
https://img.shields.io/badge/dynamic/yaml?url=https://raw.githubusercontent.com/cthoyt/obo-community-health/main/data/contacts.yaml&query=$.0.count&label=Contact%20Score&color=blue
Creates:
Note the query $.0.count
grabs the first element from the yaml then indexes the "count". This could be easily reorganized to work on a dictionary where the key is the OBO Foundry ontology ID then you ask people to format their own in. Or use some kind of clever redirect that does some URL rewriting so it can be simplified and a lot of the URL abstracted
https://img.shields.io/badge/dynamic/json?url=https://github.com/cthoyt/obo-community-health/raw/main/data/data.json&query=$.go.score&label=OBO%20Community%20Health%20Score&color=blue
Note the query $.go.score
grabs the data from the "go" entry in the JSON file.
Thanks @cthoyt that would be super cool. Anyone wanting to pick this up would be greatly appreciated!
Some inspiration maybe be taken from here:
Assuming we work from the YAML results file available on https://raw.githubusercontent.com/OBOFoundry/obo-nor.github.io/master/dashboard/dashboard-results.yml, a URL like the following:
https://img.shields.io/badge/dynamic/yaml?label=OBO%20Dashboard&query=%24..ontologies%5B%3F%28%40.namespace%3D%3D%27ngbo%27%29%5D.summary.comment&url=https%3A%2F%2Fraw.githubusercontent.com%2FOBOFoundry%2Fobo-nor.github.io%2Fmaster%2Fdashboard%2Fdashboard-results.yml
would give you a badge like this for the ngbo
ontology.
The URL looks awful because many characters need to be URL-encoded, but it can be broken down in the following parameters:
label=OBO Dashboard
The left-side label of the badge
query=$..ontologies[?(@.namespace=='ngbo')].summary.comment
In the ontologies
dictionary within the provided YAML file, select the ontology with namespace ngbo
, and use the value in the comment
key within the summary
dictionary as the right-side text of the badge.
To have a badge for another ontology, change ngbo
to the namespace of the desired ontology.
Use summary.status
instead of summary.comment
to simply display ERROR
, WARN
, or PASS
.
url=https://raw.githubusercontent.com/OBOFoundry/obo-nor.github.io/master/dashboard/dashboard-results.yml
The link to the YAML file.
Of note, the dynamic
version of Shields.io does not seem to allow to set the colour of the badge based on a JSONpath query, only the value of the badge can be set that way. So it would not be possible to have a red badge for ontologies with an error status and a green badge for ontologies with a pass status. If you want that, then the Dashboard needs to generate a custom JSON file following this schema.
I just realised that the OBO Dashboard already publishes per-ontology YAML files. We can then use slightly simpler URLs, such as this one for example for FBbt:
https://img.shields.io/badge/dynamic/yaml?label=OBO%20Dashboard&query=%24.summary.comment&url=http%3A%2F%2Fdashboard.obofoundry.org%2Fdashboard%2Ffbbt%2Fdashboard.yml
It is slightly simpler because we no longer need complex JSONpath syntax to select the correct value in the input file; to generate a badge for a different ontology, just replace fbbt%2Fdashboard.yml
by XXXX%2Fdashboard.yml
at the end of the URL, where XXXX
is the name of the desired ontology.
Thank you so much for looking into it. Shame about the colour:
I tried this: https://github.com/matentzn/badges/blob/main/bfo/dashboard.json
But I cant get it to work. This is clearly according to the json schema you suggest, but it keeps giving me "unparseable json" (this is when I decided it was more productive to dispair than to move on). @cthoyt suggested this could be due to somehow github not providing the correct mimetype or something?
I think we will go your way in the end; I would have liked something more "motivational" to get people to say: LETS FIX, I want this GREEEEN :D
For the "unparseable JSON" bit: check that GitHub is returning the actual JSON file when using that URL, and not some HTML. You might need to use "raw.githubusercontent.com" to force GitHub to do that.
Thank you sooo much @gouttegd and @cthoyt for helping me sort this out - this was a long standing issue for me and dear to my heart. I think the first draft is done.
There are two badges, OBO QC and OBO Dashboard score:
See here for an example how I envision this for NORs (top of the page):
https://github.com/OBOFoundry/OBOFoundry.github.io/issues/1912
I will announce this more widely tomorrow (for general ontologies).
I would like to propose our own OBO dashboard badge which we can serve as part of an OBO dashboard run. Does anyone have any experience with creating GitHub badges? We still have not decided how compute the overall OBO score (https://github.com/OBOFoundry/OBO-Dashboard/issues/26), but as a simple first pass I would like a badge for those passing the dashboard in their entirety..