Skip to content
Myr

classify.test.ts

This file

Path

packages/gate/test/classify.test.ts

135 lines · 3.6 KiB · TypeScript

Last changed by

Merge build/comments-packages-rest into mainoscabrielbefore adoption38cd503

History of this file

Take it

The walk stopped after 200 commits: lines older than 678c8b8 point at it.

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 1–135why, one step back
1import { describe, expect, it } from "@effect/vitest";
2import { LaneName, RepoPath } from "@repo/protocol/ids";3import {4 ChecksFailed,5 Flake,6 StaleBase,7 VerifierBlocked,8} from "@repo/protocol/refusal";9import type { Refusal } from "@repo/protocol/refusal";10import { Option } from "effect";1112import { classifyFailure } from "../src/classify.ts";13import type { LaneEvidence } from "../src/classify.ts";14import { base, main, wire } from "./facts.ts";1516const unit = LaneName.make("unit");1718const week = RepoPath.make("packages/parse/src/week.ts");1920const pad = RepoPath.make("packages/format/src/pad.ts");2122const changed: ReadonlySet<RepoPath> = new Set([week]);2324const red: LaneEvidence = {25 command: "bun run test",26 failingPaths: [week],27 isDoctor: false,28 lane: unit,29 logRef: "logs/datekit/unit-2222222",30 onMain: "passed",31 onMerged: "failed",32 rerun: Option.none(),33};3435const rows: readonly {36 readonly name: string;37 readonly evidence: LaneEvidence;38 readonly refusal: Option.Option<Refusal>;39}[] = [40 {41 evidence: red,42 name: "passes on main, fails on merged inside the diff",43 refusal: Option.some(44 new ChecksFailed({45 lane: unit,46 logRef: "logs/datekit/unit-2222222",47 next: "bun run test",48 })49 ),50 },51 {52 evidence: { ...red, rerun: Option.some("failed") },53 name: "fails again the same way on a fresh run",54 refusal: Option.some(55 new ChecksFailed({56 lane: unit,57 logRef: "logs/datekit/unit-2222222",58 next: "bun run test",59 })60 ),61 },62 {63 evidence: { ...red, failingPaths: [] },64 name: "fails on merged with no file named",65 refusal: Option.some(66 new ChecksFailed({67 lane: unit,68 logRef: "logs/datekit/unit-2222222",69 next: "bun run test",70 })71 ),72 },73 {74 evidence: { ...red, rerun: Option.some("passed") },75 name: "fails, then passes on a fresh run of the same tree",76 refusal: Option.some(new Flake({ lane: unit })),77 },78 {79 evidence: { ...red, onMerged: "blocked" },80 name: "the checker could not start, which earns one fresh run",81 refusal: Option.some(new Flake({ lane: unit })),82 },83 {84 evidence: { ...red, onMerged: "blocked", rerun: Option.some("blocked") },85 name: "the checker could not start twice on a tree whose main passes",86 refusal: Option.some(87 new ChecksFailed({88 lane: unit,89 logRef: "logs/datekit/unit-2222222",90 next: "bun run test",91 })92 ),93 },94 {95 evidence: { ...red, onMain: "blocked", onMerged: "blocked" },96 name: "the checker could not start on main either, so no fresh run is spent",97 refusal: Option.some(new VerifierBlocked({})),98 },99 {100 evidence: {101 ...red,102 command: "bun run doctor",103 isDoctor: true,104 lane: LaneName.make("doctor"),105 onMain: "failed",106 },107 name: "the doctor lane fails on main",108 refusal: Option.some(new VerifierBlocked({})),109 },110 {111 evidence: { ...red, onMain: "failed" },112 name: "the lane fails on main too",113 refusal: Option.some(new VerifierBlocked({})),114 },115 {116 evidence: { ...red, failingPaths: [pad] },117 name: "fails on merged outside the diff, on a lane that passes on main",118 refusal: Option.some(new StaleBase({ base, conflicts: [], main })),119 },120 {121 evidence: { ...red, onMerged: "passed" },122 name: "passes on merged",123 refusal: Option.none(),124 },125];126127describe(classifyFailure, () => {128 it.each(rows)("$name", ({ evidence, refusal }) => {129 const found = classifyFailure(evidence, changed, { base, main });130131 expect(Option.map(found, (one) => wire([one]))).toStrictEqual(132 Option.map(refusal, (one) => wire([one]))133 );134 });135});