-
Notifications
You must be signed in to change notification settings - Fork 77
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
Updates deploy to build API #454
Conversation
src/Client.php
Outdated
@@ -309,7 +309,7 @@ public function notify(Report $report, callable $callback = null) | |||
} | |||
|
|||
/** | |||
* Notify Bugsnag of a deployment. | |||
* Notify Bugsnag of a deployment. This function is being deprecated in favour of `build`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the @deprecated
annotation at the beginning of this line. Then it will also be picked up by API documentation/linting.
src/HttpClient.php
Outdated
@@ -71,6 +71,7 @@ public function queue(Report $report) | |||
|
|||
/** | |||
* Notify Bugsnag of a deployment. | |||
* This method should no longer be used in favour of sendBuildReport. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, add @deprecated
tests/ClientTest.php
Outdated
$this->client->build('baz', 'foo', 'github', 'me'); | ||
} | ||
|
||
public function testBuildAutoDetectsProvider() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be tests for the other providers as well
src/HttpClient.php
Outdated
$sourceControl['provider'] = $buildInfo['provider']; | ||
} elseif (isset($buildInfo['repository'])) { | ||
$url = $buildInfo['repository']; | ||
if (strpos($url, 'github.com') != false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You dont need to do this. Provider is optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every field is optional though. Are we using this field for something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldnt automatically set this in any of our sdks. This logic of guessing the provider is on the server (and therefore is easier to update).
The user needs to be able to set it for when they are using an on-premise installation of github and the repository URL isnt the github.com one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It gives us the extra data they may not set otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, ok, didn't see this.
src/HttpClient.php
Outdated
} | ||
|
||
if (isset($buildInfo['buildTool'])) { | ||
$data['buildTool'] = $buildInfo['buildTool']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldnt be able to externally set this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its settable for laravel to override
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think we care about php/laravel distinction at an analytics level. We just care that this lib is being used for deploys.
} | ||
|
||
if (isset($buildInfo['builder'])) { | ||
$data['builderName'] = $buildInfo['builder']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should default to whoami
or a php cross platform equivalent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want to add shell calls in the base notifier, it's much safer to use wrapped commands in higher level libs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not? If this isnt automated very few people will set it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want:
get_current_user();
instead of shell executing whoami
. That function will give you the owner of the file, which is maybe better than nothing.
Something you could do if the user has installed and not disabled the functions from posix extension, is:
posix_getpwuid(posix_geteuid())['name'];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoami
works across all windows post server-2003 & unix-like systems. I'll add a check on the response to see if it returned correctly and fallback to get_current_user
if not.
src/HttpClient.php
Outdated
if (isset($buildInfo['builder'])) { | ||
$data['builderName'] = $buildInfo['builder']; | ||
} else { | ||
$data['builderName'] = exec('whoami'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should check if this function has been disabled, otherwise it'll crash. Many web hosts disable this by default for security.
} | ||
|
||
if (isset($buildInfo['builder'])) { | ||
$data['builderName'] = $buildInfo['builder']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want:
get_current_user();
instead of shell executing whoami
. That function will give you the owner of the file, which is maybe better than nothing.
Something you could do if the user has installed and not disabled the functions from posix extension, is:
posix_getpwuid(posix_geteuid())['name'];
…-php into cawllec/update-build-api
I was just looking for this and was about to contribute it. Is there any chance we can see this get merged and released soon? |
Yeah, i'll get this released this afternoon if possible. |
Awesome, thanks @Cawllec! |
adjustments made to fallback to get_file_owner
Updates to the new Bugsnag build API.
build
method to client to send build information off to bugsnagdeploy
method tobuild
methoddeploy
method in HTTP client unchangedsendBuildReport
to HTTP client to handle new API calls.setBuildEndpoint
andgetBuildEndpoint
to configuration, with a default.