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

Add API-based support for [GitLab] badges, add new GitLab Tag badge #6988

Merged
merged 13 commits into from
Sep 14, 2021

Conversation

calebcartwright
Copy link
Member

@calebcartwright calebcartwright commented Sep 6, 2021

Closes #541, refs/implements the tag half of #4867. I've opted to use the close keyword on #541 as I feel that with the authenticated supported added here, and accompanying rate limit increase, we can now move forward with other, specific badge requests as needed following our standard badge intake flow.

Have already setup the account and token, will plug them into the prod env before deploying and will also share the relevant account info with the rest of the ops team.

@calebcartwright calebcartwright added service-badge New or updated service badge core Server, BaseService, GitHub auth, Shared helpers labels Sep 6, 2021
@shields-cd shields-cd temporarily deployed to shields-staging-pr-6988 September 6, 2021 02:23 Inactive
export default class GitLabBase extends BaseJsonService {
static auth = {
passKey: 'gitlab_token',
serviceKey: 'gitlab',
Copy link
Member Author

Choose a reason for hiding this comment

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

We'll constrain the allowed origins for Shields.io to gitlab.com, but need this to be flexible for other self-hosters which is why the key is used here instead of hardcoding the authorizedOrigins value to gitlab.com

@shields-ci
Copy link

shields-ci commented Sep 6, 2021

Warnings
⚠️ This PR modified the server but none of its tests.
That's okay so long as it's refactoring existing code.
Messages
📖

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

📖 ✨ Thanks for your contribution to Shields, @calebcartwright!

Generated by 🚫 dangerJS against 4c963cd

@shields-cd shields-cd temporarily deployed to shields-staging-pr-6988 September 11, 2021 13:32 Inactive
Copy link
Member

@chris48s chris48s left a comment

Choose a reason for hiding this comment

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

Nice work on tackling this. One question here. The rest are inline on the diff.

Have already setup the account and token, will plug them into the prod env before deploying

Do we also need to set a token for staging and/or CI or will the anonymous rate limit be sufficient for those environments?

doc/server-secrets.md Outdated Show resolved Hide resolved
services/gitlab/gitlab-tag.service.js Outdated Show resolved Hide resolved
services/gitlab/gitlab-tag.service.js Outdated Show resolved Hide resolved
services/gitlab/gitlab-tag.spec.js Show resolved Hide resolved
services/gitlab/gitlab-tag.tester.js Show resolved Hide resolved
@calebcartwright
Copy link
Member Author

Do we also need to set a token for staging and/or CI or will the anonymous rate limit be sufficient for those environments?

I was thinking anonymous will be fine. With a 2k per minute limit I don't anticipate any issues in staging nor CI

@chris48s
Copy link
Member

2k per minute

Right, yeah that is pretty generous and I think that should cover the custom gitlab_url case for most users 👍

@calebcartwright calebcartwright temporarily deployed to shields-staging-pr-6988 September 11, 2021 17:29 Inactive
@calebcartwright calebcartwright temporarily deployed to shields-staging-pr-6988 September 11, 2021 17:29 Inactive
@calebcartwright calebcartwright temporarily deployed to shields-staging-pr-6988 September 11, 2021 17:34 Inactive
Comment on lines +78 to +83
static render({ version, sort }) {
return {
message: addv(version),
color: sort === 'semver' ? versionColor(version) : 'blue',
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This is mostly copy/pasta from the corresponding GitHub service for consistency, but probably worth a moment of discussion given the change (the introduction of the v prefix).

There's been recurring discussion on this in general, and we certainly want to keep our standard posture (refs #3200, #1181, and #6135). However, we have previously expressed an openness to consider no longer inserting the v prefix on the GitHub Tag badges (e.g. #3200 (comment)).

Accordingly I actually think the message should be adjusted here to just display version, sans the addv call, but wanted to see what others thought first

Copy link
Member

Choose a reason for hiding this comment

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

I do see where you're coming from and this is a good point to raise.

Our starting point for this is that (pretty much?) all of our badges add the v prefix by default. If we were to decide to allow users to disable it, the pattern is going to be that everything appends v by default but then you can pass ?addv=false or whatever to disable it.

Given that, I think it probably makes most sense to set GitLab up the same way as everything else to start with (i.e: with addv()). If we don't we will either end up saying "all the version badges append v by default and you can pass ?addv=false, except GitLab which is the other way round" or we have to make a behaviour change for GitLab in future to make it consistent.

Copy link
Member Author

Choose a reason for hiding this comment

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

If we were to decide to allow users to disable it, the pattern is going to be that everything appends v by default but then you can pass ?addv=false or whatever to disable it.

to clarify, i'm not proposing we expose this level of control to the users via a query param or other means. it's strictly a question of what Shields does internally, either always injecting a leading v or not. I don't think this is something we can change our minds on down the road, or at least it's not something I think we should bank on having the liberty to do, so I feel like we should be confident and comfortable with whatever option we select.

in hindsight the tag badge is somewhat of a challenge to incorporate as the example part of what is largely centered around the general auth story for gitlab, given all the associated nuances

Copy link
Member

Choose a reason for hiding this comment

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

Yes I think once we pick an approach here we're basically stuck with it. There isn't a single unambiguously correct choice. I think I'm still in favour of addv() just because it is what we do on all the other version badges (which this is https://github.com/badges/shields/pull/6988/files#diff-36f70802cce1e0dcc5c595f7913c44e5bce18d58c8357d8567b582399c7fcdb1R22 ) and it is what we'd be doing if we were using renderVersionBadge() but if you (or other @badges/shields-maintainers ) reckon there's a strong case for it here I'm not wedded to that opinion. Tags are slightly different and as I say, neither option is unambiguously correct.

Copy link
Member

Choose a reason for hiding this comment

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

I would tend to agree with the argument "let's be consistent with what the GitHub badges do".

Copy link
Member Author

Choose a reason for hiding this comment

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

Fair enough, I can go with that. One notable piece is that at past ops meetings we've discussed the need to brand our new GitLab badges with somewhat of a "beta" tag given the outstanding uncertainty around the auth story once we start to increase the scale of badges we offer and serve at runtime.

I'll post a note back in the main issue to that effect, which could in turn give us some leeway to revisit the message on this badge too.

@calebcartwright calebcartwright temporarily deployed to shields-staging-pr-6988 September 12, 2021 05:17 Inactive
services/gitlab/gitlab-tag.service.js Outdated Show resolved Hide resolved
services/gitlab/gitlab-tag.service.js Outdated Show resolved Hide resolved
static category = 'version'

static route = {
base: 'gitlab/v/tag',
Copy link
Member Author

Choose a reason for hiding this comment

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

on the recurring theme of consistency, both with github and at large, i've updated the route to match the github tag badge route. however, i realize i'm not completely convinced this aligns with the service/noun/parameters badge route pattern enumerated in our docs.

we've also got other github routes that have the v and noun order reversed, e.g. github/v/tag/... vs github/package-json/v/...

i think this is probably the best bet to provide the highest degree of consistency, but also feel like maybe the docs could use more clarity if this is a common exception to the main rule?

Copy link
Member

Choose a reason for hiding this comment

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

Agree with your decision here 👍

@calebcartwright calebcartwright temporarily deployed to shields-staging-pr-6988 September 12, 2021 18:32 Inactive
chris48s
chris48s previously approved these changes Sep 13, 2021
Copy link
Member

@chris48s chris48s left a comment

Choose a reason for hiding this comment

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

Pressing the big green tick on this as if we stick with addv() it is good to go, but happy to re-:+1: it if we change our minds on #6988 (comment)

@calebcartwright
Copy link
Member Author

Nuts, should've just let ranger add a merge commit but did a rebase instead. One last call for a 👍 whenever anyone gets a chance 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Server, BaseService, GitHub auth, Shared helpers service-badge New or updated service badge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Badge request: Gitlab CI and Gitlab
6 participants