Skip to content

Commit e8102f4

Browse files
committed
FEATURE: raise prunner version to 0.2.0, make debuggability easier
1 parent d4331e8 commit e8102f4

5 files changed

Lines changed: 58 additions & 28 deletions

File tree

Classes/Command/PrunnerCommandController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ class PrunnerCommandController extends CommandController
1212
private const COMPOSER_INSTALL_CMD_KEY = 'post-install-cmd';
1313
private const COMPOSER_UPDATE_CMD_KEY = 'post-update-cmd';
1414

15+
/**
16+
* Patch project's composer.json file to install prunner binaries on "composer install"
17+
*/
1518
public function setupProjectCommand()
1619
{
1720
$cmd = InstallerScripts::class . '::postUpdateAndInstall';

Classes/Composer/InstallerScripts.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static function postUpdateAndInstall(Event $event)
3535
$platform = php_uname('s'); // stuff like Darwin etc
3636
$architecture = php_uname('m'); // x86_64
3737

38-
$version = '0.1.0';
38+
$version = '0.2.0';
3939

4040
$baseDirectory = 'prunner';
4141
$platformSpecificTargetDirectory = $baseDirectory . '/' . $platform . '_' . $architecture;

Classes/Dto/Job.php

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,39 @@ class Job
2626
private array $variables;
2727
private string $user;
2828

29+
private function __construct(string $id, string $pipeline, TaskResults $taskResults, bool $completed, bool $canceled, bool $errored, \DateTimeImmutable $created, ?\DateTimeImmutable $start, ?\DateTimeImmutable $end, ?string $lastError, array $variables, string $user)
30+
{
31+
$this->id = $id;
32+
$this->pipeline = $pipeline;
33+
$this->taskResults = $taskResults;
34+
$this->completed = $completed;
35+
$this->canceled = $canceled;
36+
$this->errored = $errored;
37+
$this->created = $created;
38+
$this->start = $start;
39+
$this->end = $end;
40+
$this->lastError = $lastError;
41+
$this->variables = $variables;
42+
$this->user = $user;
43+
}
44+
45+
2946
public static function fromJsonArray(array $in): self
3047
{
31-
$job = new static();
32-
$job->id = $in['id'];
33-
$job->pipeline = $in['pipeline'];
34-
$job->taskResults = TaskResults::fromJsonArray($in['tasks']);;
35-
$job->completed = $in['completed'];
36-
$job->canceled = $in['canceled'];
37-
$job->errored = $in['errored'];
38-
$job->created = \DateTimeImmutable::createFromFormat(\DateTimeInterface::W3C, $in['created']);
39-
$job->start = isset($in['start']) ? \DateTimeImmutable::createFromFormat(\DateTimeInterface::W3C, $in['start']) : null;
40-
$job->end = isset($in['end']) ? \DateTimeImmutable::createFromFormat(\DateTimeInterface::W3C, $in['end']) : null;
41-
$job->lastError = $in['lastError'];
42-
$job->variables = $in['variables'] ?? [];
43-
$job->user = $in['user'];
44-
45-
return $job;
48+
return new self(
49+
$in['id'],
50+
$in['pipeline'],
51+
TaskResults::fromJsonArray($in['tasks']),
52+
$in['completed'],
53+
$in['canceled'],
54+
$in['errored'],
55+
\DateTimeImmutable::createFromFormat(\DateTimeInterface::W3C, $in['created']),
56+
isset($in['start']) ? \DateTimeImmutable::createFromFormat(\DateTimeInterface::W3C, $in['start']) : null,
57+
isset($in['end']) ? \DateTimeImmutable::createFromFormat(\DateTimeInterface::W3C, $in['end']) : null,
58+
$in['lastError'] ?? '',
59+
$in['variables'] ?? [],
60+
$in['user']
61+
);
4662
}
4763

4864
/**

Classes/Dto/TaskResult.php

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,31 @@ class TaskResult
1919
private bool $errored;
2020
private ?string $error;
2121

22+
private function __construct(string $name, string $status, ?\DateTimeImmutable $start, ?\DateTimeImmutable $end, bool $skipped, int $exitCode, bool $errored, ?string $error)
23+
{
24+
$this->name = $name;
25+
$this->status = $status;
26+
$this->start = $start;
27+
$this->end = $end;
28+
$this->skipped = $skipped;
29+
$this->exitCode = $exitCode;
30+
$this->errored = $errored;
31+
$this->error = $error;
32+
}
33+
34+
2235
public static function fromJsonArray(array $in): self
2336
{
24-
$taskResult = new static();
25-
$taskResult->name = $in['name'];
26-
$taskResult->status = $in['status'];
27-
$taskResult->start = isset($in['start']) ? \DateTimeImmutable::createFromFormat(\DateTimeInterface::RFC3339, $in['start']) : null;
28-
$taskResult->end = isset($in['end']) ? \DateTimeImmutable::createFromFormat(\DateTimeInterface::RFC3339, $in['end']) : null;
29-
$taskResult->skipped = $in['skipped'];
30-
$taskResult->exitCode = $in['exitCode'];
31-
$taskResult->errored = $in['errored'];
32-
$taskResult->error = $in['error'];
33-
34-
return $taskResult;
37+
return new self(
38+
$in['name'],
39+
$in['status'],
40+
isset($in['start']) ? \DateTimeImmutable::createFromFormat(\DateTimeInterface::RFC3339, $in['start']) : null,
41+
isset($in['end']) ? \DateTimeImmutable::createFromFormat(\DateTimeInterface::RFC3339, $in['end']) : null,
42+
$in['skipped'],
43+
$in['exitCode'],
44+
$in['errored'],
45+
$in['error'] ?? ''
46+
);
3547
}
3648

3749
/**

Classes/PrunnerApiService.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Flowpack\Prunner\ValueObject\JobId;
99
use Flowpack\Prunner\ValueObject\PipelineName;
1010
use GuzzleHttp\Client;
11-
use GuzzleHttp\Psr7\Response;
1211
use Neos\Flow\Annotations as Flow;
1312
use Psr\Http\Message\ResponseInterface;
1413
use Symfony\Component\Yaml\Exception\ParseException;

0 commit comments

Comments
 (0)