Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Convert completed to successful #287

Merged
merged 2 commits into from
Jan 21, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const ReleaseIcon: React.FC<{
</div>
);

if (job?.status === JobStatus.Completed)
if (job?.status === JobStatus.Successful)
return (
<div className="rounded-full bg-green-400 p-1 dark:text-black">
<IconCircleCheck strokeWidth={2} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export const DeploymentNode: React.FC<DeploymentNodeProps> = ({ data }) => {
const isPending = latestActiveReleases.some(
(r) => r.releaseJobTrigger.job.status === JobStatus.Pending,
);
const isCompleted = latestActiveReleases.every(
(r) => r.releaseJobTrigger.job.status === JobStatus.Completed,
const isSuccess = latestActiveReleases.every(
(r) => r.releaseJobTrigger.job.status === JobStatus.Successful,
);

const releaseJobTrigger = activeRelease?.releaseJobTrigger;
Expand All @@ -52,7 +52,7 @@ export const DeploymentNode: React.FC<DeploymentNodeProps> = ({ data }) => {
"relative flex h-[70px] w-[250px] cursor-pointer items-center gap-2 rounded-md border border-neutral-800 bg-neutral-900/30 px-4",
isInProgress && "border-blue-500",
isPending && "border-neutral-500",
isCompleted && "border-green-500",
isSuccess && "border-green-500",
releaseJobTrigger == null && "border-neutral-800",
)}
onClick={() =>
Expand Down Expand Up @@ -81,7 +81,7 @@ export const DeploymentNode: React.FC<DeploymentNodeProps> = ({ data }) => {
"h-2 w-2 rounded-full border border-neutral-800 bg-neutral-800",
isInProgress && "border-blue-500",
isPending && "border-neutral-500",
isCompleted && "border-green-500",
isSuccess && "border-green-500",
releaseJobTrigger == null && "border-neutral-800",
)}
position={Position.Left}
Expand All @@ -93,7 +93,7 @@ export const DeploymentNode: React.FC<DeploymentNodeProps> = ({ data }) => {
"h-2 w-2 rounded-full border border-neutral-800 bg-neutral-800",
isInProgress && "border-blue-500",
isPending && "border-neutral-500",
isCompleted && "border-green-500",
isSuccess && "border-green-500",
releaseJobTrigger == null && "border-neutral-800",
)}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const statusColors = {
[JobStatus.InvalidJobAgent]: colors.amber[400],
[JobStatus.Failure]: colors.red[600],
[JobStatus.InProgress]: colors.blue[500],
[JobStatus.Completed]: colors.green[500],
[JobStatus.Successful]: colors.green[500],
};

const statusLabels = {
Expand All @@ -42,7 +42,7 @@ const statusLabels = {
[JobStatus.InvalidJobAgent]: "Invalid Job Agent",
[JobStatus.Failure]: "Failure",
[JobStatus.InProgress]: "In Progress",
[JobStatus.Completed]: "Completed",
[JobStatus.Successful]: "Successful",
};

type DailyCount = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const JobTableStatusIcon: React.FC<{
status?: schema.JobStatus;
className?: string;
}> = ({ status, className }) => {
if (status === JobStatus.Completed)
if (status === JobStatus.Successful)
return (
<IconCircleCheck className={cn("h-4 w-4 text-green-400", className)} />
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ export const JobComparisonConditionRender: React.FC<
addCondition({
type: JobFilterType.Status,
operator: ColumnOperator.Equals,
value: JobStatus.Completed,
value: JobStatus.Successful,
})
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export const RunbookJobComparisonConditionRender: React.FC<
addCondition({
type: JobFilterType.Status,
operator: ColumnOperator.Equals,
value: JobStatus.Completed,
value: JobStatus.Successful,
})
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { cn } from "@ctrlplane/ui";
import { Card } from "@ctrlplane/ui/card";
import { TableCell, TableHead } from "@ctrlplane/ui/table";
import { JobStatus } from "@ctrlplane/validators/jobs";

import { api } from "~/trpc/react";

Expand Down Expand Up @@ -41,7 +42,8 @@ export const DeploymentsContent: React.FC<{ resourceId: string }> = ({
"shrink-0 rounded-full px-2 text-xs",
deployment.releaseJobTrigger?.job == null &&
"bg-neutral-800 text-muted-foreground",
deployment.releaseJobTrigger?.job.status === "completed" &&
deployment.releaseJobTrigger?.job.status ===
JobStatus.Successful &&
"bg-green-500/30 text-green-400 text-muted-foreground",
)}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ const ReleaseIcon: React.FC<{
</div>
);

const isComplete = statuses.every((s) => s === JobStatus.Completed);
const isComplete = statuses.every((s) => s === JobStatus.Successful);
if (isComplete)
return (
<div className="rounded-full bg-green-400 p-1 dark:text-black">
<IconCircleCheck strokeWidth={2} className="h-4 w-4" />
</div>
);

const isRollingOut = statuses.some((s) => s === JobStatus.Completed);
const isRollingOut = statuses.some((s) => s === JobStatus.Successful);
if (isRollingOut)
return (
<div className="rounded-full bg-green-400 p-1 dark:text-black">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export const EnvironmentNode: React.FC<EnvironmentNodeProps> = (node) => {
const environmentJobs = releaseJobTriggers.data?.filter(
(job) => job.environmentId === data.id,
);
const completed = environmentJobs?.filter(
(job) => job.job.status === JobStatus.Completed,
const successful = environmentJobs?.filter(
(job) => job.job.status === JobStatus.Successful,
);
return (
<>
Expand All @@ -40,7 +40,7 @@ export const EnvironmentNode: React.FC<EnvironmentNodeProps> = (node) => {
variant="outline"
className="rounded-md text-xs text-muted-foreground"
>
{completed?.length} / {environmentJobs?.length}
{successful?.length} / {environmentJobs?.length}
</Badge>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ const MinSuccessCheck: React.FC<PolicyNodeProps["data"]> = ({

if (successType === "some") {
const passing =
jobs?.filter((job) => job.job.status === JobStatus.Completed).length ?? 0;
jobs?.filter((job) => job.job.status === JobStatus.Successful).length ??
0;

const isMinSatified = passing >= successMinimum;
return (
Expand All @@ -55,14 +56,14 @@ const MinSuccessCheck: React.FC<PolicyNodeProps["data"]> = ({
);
}

const areAllCompleted =
jobs?.every((job) => job.job.status === JobStatus.Completed) ?? true;
const areAllSuccessful =
jobs?.every((job) => job.job.status === JobStatus.Successful) ?? true;

return (
<div className="flex items-center gap-2">
{areAllCompleted ? (
{areAllSuccessful ? (
<>
<Passing /> All jobs completed
<Passing /> All jobs successful
</>
) : (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { JobStatus } from "@ctrlplane/db/schema";
import colors from "tailwindcss/colors";

export const statusColor: Record<JobStatus | "configured", string> = {
completed: colors.green[400],
successful: colors.green[400],
cancelled: colors.neutral[400],
skipped: colors.gray[400],
in_progress: colors.blue[400],
Expand Down
14 changes: 7 additions & 7 deletions apps/webservice/src/app/api/github/webhook/workflow/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ import { exitedStatus, JobStatus } from "@ctrlplane/validators/jobs";

type Conclusion = Exclude<WorkflowRunEvent["workflow_run"]["conclusion"], null>;
const convertConclusion = (conclusion: Conclusion): schema.JobStatus => {
if (conclusion === "success") return "completed";
if (conclusion === "action_required") return "action_required";
if (conclusion === "cancelled") return "cancelled";
if (conclusion === "neutral") return "skipped";
if (conclusion === "skipped") return "skipped";
return "failure";
if (conclusion === "success") return JobStatus.Successful;
if (conclusion === "action_required") return JobStatus.ActionRequired;
if (conclusion === "cancelled") return JobStatus.Cancelled;
if (conclusion === "neutral") return JobStatus.Skipped;
if (conclusion === "skipped") return JobStatus.Skipped;
return JobStatus.Failure;
};

const convertStatus = (
status: WorkflowRunEvent["workflow_run"]["status"],
): schema.JobStatus =>
status === JobStatus.Completed ? JobStatus.Completed : JobStatus.InProgress;
status === "completed" ? JobStatus.Successful : JobStatus.InProgress;

const extractUuid = (str: string) => {
const uuidRegex =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
releaseMetadata,
resource,
} from "@ctrlplane/db/schema";
import { JobStatus } from "@ctrlplane/validators/jobs";

import { getUser } from "~/app/api/v1/auth";

Expand All @@ -38,11 +39,11 @@ export const GET = async (
and(
eq(job.jobAgentId, params.agentId),
notInArray(job.status, [
"failure",
"cancelled",
"skipped",
"completed",
"invalid_job_agent",
JobStatus.Failure,
JobStatus.Cancelled,
JobStatus.Skipped,
JobStatus.Successful,
JobStatus.InvalidJobAgent,
]),
isNull(resource.deletedAt),
),
Expand Down
4 changes: 3 additions & 1 deletion apps/webservice/src/app/api/v1/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const openapi: Swagger.SwaggerV3 = {
status: {
type: "string",
enum: [
"completed",
"successful",
"cancelled",
"skipped",
"in_progress",
Expand All @@ -138,6 +138,8 @@ export const openapi: Swagger.SwaggerV3 = {
},
createdAt: { type: "string", format: "date-time" },
updatedAt: { type: "string", format: "date-time" },
startedAt: { type: "string", format: "date-time", nullable: true },
completedAt: { type: "string", format: "date-time", nullable: true },
jobAgentId: { type: "string", format: "uuid" },
jobAgentConfig: {
type: "object",
Expand Down
10 changes: 5 additions & 5 deletions openapi.v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -2634,7 +2634,7 @@
"status": {
"type": "string",
"enum": [
"completed",
"successful",
"cancelled",
"skipped",
"in_progress",
Expand All @@ -2655,6 +2655,10 @@
"type": "string",
"format": "date-time"
},
"updatedAt": {
"type": "string",
"format": "date-time"
},
"startedAt": {
"type": "string",
"format": "date-time",
Expand All @@ -2665,10 +2669,6 @@
"format": "date-time",
"nullable": true
},
"updatedAt": {
"type": "string",
"format": "date-time"
},
"jobAgentId": {
"type": "string",
"format": "uuid"
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/router/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ export const deploymentRouter = createTRPCRouter({
eq(environment.id, env.environment.id),
isNull(resource.deletedAt),
inArray(job.status, [
JobStatus.Completed,
JobStatus.Successful,
JobStatus.Pending,
JobStatus.InProgress,
]),
Expand Down
1 change: 1 addition & 0 deletions packages/db/drizzle/0060_stale_warlock.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TYPE job_status RENAME VALUE 'completed' TO 'successful';
Loading
Loading