Skip to content
Myr

checker.ts

This file

Path

apps/web/src/dev/checker.ts

54 lines · 1.5 KiB · TypeScript

Last changed by

Merge build/comments-web-rest into mainoscabrielbefore adoption0eb1248

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–54why, one step back
1import { CheckAt, CheckRunner } from "@repo/checks/check-runner";
2import type { CheckJob } from "@repo/checks/check-runner";3import { CheckRunnerMemory, scriptKey } from "@repo/checks/check-runner/memory";4import type { LaneResult } from "@repo/protocol/domain/answer";5import { Context, Effect, Layer } from "effect";67import { printedBy } from "./examples.ts";89const scripted = (10 job: CheckJob,11 lane: CheckJob["lanes"][number]12): LaneResult => ({13 command: lane.command,14 durationMs: 1,15 lane: lane.lane,16 result: CheckAt.match(job.at, {17 Commit: () => "failed" as const,18 Tree: () => "passed" as const,19 }),20});2122export const DevChecker: Layer.Layer<CheckRunner> = Layer.effect(23 CheckRunner,24 Effect.gen(function* () {25 const script = new Map<string, readonly LaneResult[]>();26 const outputs = new Map<string, string>();2728 const memory = Context.get(29 yield* Layer.build(CheckRunnerMemory.layer(script, outputs)),30 CheckRunner31 );3233 return CheckRunner.of({34 run: (job) =>35 Effect.suspend(() => {36 for (const lane of job.lanes) {37 const key = scriptKey(job.at, lane.lane);3839 if (!script.has(key)) {40 script.set(key, [scripted(job, lane)]);41 }4243 const printed = printedBy.get(lane.command);4445 if (lane.output === "stdout" && printed !== undefined) {46 outputs.set(key, printed);47 }48 }4950 return memory.run(job);51 }),52 });53 })54);