Skip to content

Commit

Permalink
Add emoji into the PR status template (#57)
Browse files Browse the repository at this point in the history
* 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).

* update goreleaser arguments

---------
  • Loading branch information
LinuxSuRen committed Dec 23, 2024
1 parent d0b162e commit 45a4bb9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
6 changes: 3 additions & 3 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ jobs:
- name: Check out code
uses: actions/[email protected]
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2.9.1
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release --skip-publish --rm-dist
version: '~> v2'
args: release --clean --snapshot

build-image:
name: Build Image
Expand Down
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 45a4bb9

Please sign in to comment.