Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit 6483e60

Browse files
author
Noah Lee
authored
Add a new deployment status 'queued' (#279)
* Add a new status queued * Add to handle the 'queued' status in the hooks * Fix to handle queued in the Slack * Fix to handle the 'queued' status in UI
1 parent 36cd7c4 commit 6483e60

File tree

13 files changed

+51
-18
lines changed

13 files changed

+51
-18
lines changed

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ require (
3333
require (
3434
github.com/beorn7/perks v1.0.1 // indirect
3535
github.com/cespare/xxhash/v2 v2.1.1 // indirect
36+
github.com/go-bindata/go-bindata v1.0.1-0.20190711162640-ee3c2418e368 // indirect
37+
github.com/go-openapi/inflect v0.19.0 // indirect
3638
github.com/go-playground/locales v0.13.0 // indirect
3739
github.com/go-playground/universal-translator v0.17.0 // indirect
3840
github.com/go-playground/validator/v10 v10.6.1 // indirect
@@ -63,9 +65,12 @@ require (
6365
go.uber.org/atomic v1.7.0 // indirect
6466
go.uber.org/multierr v1.6.0 // indirect
6567
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect
68+
golang.org/x/mod v0.4.2 // indirect
6669
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect
6770
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
6871
golang.org/x/text v0.3.6 // indirect
72+
golang.org/x/tools v0.1.5 // indirect
73+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
6974
google.golang.org/appengine v1.6.6 // indirect
7075
google.golang.org/protobuf v1.26.0 // indirect
7176
gopkg.in/yaml.v2 v2.4.0 // indirect

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm
104104
github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmCsR2Do=
105105
github.com/gin-gonic/gin v1.7.7 h1:3DoBmSbJbZAWqXJC3SLjAPfutPJJRN1U5pALB7EeTTs=
106106
github.com/gin-gonic/gin v1.7.7/go.mod h1:axIBovoeJpVj8S3BwE0uPMTeReE4+AfFtqpqaZ1qq1U=
107+
github.com/go-bindata/go-bindata v1.0.1-0.20190711162640-ee3c2418e368 h1:WNHfSP1q2vuAa9vF54RrhCl4nqxCjVcXhlbsRXbGOSY=
107108
github.com/go-bindata/go-bindata v1.0.1-0.20190711162640-ee3c2418e368/go.mod h1:7xCgX1lzlrXPHkfvn3EhumqHkmSlzt8at9q7v0ax19c=
108109
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
109110
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
@@ -114,6 +115,7 @@ github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vb
114115
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
115116
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
116117
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
118+
github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4=
117119
github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4=
118120
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
119121
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
@@ -520,6 +522,7 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB
520522
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
521523
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
522524
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
525+
golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
523526
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
524527
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
525528
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -687,6 +690,7 @@ golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc
687690
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
688691
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
689692
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
693+
golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=
690694
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
691695
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
692696
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

internal/server/hooks/hook.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,14 @@ func mapGithubDeploymentStatus(e *github.DeploymentStatusEvent) *ent.DeploymentS
257257
// "success" to "success", and "failure" to "failure".
258258
func mapGithubState(state string) deployment.Status {
259259
switch state {
260+
case "queued":
261+
return deployment.StatusQueued
260262
case "success":
261263
return deployment.StatusSuccess
262264
case "failure":
263265
return deployment.StatusFailure
266+
case "error":
267+
return deployment.StatusFailure
264268
default:
265269
return deployment.StatusRunning
266270
}

internal/server/slack/notification.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ func mapDeploymentStatusToColor(status deployment.Status) string {
157157
return colorGray
158158
case deployment.StatusCreated:
159159
return colorPurple
160+
case deployment.StatusQueued:
161+
return colorPurple
160162
case deployment.StatusRunning:
161163
return colorPurple
162164
case deployment.StatusSuccess:

model/ent/deployment/deployment.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

model/ent/migrate/schema.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

model/ent/schema/deployment.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func (Deployment) Fields() []ent.Field {
3030
Values(
3131
"waiting",
3232
"created",
33+
"queued",
3334
"running",
3435
"success",
3536
"failure",

openapi/v1.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,6 +1616,7 @@ components:
16161616
enum:
16171617
- waiting
16181618
- created
1619+
- queued
16191620
- running
16201621
- success
16211622
- failure

ui/src/apis/deployment.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ function mapDeploymentStatusEnum(s: string) {
102102
return DeploymentStatusEnum.Waiting
103103
case "created":
104104
return DeploymentStatusEnum.Created
105+
case "queued":
106+
return DeploymentStatusEnum.Queued
105107
case "running":
106108
return DeploymentStatusEnum.Running
107109
case "success":
@@ -132,6 +134,8 @@ function mapDeploymentStatusToString(status: DeploymentStatusEnum): string {
132134
return "waiting"
133135
case DeploymentStatusEnum.Created:
134136
return "created"
137+
case DeploymentStatusEnum.Queued:
138+
return "queued"
135139
case DeploymentStatusEnum.Running:
136140
return "running"
137141
case DeploymentStatusEnum.Success:

ui/src/components/ActivityLogs.tsx

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,27 @@ interface ActivityLogsProps {
1414
}
1515

1616
export default function ActivityLogs(props: ActivityLogsProps): JSX.Element {
17-
return <Timeline>
18-
{props.deployments.map((d, idx) => {
19-
const dot = (d.status === DeploymentStatusEnum.Running)?
20-
<SyncOutlined style={{color: "purple"}} spin />:
21-
null
22-
const avatar = <UserAvatar user={d.deployer} />
17+
return (
18+
<Timeline>
19+
{props.deployments.map((d, idx) => {
20+
const dot = (d.status === DeploymentStatusEnum.Running)?
21+
<SyncOutlined style={{color: "purple"}} spin />:
22+
null
23+
const avatar = <UserAvatar user={d.deployer} />
2324

24-
return <Timeline.Item key={idx} color={getStatusColor(d.status)} dot={dot}>
25-
<p>
26-
<Text strong>{d.env}</Text> <DeploymentRefCode deployment={d}/> <a href={`/${d.repo?.namespace}/${d.repo?.name}/deployments/${d.number}`}>• View detail #{d.number}</a>
27-
</p>
28-
<p>
29-
Deployed by {avatar} {moment(d.createdAt).fromNow()} <DeploymentStatusBadge deployment={d}/>
30-
</p>
31-
</Timeline.Item>
32-
})}
33-
</Timeline>
25+
return (
26+
<Timeline.Item key={idx} color={getStatusColor(d.status)} dot={dot}>
27+
<p>
28+
<Text strong>{d.env}</Text> <DeploymentRefCode deployment={d}/> <a href={`/${d.repo?.namespace}/${d.repo?.name}/deployments/${d.number}`}>• View detail #{d.number}</a>
29+
</p>
30+
<p>
31+
Deployed by {avatar} {moment(d.createdAt).fromNow()} <DeploymentStatusBadge deployment={d}/>
32+
</p>
33+
</Timeline.Item>
34+
)
35+
})}
36+
</Timeline>
37+
)
3438
}
3539

3640
// https://ant.design/components/timeline/#Timeline.Item
@@ -40,6 +44,8 @@ const getStatusColor = (status: DeploymentStatusEnum) => {
4044
return "gray"
4145
case DeploymentStatusEnum.Created:
4246
return "purple"
47+
case DeploymentStatusEnum.Queued:
48+
return "purple"
4349
case DeploymentStatusEnum.Running:
4450
return "purple"
4551
case DeploymentStatusEnum.Success:

0 commit comments

Comments
 (0)