Skip to content

Commit 78e522c

Browse files
committed
Add emoji into the PR status template
Fixes #56 --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/LinuxSuRen/gogit/issues/56?shareId=XXXX-XXXX-XXXX-XXXX).
1 parent d0b162e commit 78e522c

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

cmd/argoworkflow/template/comment.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const CommentTemplate = `
88
| Stage | Status | Duration |
99
|---|---|---|
1010
{{- range $_, $status := .Status.Nodes}}
11-
| {{$status.DisplayName}} | {{$status.Phase}} | {{duration $status.FinishedAt $status.StartedAt}} |
11+
| {{$status.DisplayName}} | {{if eq $status.Phase "Failed"}}:broken_heart:{{else if eq $status.Phase "Succeeded"}}:white_check_mark:{{else if eq $status.Phase "Running"}}:hourglass_flowing_sand:{{end}} {{$status.Phase}} | {{duration $status.FinishedAt $status.StartedAt}} |
1212
{{- end}}
1313
`
1414

cmd/argoworkflow/template/comment_test.go

+8-9
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,14 @@ func TestCommentTemplate(t *testing.T) {
1818
startTime := v1.Time{Time: targetTime}
1919
endTime := v1.Time{Time: startTime.Add(time.Second * 5)}
2020

21-
node1 := map[string]interface{}{"Phase": "Success", "DisplayName": "node-1", "StartedAt": startTime, "FinishedAt": endTime, "StartedTime": "2023-01-06T07:49:07Z", "EndedTime": "2023-01-06T07:54:26Z"}
21+
node1 := map[string]interface{}{"Phase": "Succeeded", "DisplayName": "node-1", "StartedAt": startTime, "FinishedAt": endTime, "StartedTime": "2023-01-06T07:49:07Z", "EndedTime": "2023-01-06T07:54:26Z"}
2222
node2 := map[string]interface{}{"Phase": "Failed", "DisplayName": "node-2", "StartedAt": startTime, "FinishedAt": endTime, "StartedTime": "2023-01-06T07:49:07Z", "EndedTime": "2023-01-06T07:54:26Z"}
23-
// TODO cannot handle the situation in template
24-
// node3 := map[string]interface{}{"DisplayName": "node-2.OnExit"}
25-
// node4 := map[string]interface{}{"DisplayName": "plugin-8bs4n.hooks.all"}
23+
node3 := map[string]interface{}{"Phase": "Running", "DisplayName": "node-3", "StartedAt": startTime, "FinishedAt": endTime, "StartedTime": "2023-01-06T07:49:07Z", "EndedTime": "2023-01-06T07:54:26Z"}
2624

2725
nodes := map[string]interface{}{}
2826
nodes["node1"] = node1
2927
nodes["node2"] = node2
30-
// nodes["node3"] = node3
31-
// nodes["node4"] = node4
28+
nodes["node3"] = node3
3229

3330
status := map[string]interface{}{}
3431
status["Nodes"] = nodes
@@ -56,8 +53,9 @@ func TestCommentTemplate(t *testing.T) {
5653
5754
| Stage | Status | Duration |
5855
|---|---|---|
59-
| node-1 | Success | 5s |
60-
| node-2 | Failed | 5s |
56+
| node-1 | :white_check_mark: Succeeded | 5s |
57+
| node-2 | :broken_heart: Failed | 5s |
58+
| node-3 | :hourglass_flowing_sand: Running | 5s |
6159
`, result)
6260

6361
result, err = template.RenderTemplate(`
@@ -73,8 +71,9 @@ func TestCommentTemplate(t *testing.T) {
7371
<!-- Generated by https://github.com/LinuxSuRen/gogit -->
7472
| Stage | Status | Duration |
7573
|---|---|---|
76-
| node-1 | Success | 5m19s |
74+
| node-1 | Succeeded | 5m19s |
7775
| node-2 | Failed | 5m19s |
76+
| node-3 | Running | 5m19s |
7877
`, result)
7978
}
8079

0 commit comments

Comments
 (0)