scribu / travis-stats

Travis CI build charts
http://scribu.github.io/travis-stats/
GNU Affero General Public License v3.0
44 stars 22 forks source link

travis-ci.com support #18

Open PatMyron opened 5 years ago

PatMyron commented 5 years ago

It looks like this shows stats from travis-ci.org and not travis-ci.com: http://scribu.net/travis-stats/#PatMyron/advent-of-code/master https://travis-ci.com/PatMyron/advent-of-code/builds https://travis-ci.org/PatMyron/advent-of-code/builds

It looks like .org is being deprecated in favor of .com soon: https://blog.travis-ci.com/2018-05-02-open-source-projects-on-travis-ci-com-with-github-apps Over the next several months, we’ll be migrating all travis-ci.org repositories and customers to travis-ci.com

PatMyron commented 5 years ago

I think these endpoints would need to be un-hardcoded in config.json:

https://github.com/scribu/travis-stats/blob/56a3ad94c03381370b3c664bc104f449a61aa742/script.js#L2-L3

scribu commented 5 years ago

You can already set them using your own config:

https://github.com/scribu/travis-stats/blob/master/README.md#private-repositories

scribu commented 5 years ago

Though we should probably explicitly write travis-ci.com in the readme.

PatMyron commented 5 years ago

@scribu Do API requests for public .com projects need an API token?

I tried switching the endpoint: https://github.com/PatMyron/travis-stats/commit/ca9e88efe5803778ee7352b035b315122e93384d and hosting it: http://patmyron.com/travis-stats/#PatMyron/advent-of-code/master

but I get GET https://api.travis-ci.com/repos/PatMyron/advent-of-code/builds?event_type=push 401 (Unauthorized)

which is weird because it looks publicly accessible: https://api.travis-ci.com/repos/PatMyron/advent-of-code/builds?event_type=push

PatMyron commented 5 years ago

I guess so...

Pats-MacBook-Pro ~/Documents/GitHub/travis-stats $ curl https://api.travis-ci.com/repos/PatMyron/advent-of-code/builds?event_type=push

Pats-MacBook-Pro ~/Documents/GitHub/travis-stats $ curl https://api.travis-ci.org/repos/PatMyron/advent-of-code/builds?event_type=push

[{"id":478085788,"repository_id":22732954,"number":"2","state":"finished","result":0,"started_at":"2019-01-10T23:37:03Z","finished_at":"2019-01-10T23:58:26Z","duration":1283,"commit":"cce28c03fb95f235e5afd58e07ea0e4de9878061","branch":"master","message":"commenting out incomplete 2017 day 23 part 2","event_type":"push"},{"id":477661874,"repository_id":22732954,"number":"1","state":"finished","result":1,"started_at":"2019-01-10T04:25:16Z","finished_at":"2019-01-10T04:26:00Z","duration":44,"commit":"d7d3e849f3044bd4aae9f5d303bea7f8051608c9","branch":"master","message":"stripping new line at the end of the input","event_type":"push"}]

Pats-MacBook-Pro ~/Documents/GitHub/travis-stats $ wget https://api.travis-ci.com/repos/PatMyron/advent-of-code/builds?event_type=push

--2019-03-04 00:45:47-- https://api.travis-ci.com/repos/PatMyron/advent-of-code/builds?event_type=push Resolving api.travis-ci.com (api.travis-ci.com)... 54.221.210.75, 54.204.23.31, 54.225.193.6 Connecting to api.travis-ci.com (api.travis-ci.com)|54.221.210.75|:443... connected. HTTP request sent, awaiting response... 401 Unauthorized Username/Password Authentication Failed.

PatMyron commented 5 years ago

Also, config.json gets blocked locally:

Access to XMLHttpRequest at 'file:///Users/patmy/Documents/GitHub/travis-stats/config.json' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

so changing defaultConfig seems more portable:

https://github.com/scribu/travis-stats/blob/56a3ad94c03381370b3c664bc104f449a61aa742/script.js#L1-L4