Skip to content

Commit 0c12e0c

Browse files
Display failing activities as failing in CLI (#1572)
1 parent 3aed65d commit 0c12e0c

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

src/Command/Activity/ActivityGetCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
131131
$rows = [];
132132
foreach ($properties as $property => $value) {
133133
$header[] = $property;
134-
$rows[] = $this->propertyFormatter->format($value, $property);
134+
if ($property === 'result') {
135+
$rows[] = ActivityMonitor::formatResult($activity, !$this->table->formatIsMachineReadable());
136+
} else {
137+
$rows[] = $this->propertyFormatter->format($value, $property);
138+
}
135139
}
136140

137141
$this->table->renderSimple($rows, $header);

src/Command/Activity/ActivityListCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
135135
'type' => new AdaptiveTableCell($activity->type, ['wrap' => false]),
136136
'progress' => $activity->getCompletionPercent() . '%',
137137
'state' => ActivityMonitor::formatState($activity->state),
138-
'result' => ActivityMonitor::formatResult($activity->result, !$this->table->formatIsMachineReadable()),
138+
'result' => ActivityMonitor::formatResult($activity, !$this->table->formatIsMachineReadable()),
139139
'environments' => implode(', ', $activity->environments),
140140
];
141141
$timings = $activity->getProperty('timings', false, false) ?: [];

src/Command/Environment/EnvironmentDeployCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8787
'created' => $this->propertyFormatter->format($activity['created_at'], 'created_at'),
8888
'description' => ActivityMonitor::getFormattedDescription($activity, !$this->table->formatIsMachineReadable()),
8989
'type' => new AdaptiveTableCell($activity->type, ['wrap' => false]),
90-
'result' => ActivityMonitor::formatResult($activity->result, !$this->table->formatIsMachineReadable()),
90+
'result' => ActivityMonitor::formatResult($activity, !$this->table->formatIsMachineReadable()),
9191
];
9292
$rows[] = $row;
9393
}

src/Command/Integration/Activity/IntegrationActivityListCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
109109
'type' => new AdaptiveTableCell($activity->type, ['wrap' => false]),
110110
'progress' => $activity->getCompletionPercent() . '%',
111111
'state' => ActivityMonitor::formatState($activity->state),
112-
'result' => ActivityMonitor::formatResult($activity->result, !$this->table->formatIsMachineReadable()),
112+
'result' => ActivityMonitor::formatResult($activity, !$this->table->formatIsMachineReadable()),
113113
];
114114
$timings = $activity->getProperty('timings', false, false) ?: [];
115115
foreach ($timingTypes as $timingType) {

src/Service/ActivityMonitor.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,10 +586,19 @@ public static function formatState(string $state): string
586586
/**
587587
* Formats an activity result.
588588
*/
589-
public static function formatResult(string $result, bool $decorate = true): string
589+
public static function formatResult(Activity $activity, bool $decorate = true): string
590590
{
591+
$result = $activity->result;
591592
$name = self::RESULT_NAMES[$result] ?? $result;
592593

594+
foreach ($activity->commands ?? [] as $command) {
595+
if ($command['exit_code'] > 0) {
596+
$name = Activity::RESULT_FAILURE;
597+
$result = Activity::RESULT_FAILURE;
598+
break;
599+
}
600+
}
601+
593602
return $decorate && $result === Activity::RESULT_FAILURE
594603
? '<error>' . $name . '</error>'
595604
: $name;

0 commit comments

Comments
 (0)