Skip to content

Commit

Permalink
fix: add stopped status for maestro flows (#2070)
Browse files Browse the repository at this point in the history
  • Loading branch information
amanjeetsingh150 authored Oct 1, 2024
1 parent 9b23967 commit d6b69dc
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion maestro-cli/src/main/java/maestro/cli/api/ApiClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.github.michaelbull.result.map
import maestro.cli.CliError
import maestro.cli.analytics.Analytics
import maestro.cli.analytics.AnalyticsReport
import maestro.cli.model.FlowStatus
import maestro.cli.runner.resultview.AnsiResultView
import maestro.cli.util.CiUtils
import maestro.cli.util.EnvUtils
Expand Down Expand Up @@ -518,7 +519,7 @@ data class UploadStatus(

data class FlowResult(
val name: String,
val status: Status,
val status: FlowStatus,
val errors: List<String>,
val cancellationReason: CancellationReason? = null
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ class CloudInteractor(
val runningFlow = runningFlows.flows.find { it.name == uploadFlowResult.name } ?: continue
runningFlow.status = uploadFlowResult.status
when (runningFlow.status) {
UploadStatus.Status.PENDING -> { /* do nothing */ }
UploadStatus.Status.RUNNING -> {
FlowStatus.PENDING -> { /* do nothing */ }
FlowStatus.RUNNING -> {
if (runningFlow.startTime == null) {
runningFlow.startTime = System.currentTimeMillis()
}
Expand Down Expand Up @@ -392,7 +392,7 @@ class CloudInteractor(
val isCancelled = upload.status == UploadStatus.Status.CANCELED
val isFailure = upload.status == UploadStatus.Status.ERROR
val containsFailure =
upload.flows.find { it.status == UploadStatus.Status.ERROR } != null // status can be cancelled but also contain flow with failure
upload.flows.find { it.status == FlowStatus.ERROR } != null // status can be cancelled but also contain flow with failure

val failed = isFailure || containsFailure || isCancelled && failOnCancellation

Expand Down Expand Up @@ -448,7 +448,7 @@ class CloudInteractor(
TestExecutionSummary.FlowResult(
name = uploadFlowResult.name,
fileName = null,
status = FlowStatus.from(uploadFlowResult.status),
status = uploadFlowResult.status,
failure = if (failure != null) TestExecutionSummary.Failure(failure) else null,
duration = runningFlows.flows.find { it.name == uploadFlowResult.name }?.duration
)
Expand Down
1 change: 1 addition & 0 deletions maestro-cli/src/main/java/maestro/cli/model/FlowStatus.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ enum class FlowStatus {
SUCCESS,
ERROR,
CANCELED,
STOPPED,
WARNING;

companion object {
Expand Down
2 changes: 1 addition & 1 deletion maestro-cli/src/main/java/maestro/cli/model/RunningFlow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ data class RunningFlows(

data class RunningFlow(
val name: String,
var status: UploadStatus.Status? = null,
var status: FlowStatus? = null,
var startTime: Long? = null,
var duration: Duration? = null,
var reported: Boolean = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ object TestSuiteStatusView {
FlowStatus.SUCCESS,
FlowStatus.WARNING -> Ansi.Color.GREEN
FlowStatus.ERROR -> Ansi.Color.RED
FlowStatus.STOPPED -> Ansi.Color.RED
else -> Ansi.Color.DEFAULT
}
val title = when (status) {
Expand All @@ -96,6 +97,7 @@ object TestSuiteStatusView {
FlowStatus.ERROR -> "Failed"
FlowStatus.PENDING -> "Pending"
FlowStatus.RUNNING -> "Running"
FlowStatus.STOPPED -> "Stopped"
FlowStatus.CANCELED -> when (cancellationReason) {
UploadStatus.CancellationReason.TIMEOUT -> "Timeout"
UploadStatus.CancellationReason.OVERLAPPING_BENCHMARK -> "Skipped"
Expand Down Expand Up @@ -174,7 +176,7 @@ object TestSuiteStatusView {
duration: Duration? = null
) = FlowResult(
name = name,
status = FlowStatus.from(status, ),
status = status,
error = errors.firstOrNull(),
cancellationReason = cancellationReason,
duration = duration
Expand Down

0 comments on commit d6b69dc

Please sign in to comment.