Skip to content

Commit 82eb0d7

Browse files
authored
fix(api): workflow run report (#2992)
1 parent d9f651d commit 82eb0d7

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

engine/api/workflow/workflow_run_event.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ func sendVCSEventStatus(db gorp.SqlExecutor, store cache.Store, proj *sdk.Projec
238238
//Send comment on pull request
239239
for _, pr := range prs {
240240
if pr.Head.Branch.DisplayID == nodeRun.VCSBranch && pr.Head.Branch.LatestCommit == nodeRun.VCSHash {
241+
if nodeRun.Status != sdk.StatusFail.String() {
242+
continue
243+
}
241244
report, err := nodeRun.Report()
242245
if err != nil {
243246
log.Error("sendVCSEventStatus> unable to compute node run report%v", err)

sdk/workflow_run.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,17 @@ func (w *WorkflowNodeRunArtifact) GetPath() string {
293293
return container
294294
}
295295

296-
const workflowNodeRunReport = `CDS Report {{.WorkflowNodeName}}#{{.Number}}.{{.SubNumber}}
297-
{{range $s := .Stages}}
296+
const workflowNodeRunReport = `{{- if .Stages }}
297+
CDS Report {{.WorkflowNodeName}}#{{.Number}}.{{.SubNumber}} {{ if eq .Status "Success" -}} ✔ {{ else }}{{ if eq .Status "Fail" -}} ✘ {{ else }}- {{ end }} {{ end }}
298+
{{- range $s := .Stages}}
299+
{{- if $s.RunJobs }}
298300
* {{$s.Name}}
299301
{{- range $j := $s.RunJobs}}
300302
* {{$j.Job.Action.Name}} {{ if eq $j.Status "Success" -}} ✔ {{ else }}{{ if eq $j.Status "Fail" -}} ✘ {{ else }}- {{ end }} {{ end }}
301303
{{- end}}
302-
{{end}}
304+
{{- end}}
305+
{{- end}}
306+
{{- end}}
303307
304308
{{- if .Tests }}
305309
{{- if gt .Tests.TotalKO 0}}

sdk/workflow_run_test.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ func TestWorkflowRunReport(t *testing.T) {
6969
},
7070
},
7171
}
72+
s, err := wfr.Report()
73+
assert.NoError(t, err)
74+
t.Log(s)
7275

7376
wfr = WorkflowNodeRun{
7477
Stages: []Stage{
@@ -98,10 +101,24 @@ func TestWorkflowRunReport(t *testing.T) {
98101
},
99102
},
100103
},
104+
Tests: nil,
105+
Status: StatusSuccess.String(),
106+
}
107+
108+
s, err = wfr.Report()
109+
assert.NoError(t, err)
110+
t.Log(s)
111+
112+
wfr = WorkflowNodeRun{
113+
Stages: []Stage{
114+
{
115+
Name: "stage 1",
116+
},
117+
},
101118
Tests: nil,
102119
}
103120

104-
s, err := wfr.Report()
121+
s, err = wfr.Report()
105122
assert.NoError(t, err)
106123
t.Log(s)
107124
}

0 commit comments

Comments
 (0)