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

Fix Circle CI Integration | Circle CI API v1.1 #798

Merged
merged 2 commits into from
Oct 23, 2016

Conversation

RedSparr0w
Copy link
Member

@RedSparr0w RedSparr0w commented Sep 26, 2016

Fixes #791 @sholladay

url structure:
/circleci/token/YOURTOKEN/project/github/RedSparr0w/node-csgo-parser/master.svg

part of url required explanation
/token/YOURTOKEN no token if private Repo
/github no can either be github or bitbucket depending where repo hosted Default "github"
/RedSparr0w yes Username
/node-csgo-parser yes Repository
/master no Branch

@levithomason
Copy link

@espadrine any chance we can get this merged? Much appreciated.

@RedSparr0w RedSparr0w changed the title Fix Circle CI Integration Fix Circle CI Integration | Circle CI API v1.1 Oct 19, 2016
Copy link
Member

@espadrine espadrine left a comment

Choose a reason for hiding this comment

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

Thanks for this contribution!

@@ -117,16 +117,16 @@ <h3 id="build"> Build </h3>
<td><code>https://img.shields.io/magnumci/ci/96ffb83fa700f069024921b0702e76ff/new-meta.svg</code></td>
</tr>
<tr><th> CircleCI: </th>
<td><img src='/circleci/project/BrightFlair/PHP.Gt.svg' alt=''/></td>
<td><code>https://img.shields.io/circleci/project/BrightFlair/PHP.Gt.svg</code></td>
<td><img src='/circleci/project/github/RedSparr0w/node-csgo-parser.svg?maxAge=2592000' alt=''/></td>
Copy link
Member

Choose a reason for hiding this comment

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

Could you remove maxAge from try.html please?

index.html is meant to be generated from try.html through make website, which I can do for you.


// Base API URL
var apiUrl = 'https://circleci.com/api/v1/project/' + userRepo;
var apiUrl = 'https://circleci.com/api/v1.1/project/'+ type +"/"+ userRepo;
Copy link
Member

Choose a reason for hiding this comment

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

Could you put spaces around the + operators please?

var branch = match[3];
var format = match[4];
var token = match[1];
var type = match[2]; // github OR bitbucket
Copy link
Member

Choose a reason for hiding this comment

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

The addition of this piece of the URL will break existing links. Could you make that part optional, defaulting to GitHub, please?

@RedSparr0w
Copy link
Member Author

Updated with requested changes.

@espadrine espadrine merged commit 2b0d688 into badges:master Oct 23, 2016
espadrine added a commit that referenced this pull request Oct 23, 2016
This prevents from misparsing /circleci/project/githubuser/repo.svg as user
"user".

Related to #798.
@espadrine
Copy link
Member

Thanks a lot!

@sholladay
Copy link

I haven't been able to reproduce a working example using a build status token with the img.shields.io server that's currently online. The home page seems to indicate this has been deployed. @espadrine is this correct?

A full API token does work, but using those is dangerous for this use case.

Here is an example that ought to say "passing", but instead says "invalid".
https://img.shields.io/circleci/token/acc2259949dc35d324ffff96186e5874a4b1ef4f/project/github/sitecues/sitecues-core.svg

Here is the equivalent directly from Circle, which works.
https://circleci.com/gh/sitecues/sitecues-core.svg?style=svg&circle-token=acc2259949dc35d324ffff96186e5874a4b1ef4f

@levithomason
Copy link

FWIW, I had to add a token with All permissions. Neither the status nor the build artifact token scopes worked.

@RedSparr0w
Copy link
Member Author

RedSparr0w commented Oct 23, 2016

https://circleci.com/api/v1.1/project/github/sitecues/sitecues-core?circle-token=acc2259949dc35d324ffff96186e5874a4b1ef4f&limit=1&filter=completed just gives:

{
  "message" : "Permission denied"
}

but seems to work using view-builds scope - gives permission denied error for status token or project not found for no token/invalid token

Token Scope Image Api Link Api Message
Status link "Permission denied"
View-Builds / Build Artifacts link
All link
Missing Token link "Project not found"

@levithomason
Copy link

Confirmed creating a token with Build Artifacts works, thanks. Not sure why it didn't work for me previously.

@RedSparr0w
Copy link
Member Author

Do you think it would be better to show the message (if available) when invalid?
Just so you have a idea of what the problem could be.

example:


-vs-

@levithomason
Copy link

Oh man, that would be immensely helpful

@levithomason
Copy link

levithomason commented Oct 24, 2016

Perhaps even a query param to view the raw JSON response. That way, it would be standardized for all badge providers. Something like ?json or ? debug.

RedSparr0w added a commit to RedSparr0w/shields that referenced this pull request Oct 24, 2016
@RedSparr0w
Copy link
Member Author

I've implemented what i was saying above in #816

But to dump the json for all badges would probably require quite a massive amount of changes.

@espadrine
Copy link
Member

Perhaps even a query param to view the raw JSON response. That way, it would be standardized for all badge providers.

A few vendor data is obtained through non-JSON formats, some over several requests.

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.

4 participants