-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
fixes to [wercker] badge #2103
fixes to [wercker] badge #2103
Conversation
- Fix case where app/branch exists but has no builds or CI runs - Fix aplicationId/branch regex case - Issue badges#2076: - `ci/{projectId}` reports the result of a CI run - `build/{projectId}` reports the result of a build - `build/{applicationName}` reports the result of a build - `ci/{applicationName}` reports the result of a _build_ (but isn't documented anywhere) for "backwards compatibility"
As far as 2. is concerned, when I added branch support in #1920 I actually didn't intend on supporting branches for our old ID based URL, as it had no longer been advertised on the homepage for years. I simply carried over the backwards compatibility for old badges that may still be lying around, so I wouldn't actually say that it "was not working correctly". 😄 This PR looks overall good to me, but I don't think we should add the new In my opinion we should only have Nevertheless, it would be nice for users to use Does this make sense? |
OK, well since we can make it work, we might as well while I'm at it..
Done |
Started looking at #2076 and as I dug into it found some more issues. I've made several changes to the wercker integration in this PR:
If a application or branch does exist but doesn't have any builds or CI runs, a response of
[]
is returned. Example: https://app.wercker.com/api/v3/applications/wercker/stern/builds I've modified the validation and added a case for this.Our current/previous regex was not working correctly when using a project ID:
If I call https://img.shields.io/wercker/ci/559e33c8e982fc615500b357.svg that generates based on (correctly) calling https://app.wercker.com/getbuilds/559e33c8e982fc615500b357?limit=1
If I call https://img.shields.io/wercker/ci/559e33c8e982fc615500b357/master.svg that generates because "559e33c8e982fc615500b357/master" is matching the regex pattern
([^/]+/[^/]+)
so we are (incorrectly) calling https://app.wercker.com/api/v3/applications/559e33c8e982fc615500b357/master/builds?limit=1 instead of (correctly) calling https://app.wercker.com/getbuilds/559e33c8e982fc615500b357?limit=1&branch=master .I've updated the regex so we try to specifically match
([a-fA-F0-9]{24})
first then fall back to([^/]+/[^/]+)
which fixes that (unless, of course, your github username isfb1ed340ffed75c22dc301c3
, in which case I broke it 😄 )Following on from Is Wercker badge reporting the correct status? #2076 I've changed this so that:
ci/{projectId}
reports the result of a CI run (totally sensible)build/{projectId}
reports the result of a build (totally sensible)build/{applicationName}
reports the result of a build (totally sensible)ci/{applicationName}
reports the result of a build but isn't documented anywhere (I'm still in 2 minds about whether this is actually the right thing to do here)I've also updated/added tests accordingly.
Annoyingly, this also has the side effect that it probably makes this a bad example to base documentation on, so I probably now want to go back and change #2075 but lets get this right first and then I'll worry about what I'm going to do with that.