-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add experimental webhook feature, simple bitbucket interface, event for
- Loading branch information
Showing
10 changed files
with
379 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Playbloom\Satisfy\Controller; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; | ||
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException; | ||
|
||
class WebhookController extends Controller | ||
{ | ||
/** | ||
* @param Request $request | ||
* @return Response | ||
* @throws BadRequestHttpException | ||
* @throws ServiceUnavailableHttpException | ||
*/ | ||
public function bitbucketAction(Request $request): Response | ||
{ | ||
$webhook = $this->container->get('satisfy.webhook.bitbucket'); | ||
try { | ||
$status = $webhook->handle($request); | ||
} catch (\InvalidArgumentException $exception) { | ||
throw new BadRequestHttpException(); | ||
} catch (\Throwable $exception) { | ||
throw new ServiceUnavailableHttpException(); | ||
} | ||
|
||
return new Response($status); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Playbloom\Satisfy\Event; | ||
|
||
use Playbloom\Satisfy\Model\RepositoryInterface; | ||
use Symfony\Component\EventDispatcher\Event; | ||
|
||
class BuildEvent extends Event | ||
{ | ||
const EVENT_NAME = 'satis_build'; | ||
|
||
/** @var RepositoryInterface|null */ | ||
private $repository; | ||
|
||
/** @var int|null */ | ||
private $status; | ||
|
||
public function __construct(RepositoryInterface $repository = null) | ||
{ | ||
$this->repository = $repository; | ||
} | ||
|
||
/** | ||
* @return RepositoryInterface|null | ||
*/ | ||
public function getRepository() | ||
{ | ||
return $this->repository; | ||
} | ||
|
||
/** | ||
* @return int|null | ||
*/ | ||
public function getStatus() | ||
{ | ||
return $this->status; | ||
} | ||
|
||
public function setStatus(int $status) | ||
{ | ||
$this->status = $status; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace Playbloom\Satisfy\Process; | ||
|
||
use Symfony\Component\Process\Process; | ||
|
||
class ProcessFactory | ||
{ | ||
/** @var string */ | ||
protected $rootPath; | ||
|
||
/** @var string */ | ||
protected $homePath; | ||
|
||
public function __construct(string $rootPath, string $homePath) | ||
{ | ||
$this->rootPath = $rootPath; | ||
$this->homePath = $homePath; | ||
} | ||
|
||
public function getRootPath(): string | ||
{ | ||
return $this->rootPath; | ||
} | ||
|
||
public function create(string $command, int $timeout = null): Process | ||
{ | ||
return new Process($command, $this->rootPath, $this->getEnv(), null, $timeout); | ||
} | ||
|
||
protected function getEnv(): array | ||
{ | ||
$env = []; | ||
|
||
foreach ($_SERVER as $k => $v) { | ||
if (is_string($v) && false !== $v = getenv($k)) { | ||
$env[$k] = $v; | ||
} | ||
} | ||
|
||
foreach ($_ENV as $k => $v) { | ||
if (is_string($v)) { | ||
$env[$k] = $v; | ||
} | ||
} | ||
|
||
if (empty($env['HOME'])) { | ||
$env['HOME'] = $this->homePath; | ||
} | ||
|
||
return $env; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.