Skip to content

Commit

Permalink
Fix checkrun status issue
Browse files Browse the repository at this point in the history
we encountered a bug related to status display
when resolving multiple checkrun issues as part of 1566.
This was rectified by introducing a new
title specifix to multiple checkrun scenario.

Signed-off-by: Savita Ashture <sashture@redhat.com>
  • Loading branch information
savitaashture authored and chmouel committed Apr 19, 2024
1 parent d1dbd12 commit de3ce9b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pkg/provider/github/status.go
Expand Up @@ -92,7 +92,7 @@ func isFailedCheckrun(run *github.CheckRun) bool {
if run == nil || run.Output == nil {
return false
}
if run.Output.Title != nil && strings.Contains(*run.Output.Title, "Failed") &&
if run.Output.Title != nil && strings.Contains(*run.Output.Title, "pipelinerun start failure") &&
run.Output.Summary != nil &&
strings.Contains(*run.Output.Summary, "failed") {
return true
Expand Down Expand Up @@ -206,6 +206,8 @@ func (v *Provider) getOrUpdateCheckRunStatus(ctx context.Context, runevent *info
// when multiple pipelineruns fail. In such cases, generate only one checkrun ID,
// regardless of the number of failed pipelineruns.
if statusOpts.Title == "Failed" && statusOpts.PipelineRunName == "" {
// setting different title to handle multiple checkrun cases
statusOpts.Title = "pipelinerun start failure"
if statusOpts.InstanceCountForCheckRun >= 1 {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion test/github_pullrequest_test.go
Expand Up @@ -129,7 +129,7 @@ func TestGithubPullRequestSecondBadYaml(t *testing.T) {
time.Sleep(5 * time.Second)
}
assert.Equal(t, len(res.CheckRuns), 1)
assert.Equal(t, res.CheckRuns[0].GetOutput().GetTitle(), "Failed")
assert.Equal(t, res.CheckRuns[0].GetOutput().GetTitle(), "pipelinerun start failure")
// may be fragile if we change the application name, but life goes on if it fails and we fix the name if that happen
assert.Equal(t, res.CheckRuns[0].GetOutput().GetSummary(), "Pipelines as Code GHE has <b>failed</b>.")
golden.Assert(t, res.CheckRuns[0].GetOutput().GetText(), strings.ReplaceAll(fmt.Sprintf("%s.golden", t.Name()), "/", "-"))
Expand Down

0 comments on commit de3ce9b

Please sign in to comment.