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

[Endpoint] badge #2473

Merged
merged 41 commits into from
Jan 22, 2019
Merged

[Endpoint] badge #2473

merged 41 commits into from
Jan 22, 2019

Conversation

paulmelnikow
Copy link
Member

@paulmelnikow paulmelnikow commented Dec 7, 2018

This reimplements the idea @bkdotcom came up with in #1519, and took a stab at in #1525. It’s a really powerful way to add all sorts of custom badges, particularly considering tools like RunKit endpoints and Jupyter Kernel Gateway, not to mention all the other ways cloud functions can be deployed these days.

I gave this a name which did not have JSON in it, so as not to confuse it with the dynamic JSON badges.

There are a few things that need doing before this can be shipped, including supporting several of the options I included in the schema.

Alternatively, they could be removed from the schema and added later on.

Curious for feedback! And thought I would open this up for comments before I got too far along.

Ref #1534 #2259. Closes #204 #358 #742 #999 #1519 #1752 #2625.

This reimplements the idea @bkdotcom came up with in #1519, and took a stab at in #1525. It’s a really powerful way to add all sorts of custom badges, particularly considering [tools like RunKit endpoints and Jupyter Kernel Gateway](#2259 (comment)), not to mention all the other ways cloud functions can be deployed these days.

Ref #1752 #2259
@paulmelnikow paulmelnikow added the core Server, BaseService, GitHub auth label Dec 7, 2018
@shields-ci
Copy link

shields-ci commented Dec 7, 2018

Messages
📖 ✨ Thanks for your contribution to Shields, @paulmelnikow!
📖

Thanks for contributing to our documentation. We ❤️ our documentarians!

Generated by 🚫 dangerJS against 92446ce

@paulmelnikow paulmelnikow changed the title [WIP] Endpoint badge [WIP] [Endpoint] badge Dec 7, 2018
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2473 December 7, 2018 01:18 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2473 December 7, 2018 01:21 Inactive
@paulmelnikow
Copy link
Member Author

This pull request introduces 1 alert when merging 02dd662 into d0c9da0 - view on LGTM.com

new alerts:

  • 1 for Ambiguous HTML id attribute

Comment posted by LGTM.com

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2473 December 7, 2018 01:30 Inactive
@calebcartwright
Copy link
Member

calebcartwright commented Dec 26, 2018

I don't really have any useful feedback on this one yet. React is wayyyy too new for me and I'm still trying to get a feel for that endpoint service.

Will try to get back to this one hopefully soon once I've read up a bit

@paulmelnikow
Copy link
Member Author

React is wayyyy too new for me and I'm still trying to get a feel for that endpoint service.

Probably understanding the React code isn't that important here as it's just documentation. Looking at the review app would probably be sufficient.

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2473 January 1, 2019 19:52 Inactive
@calebcartwright
Copy link
Member

Okay I think I've found it now 😄 I was looking for an endpoint badge via the search function as well as perusing the page but couldn't find it.

I was able to get it via direct uri at https://shields-staging-pr-2473.herokuapp.com/#/endpoint

Can I point this thing to any endpoint that returns any JSON response?

@calebcartwright
Copy link
Member

This may be expected at this point, but on my screen the json schema example looks to be in an odd location on the screen:

image

@paulmelnikow
Copy link
Member Author

Can I point this thing to any endpoint that returns any JSON response?

Yea, that's exactly the idea! 😁Or rather, a JSON response in the specified format.

This is one I created for #2259: https://runkit.com/melnikow/version-from-requirements-txt

(Oops, that formatting will need some work.)

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2473 January 3, 2019 23:55 Inactive
@calebcartwright
Copy link
Member

Gotcha. So this is conceptually similar to the dynamic badges, except that it offers the users the ability to define their own processing functionality

@calebcartwright
Copy link
Member

Do we have any idea how we might define guidelines recommendations for when a user should use this type of badge vs. implementing their own service in the Shields codebase and submitting that as a PR?

@paulmelnikow
Copy link
Member Author

Gotcha. So this is conceptually similar to the dynamic badges, except that it offers the users the ability to define their own processing functionality

Right.

It also allows a service to publish a prerendered badge which can be proxied through shields.io to provide formatting flexibility.

Do we have any idea how we might define guidelines recommendations for when a user should use this type of badge vs. implementing their own service in the Shields codebase and submitting that as a PR?

It's a great way to get something going quickly and to quickly iterate and remix.

Beyond that I'd say if folks have something that's working well and they think it's generally useful, they should open an issue to suggest it. I don't have clear guidelines of what's too specific or too generic to include.

We probably wouldn't merge "is such-and-such the current month or not" (#1519) or "how many days are left in the year," however I could see building something along those lines that's specific to hacktoberfest.

This is also a good candidate for things we don't want to do, like exact star count or download count (#742), or nuget aggregate download counts (#204).

@calebcartwright
Copy link
Member

calebcartwright commented Jan 4, 2019

It also allows a service to publish a prerendered badge which can be proxied through shields.io to provide formatting flexibility.

Nice! I was thinking along the same lines of use cases.

I was envisioning a scenario where someone may use this to get something going quickly, but then once they get it working well they just use it as is and not bother to share it back with the community 😄

Obviously that's not something that can be prevented, but maybe just a note in docs down the line that includes the exact sentiment you articulated:

Beyond that I'd say if folks have something that's working well and they think it's generally useful, they should open an issue to suggest it

@paulmelnikow
Copy link
Member Author

I was envisioning a scenario where someone may use this to get something going quickly, but then once they get it working well they just use it as is and not bother to share it back with the community 😄

Right, that's a possibility. Though the advantage of pulling the implementation into the shields server is that it will take load off their server endpoint, and probably will perform better and be more reliable.

@calebcartwright
Copy link
Member

One odd thing I've noticed is that the first time I hit the endpoint page I see what I showed above in #2473 (comment), but after I reload the page I see this:

image

lib/validate.js Outdated
@@ -11,17 +11,21 @@ function validate(
includeKeys = false,
traceErrorMessage = 'Data did not match schema',
traceSuccessMessage = 'Data after validation',
allowAndStripUnknownKeys = true,
Copy link
Member

Choose a reason for hiding this comment

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

i have no clue what all this is used for, but my first thought here was whether any consumers of this function would ever need different values for these two keys (allowUnknown false and stripUnknown true)?

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems unsafe to allowUnknown and not stripUnknown so if we did that, I'd tend to think we weren't doing a good job of validating.

Originally I'd passed options directly through which would have supported any combination, though I'm not sure we would ever want to do that.


const { protocol, hostname } = new URL(url)
if (protocol !== 'https:') {
throw new InvalidParameter({ prettyMessage: 'please use https' })
Copy link
Member

@calebcartwright calebcartwright Jan 22, 2019

Choose a reason for hiding this comment

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

👍 on pushing for https

@calebcartwright
Copy link
Member

I went through the changes and left feedback/questions where I could, but have to defer on the frontend content to someone with a better eye for that sort of thing. Bravo on another big add 🍻!

I'd lean toward merging and opening a bug ticket for the fix.

That makes sense to me. I feel like there's been a lot of issues opened lately that will be resolved by this so I definitely see value in getting the functionality out even if there's some short term formatting items.

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2473 January 22, 2019 02:57 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2473 January 22, 2019 02:58 Inactive
@paulmelnikow
Copy link
Member Author

I'm going to add a Beta label to this feature, which will give us a chance to change the API if we decide we want to.

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2473 January 22, 2019 03:07 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2473 January 22, 2019 03:08 Inactive
schemaVersion: 1,
label: 'hello',
message: 'sweet world',
color: 'orange',
Copy link
Member

Choose a reason for hiding this comment

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

😆 For some reason my brain read this as hello sweet orange. wonder if i am hungry...

Copy link
Member

@calebcartwright calebcartwright left a comment

Choose a reason for hiding this comment

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

LGTM, don't have much to offer on the frontend content though

@paulmelnikow
Copy link
Member Author

Do you mean you don't have much to offer on the way it's coded, or about what it's saying to the user?

@calebcartwright
Copy link
Member

Do you mean you don't have much to offer on the way it's coded, or about what it's saying to the user?

Apologies, the former.

@paulmelnikow
Copy link
Member Author

Opened #2837 for the formatting issues. I'm gonna ship this!!!

@paulmelnikow paulmelnikow merged commit 0fc3df8 into master Jan 22, 2019
@shields-deployment
Copy link

This pull request was merged to master branch. This change is now waiting for deployment, which will usually happen within a few days. Stay tuned by joining our #ops channel on Discord!

After deployment, changes are copied to gh-pages branch:

@paulmelnikow paulmelnikow deleted the endpoint branch January 22, 2019 03:55
@paulmelnikow
Copy link
Member Author

And opened #2838 for further discussions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Server, BaseService, GitHub auth service-badge Accepted and actionable changes, features, and bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants