GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — t3code/scripts/check-changed.ts at main · AndryHTC/t3code Expand file tree/ Copy pathcheck-changed.tsMore file actions 626 lines (592 loc) · 25.7 KB / Copy pathcheck-changed.tsFile metadata and controls626 lines (592 loc) · 25.7 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 // @effect-diagnostics nodeBuiltinImport:off - hashes inputs with node:crypto and sizes the budget with node:os. // Runs CI's fast checks for this branch's changes: format and lint of the // changed files, knip, generated GraphQL operations, typecheck of the affected // packages and their dependents, the test files beside the changed files, and // the cross-file checks those miss (agent context budget, React Compiler // coverage of the changed client files). // A dependency change also gets the unused-patch install check below. CI still // runs the full test suites and the jobs listed in the summary. // // vp run check:changed compare against the closest merge base with any remote main // vp run check:changed <ref> compare against the merge base with <ref> // vp run check:changed --concurrency 1 run the steps one at a time // // Uncommitted and untracked files count. Affected packages come from // .github/scripts/ci-changes.cjs, the same mapping CI uses to gate its jobs. // The steps run side by side within a budget derived from the machine's cores // and available memory, and each prints its output when it finishes. A step // running past the timeout is killed with its process group and reported as // TIMEOUT. A rerun on exactly the files of the last passing run prints that // run's summary. import * as NodeCrypto from "node:crypto"; import * as NodeOS from "node:os"; import * as NodeRuntime from "@effect/platform-node/NodeRuntime"; import * as NodeServices from "@effect/platform-node/NodeServices"; import * as HostProcess from "@t3tools/shared/HostProcess"; import * as Clock from "effect/Clock"; import * as Config from "effect/Config"; import * as Console from "effect/Console"; import * as Effect from "effect/Effect"; import * as FileSystem from "effect/FileSystem"; import * as Option from "effect/Option"; import * as Path from "effect/Path"; import type * as PlatformError from "effect/PlatformError"; import * as Schema from "effect/Schema"; import * as Semaphore from "effect/Semaphore"; import * as Stream from "effect/Stream"; import { Argument, Command, Flag } from "effect/cli"; import { ChildProcess, ChildProcessSpawner } from "effect/process"; import { decide, readWorkspace } from "../.github/scripts/ci-changes.cjs"; import { vitePlusCommand } from "./check-changed-command.ts"; const GiB = 1024 ** 3; // A typecheck or test step can take several cores and gigabytes of memory, so // allow one step per two cores and per 6 GiB of available memory. export const defaultConcurrency = (cores: number, availableBytes: number) => Math.max(1, Math.min(Math.floor(cores / 2), Math.floor(availableBytes / (6 * GiB)))); export type Outcome = "pass" | "FAIL" | "TIMEOUT"; export interface Step<R> { readonly name: string; readonly run: Effect.Effect<{ readonly ok: boolean; readonly output: string }, never, R>; // Budget slots the step holds: one per worker it runs in parallel. readonly weight?: number; // Vitest runs started together race to rebuild node_modules/.vitest-cache (ENOTEMPTY). readonly serial?: boolean; } // Interrupting a step at its timeout closes the scopes of the processes it // spawned, which kills each one's process group. export const runSteps = Effect.fn("checkChanged.runSteps")(function* <R>( steps: ReadonlyArray<Step<R>>, options: { readonly concurrency: number; readonly timeoutSeconds: number }, ) { const budget = yield* Semaphore.make(options.concurrency); // Steps claim budget one at a time, in order: Semaphore lets a light request // take free slots ahead of a waiting heavier one, which would delay typecheck. const admission = yield* Semaphore.make(1); const serial = yield* Semaphore.make(1); return yield* Effect.forEach( steps, (step) => { const timed = Effect.gen(function* () { const started = yield* Clock.currentTimeMillis; const result = yield* Effect.timeoutOption(step.run, `${options.timeoutSeconds} seconds`); const seconds = ((yield* Clock.currentTimeMillis) - started) / 1000; const outcome: Outcome = Option.match(result, { onNone: () => "TIMEOUT", onSome: ({ ok }) => (ok ? "pass" : "FAIL"), }); const time = outcome === "TIMEOUT" ? `killed after ${options.timeoutSeconds}s` : `${seconds.toFixed(1)}s`; yield* Console.log(`\n> vp ${step.name} ${outcome} ${time}`); const output = Option.getOrUndefined(result)?.output.trimEnd(); if (output) yield* Console.log(output); return { name: step.name, outcome, time }; }); const slots = Math.min(step.weight ?? 1, options.concurrency); const limited = Effect.acquireUseRelease( admission.withPermit(budget.take(slots)), () => timed, () => budget.release(slots), ); return step.serial ? serial.withPermit(limited) : limited; }, { concurrency: "unbounded" }, ); }); const CacheEntry = Schema.fromJsonString( Schema.Struct({ key: Schema.String, summary: Schema.Array(Schema.String) }), ); const decodeCacheEntry = Schema.decodeEffect(CacheEntry); const encodeCacheEntry = Schema.encodeEffect(CacheEntry); const decodeRootPackageJson = Schema.decodeEffect( Schema.fromJsonString( Schema.Struct({ scripts: Schema.Struct({ "knip:check:files": Schema.String, "knip:check:exports": Schema.String, }), }), ), ); const collectBytes = (stream: Stream.Stream<Uint8Array, PlatformError.PlatformError>) => Stream.runCollect(stream).pipe(Effect.map((chunks) => Buffer.concat(chunks))); // Fails on a nonzero exit: an empty file list from a broken index would // otherwise pass as "no changes". quotePath=false keeps non-ASCII paths as real // paths instead of quoted escapes. export const git = Effect.fn("checkChanged.git")(function* ( cwd: string, args: ReadonlyArray<string>, ) { const spawner = yield* ChildProcessSpawner.ChildProcessSpawner; return yield* Effect.scoped( Effect.gen(function* () { const handle = yield* spawner.spawn( ChildProcess.make("git", ["-c", "core.quotePath=false", ...args], { cwd }), ); const [stdout, stderr, exitCode] = yield* Effect.all( [collectBytes(handle.stdout), collectBytes(handle.stderr), handle.exitCode], { concurrency: "unbounded" }, ); if (exitCode !== 0) { return yield* Effect.fail( `check:changed: git ${args.join(" ")} exited with ${exitCode}: ${stderr.toString().trim()}`, ); } return stdout; }), ); }); export const gitLines = (cwd: string, args: ReadonlyArray<string>) => git(cwd, args).pipe(Effect.map((stdout) => stdout.toString().split("\n").filter(Boolean))); export const comparisonBase = Effect.fn("checkChanged.comparisonBase")(function* ( root: string, explicitRef: Option.Option<string>, ) { const candidates = Option.isSome(explicitRef) ? [{ ref: explicitRef.value, rev: explicitRef.value }] : (yield* gitLines(root, ["remote"])).map((name) => ({ ref: name + "/main", rev: "refs/remotes/" + name + "/main", })); let closest: { ref: string; base: string; ahead: number } | undefined; for (const { ref, rev } of candidates) { const base = yield* git(root, ["merge-base", "HEAD", rev]).pipe( Effect.map((stdout) => stdout.toString().trim()), Effect.orElseSucceed(() => undefined), ); if (!base) continue; const ahead = Number((yield* git(root, ["rev-list", "--count", base + "..HEAD"])).toString()); if (!closest || ahead < closest.ahead) closest = { ref, base, ahead }; } if (!closest) { const tried = candidates.map(({ ref }) => ref).join(", ") || "a remote main"; return yield* Effect.fail( "check:changed: no merge base with " + tried + ". Run git fetch or pass a ref.", ); } return closest; }); // CI's lint and knip also read Astro components' frontmatter. const CODE = /\.(?:[cm]?[jt]sx?|astro)$/; const TEST = /\.test\.[cm]?[jt]sx?$/; // CI runs the .github/scripts tests with `node --test`; vitest passes a failing node:test file. const NODE_TEST = /^\.github[/\\]scripts[/\\]/; export const splitTests = (tests: Iterable<string>) => { const all = [...tests]; return { vitestTests: all.filter((file) => !NODE_TEST.test(file)), nodeTests: all.filter((file) => NODE_TEST.test(file)), }; }; const escapeRegExp = (text: string) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // A flag wins over its environment variable; either must be a positive integer. const override = Effect.fn("checkChanged.override")(function* ( flagName: string, flag: Option.Option<number>, envName: string, ) { const [name, value] = Option.isSome(flag) ? [`--${flagName}`, flag] : [envName, yield* Config.option(Config.Int(envName))]; if (Option.isSome(value) && value.value < 1) { return yield* Effect.fail(`check:changed: ${name} must be a positive integer.`); } return value; }); // Tests that read a doc; a changed doc has no test beside it to select them. export const docReaderTests = (files: ReadonlyArray<string>) => files.includes("docs/user/t3-connect-troubleshooting.md") ? ["apps/server/src/cloud/ConnectReachability.test.ts"] : []; const checkChanged = Effect.fn("checkChanged")(function* (input: { readonly ref: Option.Option<string>; readonly concurrency: Option.Option<number>; readonly timeout: Option.Option<number>; }) { const fs = yield* FileSystem.FileSystem; const path = yield* Path.Path; const spawner = yield* ChildProcessSpawner.ChildProcessSpawner; const root = yield* path.fromFileUrl(new URL("..", import.meta.url)); const inRoot = (file: string) => path.join(root, file); // macOS counts its file cache as used, so available memory there would // starve a large Mac. Elsewhere availableMemory() honors a cgroup limit. const platform = yield* HostProcess.Platform; const concurrency = Option.getOrElse( yield* override("concurrency", input.concurrency, "CHECK_CHANGED_CONCURRENCY"), () => defaultConcurrency( NodeOS.availableParallelism(), platform === "darwin" ? NodeOS.totalmem() : process.availableMemory(), ), ); const timeoutSeconds = Option.getOrElse( yield* override("timeout", input.timeout, "CHECK_CHANGED_TIMEOUT"), () => 900, ); const lines = (...args: Array<string>) => gitLines(root, args); const { ref, base } = yield* comparisonBase(root, input.ref); // --no-renames lists a rename as its old and new path, as CI does. const changedFiles = lines("diff", "--name-only", "--no-renames", base, "--"); const untrackedFiles = lines("ls-files", "--others", "--exclude-standard"); const files = [...new Set([...(yield* changedFiles), ...(yield* untrackedFiles)])].sort(); if (files.length === 0) { yield* Console.log(`check:changed: no changes since ${base.slice(0, 12)} (${ref}).`); return true; } yield* Console.log(`check:changed: ${files.length} files since ${base.slice(0, 12)} (${ref})`); // Ignored generated sources, declarations, env files, and install state affect check results. // Include them in the key, but skip large ignored folders that no check reads. // Recompute after a passing run so edits made during it are never cached as passing. const ci = Option.getOrElse(yield* Config.option(Config.String("CI")), () => ""); const inputKey = Effect.gen(function* () { const hash = NodeCrypto.createHash("sha256"); // CI changes test behavior (vite.config.ts rejects .only under CI). hash.update(`${process.version}\0${base}\0${ci}\0`); hash.update( yield* git(root, [ "diff", "--binary", "--no-renames", "--no-ext-diff", "--no-textconv", base, "--", ]), ); const ignored = yield* lines( "ls-files", "--others", "--ignored", "--exclude-standard", "--", ":(glob)**/.generated/**", ":(glob)**/.astro/**", ":(glob)**/*.d.ts", ":(glob)**/.env*", ":(exclude,glob)**/node_modules/**", ); for (const file of [ // Raw bytes of changed files too: .gitattributes normalizes line endings in // the diff, but the formatter reads the file as it is on disk. ...(yield* changedFiles), ...(yield* untrackedFiles), ...ignored, "node_modules/.modules.yaml", "node_modules/.pnpm/lock.yaml", ]) { hash.update(`\0${file}\0`); // Untracked nested repositories are listed as directories. const info = yield* Effect.option(fs.stat(inRoot(file))); if (Option.isSome(info) && info.value.type === "File") { hash.update(yield* fs.readFile(inRoot(file))); } } return hash.digest("hex"); }); const key = yield* inputKey; const cachePath = inRoot("node_modules/.cache/check-changed.json"); // A missing or unreadable cache is a miss, never a failure. const cached = yield* fs .readFileString(cachePath) .pipe(Effect.flatMap(decodeCacheEntry), Effect.option); if (Option.isSome(cached) && cached.value.key === key) { yield* Console.log("Nothing changed since the last passing run.\n"); for (const line of cached.value.summary) yield* Console.log(line); return true; } const present = yield* Effect.filter(files, (file) => fs.exists(inRoot(file))); const code = present.filter((file) => CODE.test(file)); const packages = readWorkspace(); const { affected, outputs } = decide(files, packages, false); // Changed test files, and the test files beside a changed source file // (foo.ts -> foo.test.ts, foo.browser.test.tsx). Vitest's import-graph // `related` reaches most of a package: one leaf server file pulled in 252 of // 406 server test files and took 7 minutes. CI runs the rest. const tests = new Set(code.filter((file) => TEST.test(file))); for (const file of code) { const dir = path.dirname(file); const prefix = `${path.basename(file).replace(CODE, "")}.`; for (const entry of yield* fs.readDirectory(inRoot(dir))) { if (entry.startsWith(prefix) && TEST.test(entry)) tests.add(path.join(dir, entry)); } } for (const test of docReaderTests(files)) tests.add(test); // It reads files other than the ones beside it, so no changed file selects it. if (affected.includes("t3")) tests.add("apps/server/src/provider/AgentContextBudget.test.ts"); const { vitestTests, nodeTests } = splitTests(tests); // React Compiler coverage compiles every client source file, so run only the // changed files' cases, in one extra step: a -t filter in the main test step // would drop every other test. An app is skipped when the main step already // runs its coverage file unfiltered. File filters mirror each coverage test. const compilerApps = [ { test: "apps/web/src/reactCompilerCoverage.test.ts", root: "apps/web/src/", // Test names keep the repo-relative path. name: (file: string) => file, compiled: (file: string) => /\.tsx?$/.test(file) && !/\.(test|browser)\.tsx?$/.test(file) && !file.endsWith(".gen.ts"), // Web has only per-file cases. always: [], }, { test: "apps/mobile/src/reactCompilerCoverage.test.ts", root: "apps/mobile/src/", name: (file: string) => file.slice("apps/mobile/".length), compiled: (file: string) => /\.tsx?$/.test(file) && !/\.(test\.tsx?|d\.ts)$/.test(file), // The Metro, cache, and stale-allowlist cases check more than one file, deletions included. always: ["^(?!.*compiles )"], }, ].flatMap(({ test, root: appRoot, name, compiled, always }) => { const changed = files.filter((file) => file.startsWith(appRoot) && compiled(file)); if (changed.length === 0 || tests.has(test)) return []; const names = changed .filter((file) => present.includes(file)) .map((file) => `compiles ${escapeRegExp(name(file))}$`); const pattern = [...names, ...always]; return pattern.length > 0 ? [{ test, names, pattern }] : []; }); // knip:check cannot be scoped to a package. Any code change can leave a file, // export, or dependency unused (removing the last import of a helper does), so // it runs whenever code or a manifest changes. const runKnip = files.some( (file) => CODE.test(file) || path.basename(file) === "package.json" || file === "knip.jsonc", ); // CI runs knip:check as a task that depends on one script per pass. The passes // do not depend on each other, so they run side by side here. const rootPackage = yield* fs .readFileString(inRoot("package.json")) .pipe(Effect.flatMap(decodeRootPackageJson), Effect.orDie); const knipPasses: Array<Array<string>> = []; for (const command of [ rootPackage.scripts["knip:check:files"], rootPackage.scripts["knip:check:exports"], ]) { const [bin, ...args] = command.trim().split(/\s+/); if (bin !== "knip" || /["'$\\|;&<>]/.test(command)) { return yield* Effect.fail(`check:changed cannot split knip:check: ${command}`); } knipPasses.push(["exec", "knip", ...args]); } // A version bump can leave a patch unused, causing pnpm to reject the install // with ERR_PNPM_UNUSED_PATCH. Check it here as Release Smoke does in CI. const runPatchCheck = files.some( (file) => file === "pnpm-workspace.yaml" || file === "pnpm-lock.yaml" || file === ".pnpmfile.cjs" || file.startsWith("patches/") || file.startsWith("apps/mobile/deps/") || path.basename(file) === "package.json", ); // Output is piped, so keep the colors a terminal would get. const env = process.stdout.isTTY ? { FORCE_COLOR: "1" } : {}; const vp = (args: ReadonlyArray<string>, cwd = root) => Effect.scoped( Effect.gen(function* () { const [command, commandArgs] = vitePlusCommand(args, platform); const handle = yield* spawner.spawn( ChildProcess.make(command, commandArgs, { cwd, env, extendEnv: true, forceKillAfter: "5 seconds", }), ); const [output, exitCode] = yield* Effect.all( [Stream.mkString(Stream.decodeText(handle.all)), handle.exitCode], { concurrency: 2 }, ); return { ok: exitCode === 0, output }; }), ).pipe(Effect.catch((error) => Effect.succeed({ ok: false, output: error.message }))); // Resolve without the lockfile in a temp copy to preserve the working tree and lockfile. // Copy mobile modules too: they are file: dependencies, not workspace packages. // Cached registry metadata limits this to patches stranded by local changes, not registry drift. const checkPatches = Effect.scoped( Effect.gen(function* () { const temp = yield* fs.makeTempDirectoryScoped({ prefix: "t3-patch-check-" }); const copy = Effect.fnUntraced(function* (relative: string) { const dest = path.join(temp, relative); yield* fs.makeDirectory(path.dirname(dest), { recursive: true }); yield* fs.copy(inRoot(relative), dest); }); yield* copy("package.json"); yield* copy("pnpm-workspace.yaml"); for (const pkg of packages) yield* copy(`${pkg.dir}/package.json`); const modulesDir = "apps/mobile/modules"; if (yield* fs.exists(inRoot(modulesDir))) { for (const entry of yield* fs.readDirectory(inRoot(modulesDir))) { const manifest = `${modulesDir}/${entry}/package.json`; if (yield* fs.exists(inRoot(manifest))) yield* copy(manifest); } } for (const extra of ["apps/mobile/deps", "patches", ".pnpmfile.cjs"]) { if (yield* fs.exists(inRoot(extra))) yield* copy(extra); } const result = yield* vp(["install", "--lockfile-only", "--ignore-scripts"], temp); if (result.ok || !result.output.includes("ERR_PNPM_UNUSED_PATCH")) return result; return { ok: false, output: `${result.output}\nUnused dependency patches: remove each patch named above from ` + "patchedDependencies in pnpm-workspace.yaml and from patches/, " + "update it to the version the install resolves, " + "or pin the dependency that pulls it in to the patched version.", }; }), ).pipe(Effect.catch((error) => Effect.succeed({ ok: false, output: error.message }))); // CI's Lint job checks that generated GraphQL operations match their sources. const graphql = ["apps/server", "packages/source-control-github"].filter((dir) => files.some((file) => file.startsWith(`${dir}/`)), ); const filters = (names: ReadonlyArray<string>) => names.flatMap((name) => ["--filter", name]); const typecheckWorkers = Math.min(concurrency, affected.length); const command = (name: string, args: ReadonlyArray<string>) => ({ name, run: vp(args) }); const compilerFiles = compilerApps.reduce((count, app) => count + app.names.length, 0); const steps: Array<Step<never>> = [ ...(runPatchCheck ? [{ name: "unused patches", run: checkPatches }] : []), ...(present.length > 0 ? [command("format", ["fmt", "--check", "--no-error-on-unmatched-pattern", ...present])] : []), ...(code.length > 0 ? [command("lint", ["lint", "--no-error-on-unmatched-pattern", ...code])] : []), ...(runKnip ? knipPasses.map((args, index) => command(`knip ${index + 1}/${knipPasses.length}`, args)) : []), ...graphql.map((dir) => command(`graphql (${dir})`, ["run", "--filter", `./${dir}`, "generate", "--check"]), ), ...(affected.length > 0 ? [ { // `effect-tsgo tsrs --noEmit` writes nothing another package reads, so dependency order // only made dependents wait: --parallel cut a contracts change from 13 s to 9 s. ...command(`typecheck (${affected.length} packages)`, [ "run", "--cache", "--parallel", "--concurrency-limit", String(typecheckWorkers), ...filters(affected), "typecheck", ]), weight: typecheckWorkers, }, ] : []), // From the repo root, the root vite.config.ts hands each file to its package's config. ...(vitestTests.length > 0 ? [ { ...command(`test (${vitestTests.length} files)`, [ "test", "run", "--passWithNoTests", ...vitestTests, ]), serial: true, }, ] : []), ...(nodeTests.length > 0 ? [ command(`node --test (${nodeTests.length} files)`, [ "exec", "node", "--test", ...nodeTests, ]), ] : []), ...(compilerApps.length > 0 ? [ { ...command(`react compiler (${compilerFiles} files)`, [ "test", "run", ...compilerApps.map((app) => app.test), "-t", compilerApps.flatMap((app) => app.pattern).join("|"), ]), serial: true, }, ] : []), ]; const results = yield* runSteps(steps, { concurrency, timeoutSeconds }); const summary = ["check:changed summary"]; for (const result of results) { summary.push(` ${result.outcome} ${result.name} ${result.time}`); } if (results.some((result) => result.outcome === "TIMEOUT")) { summary.push( ` TIMEOUT: ran past ${timeoutSeconds}s and was killed; this is not a check failure. ` + "Raise --timeout or lower --concurrency.", ); } const ciOnly = Object.entries({ "full test suites": outputs.test || outputs.test_web || outputs.test_server, build: outputs.build, rust: outputs.rust, "mobile native lint": outputs.mobile_native, "release smoke": outputs.release_smoke, }).flatMap(([job, runs]) => (runs ? [job] : [])); if (ciOnly.length > 0) summary.push(` CI also runs: ${ciOnly.join(", ")}`); if (!runPatchCheck) summary.push(" unused patch check skipped: no dependency files changed"); if (!runKnip) summary.push(" knip skipped: no code or manifest changed"); yield* Console.log(`\n${summary.join("\n")}`); if (results.some((result) => result.outcome !== "pass")) return false; if ((yield* inputKey) !== key) { yield* Console.log(" pass not cached: files changed during the run"); return true; } // Write then rename, so a concurrent run never reads half a file. const temp = `${cachePath}.${process.pid}`; yield* Effect.gen(function* () { yield* fs.makeDirectory(path.dirname(cachePath), { recursive: true }); yield* fs.writeFileString(temp, yield* encodeCacheEntry({ key, summary })); yield* fs.rename(temp, cachePath); }).pipe(Effect.catch((error) => Console.warn(` pass not cached: ${error.message}`))); return true; }); export const checkChangedCommand = Command.make( "check-changed", { ref: Argument.String("ref").pipe( Argument.withDescription("Compare against the merge base with this ref."), Argument.optional, ), concurrency: Flag.Int("concurrency").pipe( Flag.withDescription( "Budget of parallel steps and typecheck workers; also CHECK_CHANGED_CONCURRENCY. Defaults to one per two cores and per 6 GiB of available memory.", ), Flag.optional, ), timeout: Flag.Int("timeout").pipe( Flag.withDescription( "Seconds before a step is killed; also CHECK_CHANGED_TIMEOUT. Defaults to 900.", ), Flag.optional, ), }, (input) => checkChanged(input).pipe( Effect.catch((message) => Console.error(message).pipe(Effect.as(false))), // exitCode, not a failed exit: runMain calls process.exit() on failure, and // piped stdout is asynchronous on macOS, so it would cut off step output. Effect.flatMap((ok) => Effect.sync(() => { if (!ok) process.exitCode = 1; }), ), ), ).pipe(Command.withDescription("Run CI's fast checks for this branch's changes.")); if (import.meta.main) { Command.run(checkChangedCommand, { version: "0.0.0" }).pipe( Effect.provide(NodeServices.layer), NodeRuntime.runMain, ); } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |