From 019c3db7d97819e21c03b1bb3a220d2df774af2f Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Wed, 15 Oct 2025 08:52:14 +0200 Subject: [PATCH] Display failing activities as failing in CLI --- src/Command/Activity/ActivityGetCommand.php | 6 +++++- src/Command/Activity/ActivityListCommand.php | 2 +- .../Activity/IntegrationActivityListCommand.php | 2 +- src/Service/ActivityMonitor.php | 10 +++++++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Command/Activity/ActivityGetCommand.php b/src/Command/Activity/ActivityGetCommand.php index 8d023f425..add6f8fcb 100644 --- a/src/Command/Activity/ActivityGetCommand.php +++ b/src/Command/Activity/ActivityGetCommand.php @@ -131,7 +131,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $rows = []; foreach ($properties as $property => $value) { $header[] = $property; - $rows[] = $this->propertyFormatter->format($value, $property); + if ($property === 'result') { + $rows[] = ActivityMonitor::formatResult($activity, !$this->table->formatIsMachineReadable()); + } else { + $rows[] = $this->propertyFormatter->format($value, $property); + } } $this->table->renderSimple($rows, $header); diff --git a/src/Command/Activity/ActivityListCommand.php b/src/Command/Activity/ActivityListCommand.php index 077f10506..098e40167 100644 --- a/src/Command/Activity/ActivityListCommand.php +++ b/src/Command/Activity/ActivityListCommand.php @@ -135,7 +135,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int 'type' => new AdaptiveTableCell($activity->type, ['wrap' => false]), 'progress' => $activity->getCompletionPercent() . '%', 'state' => ActivityMonitor::formatState($activity->state), - 'result' => ActivityMonitor::formatResult($activity->result, !$this->table->formatIsMachineReadable()), + 'result' => ActivityMonitor::formatResult($activity, !$this->table->formatIsMachineReadable()), 'environments' => implode(', ', $activity->environments), ]; $timings = $activity->getProperty('timings', false, false) ?: []; diff --git a/src/Command/Integration/Activity/IntegrationActivityListCommand.php b/src/Command/Integration/Activity/IntegrationActivityListCommand.php index c7c5116dc..a13fde8fd 100644 --- a/src/Command/Integration/Activity/IntegrationActivityListCommand.php +++ b/src/Command/Integration/Activity/IntegrationActivityListCommand.php @@ -109,7 +109,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int 'type' => new AdaptiveTableCell($activity->type, ['wrap' => false]), 'progress' => $activity->getCompletionPercent() . '%', 'state' => ActivityMonitor::formatState($activity->state), - 'result' => ActivityMonitor::formatResult($activity->result, !$this->table->formatIsMachineReadable()), + 'result' => ActivityMonitor::formatResult($activity, !$this->table->formatIsMachineReadable()), ]; $timings = $activity->getProperty('timings', false, false) ?: []; foreach ($timingTypes as $timingType) { diff --git a/src/Service/ActivityMonitor.php b/src/Service/ActivityMonitor.php index d81e04f48..3fc50055b 100644 --- a/src/Service/ActivityMonitor.php +++ b/src/Service/ActivityMonitor.php @@ -586,10 +586,18 @@ public static function formatState(string $state): string /** * Formats an activity result. */ - public static function formatResult(string $result, bool $decorate = true): string + public static function formatResult(Activity $activity, bool $decorate = true): string { + $result = $activity->result; $name = self::RESULT_NAMES[$result] ?? $result; + foreach ($activity->commands ?? [] as $command) { + if ($command['exit_code'] > 0) { + $name = Activity::RESULT_FAILURE; + break; + } + } + return $decorate && $result === Activity::RESULT_FAILURE ? '' . $name . '' : $name;