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

[QueryStringStatic] service #3024

Merged
merged 24 commits into from
Feb 22, 2019

Conversation

mbarkhau
Copy link
Contributor

@mbarkhau mbarkhau commented Feb 18, 2019

Ref #2673

This is WIP (no updated documentation yet) and is based on PR #3012

@shields-ci
Copy link

shields-ci commented Feb 18, 2019

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

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

Generated by 🚫 dangerJS against 8e310ce

Copy link
Member

@paulmelnikow paulmelnikow left a comment

Choose a reason for hiding this comment

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

Thanks! I left some preliminary comments.

core/badge-urls/make-badge-url.js Outdated Show resolved Hide resolved
}
}

handle(namedParams, queryParams) {
Copy link
Member

Choose a reason for hiding this comment

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

It would be good to validate the queryParams using Joi, as we've done in e.g. the dynamic badge. It will ensure that message is a string or numeric string, and not e.g. an array. (same issue as #2854)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added validation as best as I could figure out how. I'm sure there's a better way.

Copy link
Member

Choose a reason for hiding this comment

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

This works for now! That code is in flight in #3042 so if that lands first, we can update this; otherwise after this lands I can update #3042.

.get(
'/static/v1.svg?label=label&message=message&color=notacolor&style=_shields_test'
)
.expectJSON({ name: 'label', value: 'message', color: null })
Copy link
Member

Choose a reason for hiding this comment

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

These seem like they are testing functionality in coalesceBadge + BaseService. There's already a "set color" test at the bottom, so how about removing all of these?

If it seems important to add more tests of that code I would prefer we find a way to do it with a unit test instead of a service test, as the unit tests get run more frequently.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point.

.get(
'/static/v1.svg?label=best-license&message=Apache-2.0&color=blue&style=_shields_test'
)
.expectJSON({ name: 'best-license', value: 'Apache-2.0', color: 'blue' })
Copy link
Member

Choose a reason for hiding this comment

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

The "Shields-encoded dash" is the unusual escaping used in the url-based static badge. It doesn't seem relevant here and could be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point!

@paulmelnikow paulmelnikow changed the title Query string static service [QueryStringStatic] service Feb 18, 2019
@paulmelnikow
Copy link
Member

I updated the PR title so the service tests will run starting with the next build.

@mbarkhau
Copy link
Contributor Author

So I guess the next step here is to update the shields.io page and add documentation for this. Should it be more like the endpoint badge, on a separate page, or should it be a widget similar to the current static badge, or something else?

Maybe the most simple thing would be to add another output url on the current static widget.

image

@paulmelnikow
Copy link
Member

Maybe the most simple thing would be to add another output url on the current static widget.

Yea, seems fine to do the simple thing for now.

That text is in flight in #3032 so perhaps best to get that merged first.

core/badge-urls/make-badge-url.js Show resolved Hide resolved
}
}

handle(namedParams, queryParams) {
Copy link
Member

Choose a reason for hiding this comment

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

This works for now! That code is in flight in #3042 so if that lands first, we can update this; otherwise after this lands I can update #3042.

@mbarkhau
Copy link
Contributor Author

3aca1ef adds a snippet on the front page, which looks like this

image

I'm not sure how you want to treat the new static urls vs the old ones. With the commit f9b5c20 I've updated the fronted to use the /static/v1.svg urls everywhere, which may be a bit much, idk.

In order to keep the history linear I usually like to do git rebase and assuming nobody else is working on this branch I then do git push --force. Since this branch has merge conflicts with master again, how would you like that to be resolved? Should I merge master to this branch and give up on the linear history?

@paulmelnikow
Copy link
Member

In order to keep the history linear I usually like to do git rebase and assuming nobody else is working on this branch I then do git push --force. Since this branch has merge conflicts with master again, how would you like that to be resolved? Should I merge master to this branch and give up on the linear history?

We keep PRs to single units of work and use a squash merge workflow, and as a result can optimize the history in PRs for people who are following the PRs. So please merge master into your branch, and we'll squash it down when it's done.

@paulmelnikow
Copy link
Member

Thanks for carrying this forward!

3aca1ef adds a snippet on the front page, which looks like this

image

Looks good!

I'd like to ship a second version of the URL path version that is a bit friendlier. But this feature is intended for (1) easy programmatic generation and (2) complicated text that is otherwise hard to escape. So, could you put the new text below instead of above?

Also I don't think there's a need to label it beta. We've been thinking about this for a long time and I'm feeling confident in the changes you're making. 😁

I'm not sure how you want to treat the new static urls vs the old ones. With the commit f9b5c20 I've updated the fronted to use the /static/v1.svg urls everywhere, which may be a bit much, idk.

Again some of the code you're changing is in flight in #3032; so apologies, but I think we need to land that first. I'd lean toward using the old badge everywhere else because the URLs are more readable than query strings. If we get a more streamlined URL-path version down the line we could switch them over.

@mbarkhau
Copy link
Contributor Author

I'd lean toward using the old badge everywhere else because the URLs are more readable than query strings.

Sounds reasonable. I'll revert f9b5c20.

@mbarkhau mbarkhau marked this pull request as ready for review February 21, 2019 16:18
@mbarkhau
Copy link
Contributor Author

mbarkhau commented Feb 21, 2019

I swapped the ordering of the URLs and removed the "(beta)" text.

image

Anything else this needs before a merge?

@paulmelnikow
Copy link
Member

It looks good! Did you merge in the changes from #3032? That should make it quick to merge this after that lands.

The query param changes landed in #3042; I'll leave a comment about that.

@mbarkhau
Copy link
Contributor Author

This PR is now pending on the merge of #3032 since I merged consolidate-badge-gen.

@paulmelnikow
Copy link
Member

Thanks for the updates! Will approve and merge when #3032 is in.

@paulmelnikow paulmelnikow merged commit f6628e6 into badges:master Feb 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:

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

Successfully merging this pull request may close these issues.

3 participants