Skip to content

Commit

Permalink
Improve error reporting in github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
albertwoo committed Oct 21, 2024
1 parent 0953d6c commit fc9808c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions Fun.Build/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

## [1.1.11] - 2024-10-21

- Improve error reporting in github actions

## [1.1.10] - 2024-10-21

- Improve error reporting in github actions
Expand Down
4 changes: 2 additions & 2 deletions Fun.Build/PipelineContextExtensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module PipelineContextExtensionsInternal =
}


member this.GetErrorPrefix() = if this.EnvVars.ContainsKey("GITHUB_ENV") then "::error" else "Error:"
member this.GetErrorPrefix() = if this.EnvVars.ContainsKey("GITHUB_ENV") then "::error::" else "Error: "


member this.RunStages(stages: StageContext seq, cancelToken: Threading.CancellationToken, ?failfast: bool) =
Expand Down Expand Up @@ -158,7 +158,7 @@ module PipelineContextExtensionsInternal =
if pipelineExns.Count > 0 then
for exn in pipelineExns do
let innerMessage = if exn.InnerException <> null then exn.InnerException.Message else ""
AnsiConsole.MarkupLineInterpolated $"[red]{this.GetErrorPrefix()} {exn.Message} {innerMessage}[/]"
AnsiConsole.MarkupLineInterpolated $"[red]{this.GetErrorPrefix()}{exn.Message} {innerMessage}[/]"
AnsiConsole.WriteLine()
raise (PipelineFailedException("Pipeline is failed because of exception", pipelineExns[0]))
else if hasError then
Expand Down
8 changes: 4 additions & 4 deletions Fun.Build/StageContextExtensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ module StageContextExtensionsInternal =

member ctx.GetErrorPrefix() =
match ctx.TryGetEnvVar("GITHUB_ENV") with
| ValueSome _ -> "::error"
| _ -> "Error:"
| ValueSome _ -> "::error::"
| _ -> "Error: "


member ctx.GetNoPrefixForStep() =
Expand Down Expand Up @@ -253,9 +253,9 @@ module StageContextExtensionsInternal =
| Error e ->
if String.IsNullOrEmpty e |> not then
if not isParallel && stage.GetNoPrefixForStep() then
AnsiConsole.MarkupLineInterpolated $"""[red]{stage.GetErrorPrefix()} {e}[/]"""
AnsiConsole.MarkupLineInterpolated $"""[red]{stage.GetErrorPrefix()}{e}[/]"""
else
AnsiConsole.MarkupLineInterpolated $"""[red]{stage.GetErrorPrefix()} {prefix} {e}[/]"""
AnsiConsole.MarkupLineInterpolated $"""[red]{stage.GetErrorPrefix()}{prefix} {e}[/]"""
return false
| Ok _ -> return true
}
Expand Down

0 comments on commit fc9808c

Please sign in to comment.