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

Add a new deployment status 'queued' #279

Merged
merged 4 commits into from
Dec 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ require (
require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/go-bindata/go-bindata v1.0.1-0.20190711162640-ee3c2418e368 // indirect
github.com/go-openapi/inflect v0.19.0 // indirect
github.com/go-playground/locales v0.13.0 // indirect
github.com/go-playground/universal-translator v0.17.0 // indirect
github.com/go-playground/validator/v10 v10.6.1 // indirect
Expand Down Expand Up @@ -63,9 +65,12 @@ require (
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect
golang.org/x/mod v0.4.2 // indirect
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
golang.org/x/text v0.3.6 // indirect
golang.org/x/tools v0.1.5 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/protobuf v1.26.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm
github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmCsR2Do=
github.com/gin-gonic/gin v1.7.7 h1:3DoBmSbJbZAWqXJC3SLjAPfutPJJRN1U5pALB7EeTTs=
github.com/gin-gonic/gin v1.7.7/go.mod h1:axIBovoeJpVj8S3BwE0uPMTeReE4+AfFtqpqaZ1qq1U=
github.com/go-bindata/go-bindata v1.0.1-0.20190711162640-ee3c2418e368 h1:WNHfSP1q2vuAa9vF54RrhCl4nqxCjVcXhlbsRXbGOSY=
github.com/go-bindata/go-bindata v1.0.1-0.20190711162640-ee3c2418e368/go.mod h1:7xCgX1lzlrXPHkfvn3EhumqHkmSlzt8at9q7v0ax19c=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
Expand All @@ -114,6 +115,7 @@ github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vb
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4=
github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4=
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
Expand Down Expand Up @@ -518,6 +520,7 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -685,6 +688,7 @@ golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
4 changes: 4 additions & 0 deletions internal/server/hooks/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,14 @@ func mapGithubDeploymentStatus(e *github.DeploymentStatusEvent) *ent.DeploymentS
// "success" to "success", and "failure" to "failure".
func mapGithubState(state string) deployment.Status {
switch state {
case "queued":
return deployment.StatusQueued
Comment on lines +260 to +261
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handle the queued status in the hooks

case "success":
return deployment.StatusSuccess
case "failure":
return deployment.StatusFailure
case "error":
return deployment.StatusFailure
default:
return deployment.StatusRunning
}
Expand Down
2 changes: 2 additions & 0 deletions internal/server/slack/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ func mapDeploymentStatusToColor(status deployment.Status) string {
return colorGray
case deployment.StatusCreated:
return colorPurple
case deployment.StatusQueued:
return colorPurple
case deployment.StatusRunning:
return colorPurple
case deployment.StatusSuccess:
Expand Down
3 changes: 2 additions & 1 deletion model/ent/deployment/deployment.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion model/ent/migrate/schema.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions model/ent/schema/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func (Deployment) Fields() []ent.Field {
Values(
"waiting",
"created",
"queued",
"running",
"success",
"failure",
Expand Down
1 change: 1 addition & 0 deletions openapi/v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1616,6 +1616,7 @@ components:
enum:
- waiting
- created
- queued
- running
- success
- failure
Expand Down
4 changes: 4 additions & 0 deletions ui/src/apis/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ function mapDeploymentStatusEnum(s: string) {
return DeploymentStatusEnum.Waiting
case "created":
return DeploymentStatusEnum.Created
case "queued":
return DeploymentStatusEnum.Queued
case "running":
return DeploymentStatusEnum.Running
case "success":
Expand Down Expand Up @@ -132,6 +134,8 @@ function mapDeploymentStatusToString(status: DeploymentStatusEnum): string {
return "waiting"
case DeploymentStatusEnum.Created:
return "created"
case DeploymentStatusEnum.Queued:
return "queued"
case DeploymentStatusEnum.Running:
return "running"
case DeploymentStatusEnum.Success:
Expand Down
38 changes: 22 additions & 16 deletions ui/src/components/ActivityLogs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,27 @@ interface ActivityLogsProps {
}

export default function ActivityLogs(props: ActivityLogsProps): JSX.Element {
return <Timeline>
{props.deployments.map((d, idx) => {
const dot = (d.status === DeploymentStatusEnum.Running)?
<SyncOutlined style={{color: "purple"}} spin />:
null
const avatar = <UserAvatar user={d.deployer} />
return (
<Timeline>
{props.deployments.map((d, idx) => {
const dot = (d.status === DeploymentStatusEnum.Running)?
<SyncOutlined style={{color: "purple"}} spin />:
null
const avatar = <UserAvatar user={d.deployer} />

return <Timeline.Item key={idx} color={getStatusColor(d.status)} dot={dot}>
<p>
<Text strong>{d.env}</Text> <DeploymentRefCode deployment={d}/> <a href={`/${d.repo?.namespace}/${d.repo?.name}/deployments/${d.number}`}>• View detail #{d.number}</a>
</p>
<p>
Deployed by {avatar} {moment(d.createdAt).fromNow()} <DeploymentStatusBadge deployment={d}/>
</p>
</Timeline.Item>
})}
</Timeline>
return (
<Timeline.Item key={idx} color={getStatusColor(d.status)} dot={dot}>
<p>
<Text strong>{d.env}</Text> <DeploymentRefCode deployment={d}/> <a href={`/${d.repo?.namespace}/${d.repo?.name}/deployments/${d.number}`}>• View detail #{d.number}</a>
</p>
<p>
Deployed by {avatar} {moment(d.createdAt).fromNow()} <DeploymentStatusBadge deployment={d}/>
</p>
</Timeline.Item>
)
})}
</Timeline>
)
}

// https://ant.design/components/timeline/#Timeline.Item
Expand All @@ -40,6 +44,8 @@ const getStatusColor = (status: DeploymentStatusEnum) => {
return "gray"
case DeploymentStatusEnum.Created:
return "purple"
case DeploymentStatusEnum.Queued:
return "purple"
case DeploymentStatusEnum.Running:
return "purple"
case DeploymentStatusEnum.Success:
Expand Down
2 changes: 2 additions & 0 deletions ui/src/components/DeploymentStatusBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const getStatusColor = (status: DeploymentStatusEnum) => {
return "gray"
case DeploymentStatusEnum.Created:
return "purple"
case DeploymentStatusEnum.Queued:
return "purple"
case DeploymentStatusEnum.Running:
return "purple"
case DeploymentStatusEnum.Success:
Expand Down
1 change: 1 addition & 0 deletions ui/src/models/Deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export enum DeploymentType {
export enum DeploymentStatusEnum {
Waiting = "waiting",
Created = "created",
Queued = "queued",
Running = "running",
Success = "success",
Failure = "failure",
Expand Down
2 changes: 2 additions & 0 deletions ui/src/redux/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const searchDeployments = createAsyncThunk<Deployment[], void, { state: {
const deployments = await _searchDeployments([
DeploymentStatusEnum.Waiting,
DeploymentStatusEnum.Created,
DeploymentStatusEnum.Queued,
DeploymentStatusEnum.Running,
], false)
return deployments
Expand Down Expand Up @@ -239,6 +240,7 @@ export const mainSlice = createSlice({
if (idx !== -1 ) {
if (!(event.deployment?.status === DeploymentStatusEnum.Waiting
|| event.deployment?.status === DeploymentStatusEnum.Created
|| event.deployment?.status === DeploymentStatusEnum.Queued
|| event.deployment?.status === DeploymentStatusEnum.Running)) {
state.deployments.splice(idx, 1)
return
Expand Down