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

switch [circleci] service to scrape SVG badge, reorganise routes #3413

Merged
merged 6 commits into from
May 11, 2019

Conversation

chris48s
Copy link
Member

@chris48s chris48s commented May 5, 2019

Closes #1064
Closes #1792
Closes #1872

Default URL is now circleci/build/gh/badges/shields/master?token=abc123
There are redirects on the legacy routes to provide backwards compatibility for existing users

For review, it is easier to read this diff if you read each commit in isolation

Default URL is now
circleci/build/gh/badges/shields/master?token=abc123
There are redirects on the legacy routes to provide
backwards compatibility for existing users
@shields-ci
Copy link

shields-ci commented May 5, 2019

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

Generated by 🚫 dangerJS against cf61429

@paulmelnikow paulmelnikow added the service-badge New or updated service badge label May 6, 2019
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-3413 May 8, 2019 19:56 Inactive
@chris48s
Copy link
Member Author

chris48s commented May 8, 2019

I quite like allowing gh|bb as it allows you to easily take the badge URL Circle CI gives you and convert it to a shields one.

Screenshot at 2019-05-08 20-52-44

but you're right that across shields we more commonly use the longhand versions.
I've switched it to allow (github|gh|bitbucket|bb). Does that seem reasonable?

@calebcartwright
Copy link
Member

Does that seem reasonable?

Sounds good to me!

@paulmelnikow
Copy link
Member

it allows you to easily take the badge URL Circle CI gives you and convert it to a shields one.

On a side note, it would be great to add this capability to the frontend: where you can paste in a URL from a service and it transforms it into a badge URL. It's a similar idea to #2420.

)
.expectBadge({
label: 'build',
message: 'invalid response data',
color: 'lightgrey',
message: isBuildStatus,
})
Copy link
Member

@calebcartwright calebcartwright May 9, 2019

Choose a reason for hiding this comment

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

We admittedly don't have anything documented around our practices for redirectors yet (I opened #3402 to track creating those docs), but so far we've been testing them by disabling followRedirect and then checking the status and target url, example below from the vso redirector:

t.create('Build: default branch')
  .get('/build/totodem/8cf3ec0e-d0c2-4fcd-8206-ad204f254a96/2.svg', {
    followRedirect: false,
  })
  .expectStatus(301)
  .expectHeader(
    'Location',
    '/azure-devops/build/totodem/8cf3ec0e-d0c2-4fcd-8206-ad204f254a96/2.svg'
  )

The approach you've taken here obviously validates the redirect route as well. This isn't a blocker for this PR by any means, but I just wanted to make note of it. Happy to shift this topic over to #3402 for discussion in the event folks have opinions on whether we have any preference for redirector testers (leave it up to the developer, prefer one or the other, etc.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I can see reasons to go both ways on this.
On the one hand, the thing we're testing is a redirector, so checking it issues a 301 is a unit testing approach to making sure that component does exactly what its supposed to do.
On the other hand, our service tests are really high-level integration tests, so testing the end-to-end behaviour also makes sense in this context.
There probably isn't a single correct answer to that, but it does make sense to pick one approach and document it as a convention. I'd be happy to go either way on it tbh.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed there are reasons to go both ways here. When I wrote the first of these I picked this way, though to be honest neither way seems perfect.

I'm inclined to do what's easy to maintain.

A sort of middle-ground option is adding a helper that does a bit of both: check the redirect, then follow it, and finally do a basic check that the final result is not an error badge. Part unit test, part integration test, with a very lightweight assertion.

calebcartwright
calebcartwright previously approved these changes May 9, 2019
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.

Core changes in this PR are good to go IMO 👍 Left a couple inline thoughts/questions on some test topics, and happy to re-approve if you decide to make any additional changes

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-3413 May 9, 2019 20:41 Inactive
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.

👍

@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
Copy link
Member

Thanks for taking this on, Chris! And thanks Caleb for reviewing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service-badge New or updated service badge
Projects
None yet
4 participants