dustinmoris / CI-BuildStats

Little widget to display AppVeyor, TravisCI, CircleCI, GitHub Actions or Azure Pipelines build history charts and other SVG badges.
https://buildstats.info
GNU General Public License v2.0
171 stars 25 forks source link

Support travis-ci.com #17

Closed martincostello closed 6 years ago

martincostello commented 6 years ago

New repositories/accounts created with Travis CI may now be created at travis-ci.com instead of travis-ci.org as part of Travis' infrastructure migration.

As the API URL is hard-coded at present, it is not possible to generate charts for builds in travis-ci.com.

https://github.com/dustinmoris/CI-BuildStats/blob/d275648710c6b93fa6543c95b3099849ae63f072/src/BuildStats/BuildHistoryCharts.fs#L196

Two possible approaches to support this could be either:

  1. Adding a query-string parameter to specify that the .com version should be used (?v=2 ?).
  2. Adding a new provider (travisci2 ?).
dustinmoris commented 6 years ago

Can the same project be available under travis-ci.org and travis-ci.com?

If not, then I'd prefer to do a quick check which one of the two endpoints returns data and then there is no need to introduce a new argument for travis-ci.com, however if the same project name can appear on both platforms then we'd have to go with one of your two suggestions. I don't have a strong feeling, which one would you prefer?

Anyhow, this is a small fix, I will try to get this live tomorrow as soon as I have figured out which one it is.

martincostello commented 6 years ago

I’ll double check tomorrow morning for projects, but accounts can be. My existing projects are all still .org but I created a new one and it got set up as .com which was how I noticed this issue.

I noticed that shields.io supports both by having two different path options, which was where the “toggle” suggestion came from.

I wasn’t sure what the infrastructure impact to you would be by doing a try one then try the other approach.

dustinmoris commented 6 years ago

Ok so from reading the official blog post it's pretty clear that the days for travis-ci.org are counted. Looks like they are going to migrate everything over to travis-ci.com and starting with all new projects being created there now.

New Travis CI Users Welcome to Travis CI! Go ahead and sign up at travis-ci.com. You will be able to use the GitHub Apps Integration right away, and all of your repositories will be in one place. This is the best time to get started!

Current Travis CI Users You can continue to use both your travis-ci.org and travis-ci.com accounts as usual for now. Over the next several months, we’ll be migrating all travis-ci.org repositories and customers to travis-ci.com. Though this will not happen right away, you can go ahead and read more about what to expect in the docs.

With that information I think the best for me to do is to check if a repo returns 200 on travis-ci.com and if it does then don't even bother to go to travis-ci.org. If it doesn't then I'll use .org as the fallback and over time the amount of second requests being made to .org should go down at which point I'll probably be able to entirely delete that code.

I personally think this is a better option than asking all users now to distinguish between travisci and travisci2 if this is only temporary anyway.

martincostello commented 6 years ago

I think that’s fine then :+1

dustinmoris commented 6 years ago

I have deployed a fix today. I updated the code to work against the V3 API of Travis (which is much better btw) and managed to query public repo data from the .com domain with a fallback to .org without the need for an auth token after all. Even though I didn't need the auth token in the end I have still implemented a first version for private repository support. This is currently in testing and not officially released yet, but if you want to have a dig at it you should be able to encrypt your token here and then pass in the encrypted value to the Travis endpoint via the authToken={encrypted value} query parameter.

Thanks for your help again!

martincostello commented 6 years ago

Awesome thanks @dustinmoris. I'll check this out later today 👍

martincostello commented 6 years ago

Awesome, it just worked

I didn't try the token stuff, but I had a quick peek at the page and FYI there's a 404 in the browser console because it's trying to find a favicon.

dustinmoris commented 6 years ago

Hmm weird, I don't have a reference to any favicon in my entire code base. In my chrome dev tools I also don't get a 404:

image

Where did you see this happening?

martincostello commented 6 years ago

Ah, maybe it was just the browser being presumptive and trying anyway on the first visit.

martincostello commented 6 years ago

I think this may have caused a regression. For an existing project that hasn't been migrated yet, I'm getting an empty graph instead of it falling back to .org.

https://github.com/martincostello/website#martin-costellos-website

dustinmoris commented 6 years ago

Hmm weird, I do have tests with non migrated projects and they all work. I'll check this a bit later today!