Skip to content

Commit d68af1f

Browse files
authored
Merge pull request #1577 from platformsh/backport-0c12e0c1-php56
backport (4.x): Display failing activities as failing in CLI
2 parents 9a84792 + 04bf2f3 commit d68af1f

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

src/Command/Activity/ActivityGetCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
120120
$rows = [];
121121
foreach ($properties as $property => $value) {
122122
$header[] = $property;
123-
$rows[] = $formatter->format($value, $property);
123+
if ($property === 'result') {
124+
$rows[] = ActivityMonitor::formatResult($activity, !$table->formatIsMachineReadable());
125+
} else {
126+
$rows[] = $formatter->format($value, $property);
127+
}
124128
}
125129

126130
$table->renderSimple($rows, $header);

src/Command/Activity/ActivityListCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
122122
'type' => new AdaptiveTableCell($activity->type, ['wrap' => false]),
123123
'progress' => $activity->getCompletionPercent() . '%',
124124
'state' => ActivityMonitor::formatState($activity->state),
125-
'result' => ActivityMonitor::formatResult($activity->result, !$table->formatIsMachineReadable()),
125+
'result' => ActivityMonitor::formatResult($activity, !$table->formatIsMachineReadable()),
126126
'environments' => implode(', ', $activity->environments),
127127
];
128128
$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
@@ -72,7 +72,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
7272
'created' => $formatter->format($activity['created_at'], 'created_at'),
7373
'description' => ActivityMonitor::getFormattedDescription($activity, !$table->formatIsMachineReadable()),
7474
'type' => new AdaptiveTableCell($activity->type, ['wrap' => false]),
75-
'result' => ActivityMonitor::formatResult($activity->result, !$table->formatIsMachineReadable()),
75+
'result' => ActivityMonitor::formatResult($activity, !$table->formatIsMachineReadable()),
7676
];
7777
$rows[] = $row;
7878
}

src/Command/Integration/Activity/IntegrationActivityListCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
101101
'type' => new AdaptiveTableCell($activity->type, ['wrap' => false]),
102102
'progress' => $activity->getCompletionPercent() . '%',
103103
'state' => ActivityMonitor::formatState($activity->state),
104-
'result' => ActivityMonitor::formatResult($activity->result, !$table->formatIsMachineReadable()),
104+
'result' => ActivityMonitor::formatResult($activity, !$table->formatIsMachineReadable()),
105105
];
106106
$timings = $activity->getProperty('timings', false, false) ?: [];
107107
foreach ($timingTypes as $timingType) {

src/Service/ActivityMonitor.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -564,15 +564,25 @@ public static function formatState($state)
564564
/**
565565
* Format a result.
566566
*
567-
* @param string $result
568-
* @param bool $decorate
567+
* @param Activity $activity
568+
* @param bool $decorate
569569
*
570570
* @return string
571571
*/
572-
public static function formatResult($result, $decorate = true)
572+
public static function formatResult($activity, $decorate = true)
573573
{
574+
$result = $activity->result;
574575
$name = isset(self::$resultNames[$result]) ? self::$resultNames[$result] : $result;
575576

577+
$commands = isset($activity->commands) ? $activity->commands : array();
578+
foreach ($commands as $command) {
579+
if ($command['exit_code'] > 0) {
580+
$name = self::$resultNames[Activity::RESULT_FAILURE];
581+
$result = Activity::RESULT_FAILURE;
582+
break;
583+
}
584+
}
585+
576586
return $decorate && $result === Activity::RESULT_FAILURE
577587
? '<error>' . $name . '</error>'
578588
: $name;

0 commit comments

Comments
 (0)