Skip to content

Commit

Permalink
Add emoji into the PR status template
Browse files Browse the repository at this point in the history
Fixes #56

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/LinuxSuRen/gogit/issues/56?shareId=XXXX-XXXX-XXXX-XXXX).
  • Loading branch information
LinuxSuRen committed Dec 20, 2024
1 parent d0b162e commit 8db94a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/argoworkflow/template/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const CommentTemplate = `
| Stage | Status | Duration |
|---|---|---|
{{- range $_, $status := .Status.Nodes}}
| {{$status.DisplayName}} | {{$status.Phase}} | {{duration $status.FinishedAt $status.StartedAt}} |
| {{$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}} |
{{- end}}
`

Expand Down
17 changes: 8 additions & 9 deletions cmd/argoworkflow/template/comment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@ func TestCommentTemplate(t *testing.T) {
startTime := v1.Time{Time: targetTime}
endTime := v1.Time{Time: startTime.Add(time.Second * 5)}

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"}
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"}
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"}
// TODO cannot handle the situation in template
// node3 := map[string]interface{}{"DisplayName": "node-2.OnExit"}
// node4 := map[string]interface{}{"DisplayName": "plugin-8bs4n.hooks.all"}
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"}

nodes := map[string]interface{}{}
nodes["node1"] = node1
nodes["node2"] = node2
// nodes["node3"] = node3
// nodes["node4"] = node4
nodes["node3"] = node3

status := map[string]interface{}{}
status["Nodes"] = nodes
Expand Down Expand Up @@ -56,8 +53,9 @@ func TestCommentTemplate(t *testing.T) {
| Stage | Status | Duration |
|---|---|---|
| node-1 | Success | 5s |
| node-2 | Failed | 5s |
| node-1 | :white_check_mark: Succeeded | 5s |
| node-2 | :broken_heart: Failed | 5s |
| node-3 | :hourglass_flowing_sand: Running | 5s |
`, result)

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

Expand Down

0 comments on commit 8db94a0

Please sign in to comment.