Skip to content

Commit 00e6888

Browse files
hastyyTrigger.dev RepoOps
authored andcommitted
feat(webapp): add a flagged outcome for deployment checks
Deployment checks can report a new `flagged` outcome: the check passed, but found something worth a look. It is recorded like the other outcomes and never changes or stops a deployment. Mono-RevId: 6a78a780d8ec3924e263a1ba65353146ba37a979
1 parent b1013d9 commit 00e6888

3 files changed

Lines changed: 28 additions & 12 deletions

File tree

‎apps/webapp/app/v3/deploymentChecks.server.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { getMeter, type Meter } from "@internal/tracing";
22
import { Logger, type LogLevel } from "@trigger.dev/core/logger";
33
import type {
4+
DeploymentCheckOutcome,
45
DeploymentChecksController,
56
DeploymentChecksPlugin,
67
DeploymentChecksPluginConfig,
@@ -216,9 +217,7 @@ export type DeploymentCheckJobOutcome =
216217
| "no_plugin"
217218
| "not_found"
218219
| "skipped"
219-
| "pass"
220-
| "fail"
221-
| "unavailable";
220+
| DeploymentCheckOutcome;
222221

223222
export type DeploymentCheckJobDependencies = {
224223
prisma?: PrismaClientOrTransaction;

‎apps/webapp/test/deploymentChecks.test.ts‎

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,10 @@ describe("deployment checks", () => {
104104
// Catches: a background check changing a live deployment.
105105
const results: DeploymentCheckResult[] = [
106106
{ outcome: "pass", id: "check_1", retryable: false },
107-
{ outcome: "fail", id: "check_2", retryable: false },
108-
{ outcome: "unavailable", id: "check_3", retryable: false },
109-
{ outcome: "unavailable", id: "check_4", retryable: true },
107+
{ outcome: "flagged", id: "check_2", retryable: false },
108+
{ outcome: "fail", id: "check_3", retryable: false },
109+
{ outcome: "unavailable", id: "check_4", retryable: false },
110+
{ outcome: "unavailable", id: "check_5", retryable: true },
110111
];
111112
for (const result of results) {
112113
const { deployment } = await createDeployment(prisma);
@@ -127,12 +128,17 @@ describe("deployment checks", () => {
127128

128129
postgresTest("checks what the plugin chose, labelled with its mode", async ({ prisma }) => {
129130
// Catches: a gate or shadow deploy not checked, a skipped one checked, an image reference
130-
// the checker can't use sent, the plugin asked about the wrong org or deployment, or an org
131-
// id in the metric attributes.
131+
// the checker can't use sent, the plugin asked about the wrong org or deployment, an org id
132+
// in the metric attributes, or a flagged answer missing from the counter the deploy scan
133+
// alert reads.
132134
const metrics = createInMemoryMetrics();
133135
const telemetry = deploymentCheckTelemetry(metrics.meter);
134-
const run = async (decision: DeploymentCheckDecision, imageReference?: string | null) => {
135-
const plugin = testPlugin({ decision });
136+
const run = async (
137+
decision: DeploymentCheckDecision,
138+
imageReference?: string | null,
139+
result?: DeploymentCheckResult
140+
) => {
141+
const plugin = testPlugin({ decision, result });
136142
const { deployment, organization, project } = await createDeployment(prisma, {
137143
imageReference,
138144
});
@@ -175,6 +181,13 @@ describe("deployment checks", () => {
175181
]);
176182
}
177183

184+
const flagged = await run(SHADOW, undefined, {
185+
outcome: "flagged",
186+
id: "check_flagged",
187+
retryable: false,
188+
});
189+
expect(flagged.outcome).toBe("flagged");
190+
178191
// The reader also exports every 100 ms, and an earlier export holds partial totals. With
179192
// cumulative temporality the latest export holds every point.
180193
const points = ((await latestMetrics(metrics))?.scopeMetrics ?? [])
@@ -184,6 +197,7 @@ describe("deployment checks", () => {
184197
expect.arrayContaining([
185198
{ mode: "shadow", selected_by: "sampled", outcome: "pass" },
186199
{ mode: "gate", selected_by: "always", outcome: "pass" },
200+
{ mode: "shadow", selected_by: "sampled", outcome: "flagged" },
187201
])
188202
);
189203
for (const point of points ?? []) {

‎packages/plugins/src/deploymentChecks.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ export type DeploymentCheckInput = {
2424
decision: DeploymentCheckDecision & { plan: Exclude<DeploymentCheckPlan, "skip"> };
2525
};
2626

27-
/** pass and fail are answers. unavailable means there is no answer. */
28-
export type DeploymentCheckOutcome = "pass" | "fail" | "unavailable";
27+
/**
28+
* pass, flagged and fail are answers. flagged is a pass that found something worth a look: it never
29+
* stops a deployment. unavailable means there is no answer.
30+
*/
31+
export type DeploymentCheckOutcome = "pass" | "flagged" | "fail" | "unavailable";
2932

3033
export type DeploymentCheckResult = {
3134
outcome: DeploymentCheckOutcome;

0 commit comments

Comments
 (0)