|
| 1 | +import { describe, expect, test } from "bun:test"; |
| 2 | + |
| 3 | +import { buildComponents, computeAffected, computeCiJobPlan } from "./preflight"; |
| 4 | + |
| 5 | +const components = buildComponents(); |
| 6 | + |
| 7 | +function getCiJobPlan(changedFiles: string[]) { |
| 8 | + const { ordered, repoWide } = computeAffected(components, changedFiles, false); |
| 9 | + return computeCiJobPlan(ordered, changedFiles, repoWide); |
| 10 | +} |
| 11 | + |
| 12 | +describe("preflight CI detection", () => { |
| 13 | + test("root Bun dependency changes only trigger Bun-backed jobs", () => { |
| 14 | + const plan = getCiJobPlan(["package.json"]); |
| 15 | + |
| 16 | + expect(plan.run_biome_format).toBe(true); |
| 17 | + expect(plan.run_typescript_packages).toBe(true); |
| 18 | + expect(plan.run_extension).toBe(true); |
| 19 | + expect(plan.run_docs).toBe(true); |
| 20 | + expect(plan.run_landing).toBe(true); |
| 21 | + expect(plan.run_demo).toBe(true); |
| 22 | + expect(plan.run_playground).toBe(true); |
| 23 | + expect(plan.run_desktop_macos).toBe(true); |
| 24 | + expect(plan.run_python_sdk).toBe(false); |
| 25 | + expect(plan.run_rust_sdk).toBe(false); |
| 26 | + expect(plan.run_go_sdk).toBe(false); |
| 27 | + }); |
| 28 | + |
| 29 | + test("Rust SDK changes propagate to desktop but not other language jobs", () => { |
| 30 | + const plan = getCiJobPlan(["packages/rust/slop-ai/Cargo.toml"]); |
| 31 | + |
| 32 | + expect(plan.run_biome_format).toBe(false); |
| 33 | + expect(plan.run_typescript_packages).toBe(false); |
| 34 | + expect(plan.run_extension).toBe(false); |
| 35 | + expect(plan.run_docs).toBe(false); |
| 36 | + expect(plan.run_landing).toBe(false); |
| 37 | + expect(plan.run_demo).toBe(false); |
| 38 | + expect(plan.run_playground).toBe(false); |
| 39 | + expect(plan.run_desktop_macos).toBe(true); |
| 40 | + expect(plan.run_python_sdk).toBe(false); |
| 41 | + expect(plan.run_rust_sdk).toBe(true); |
| 42 | + expect(plan.run_go_sdk).toBe(false); |
| 43 | + }); |
| 44 | + |
| 45 | + test("Biome config changes only trigger the formatting job", () => { |
| 46 | + const plan = getCiJobPlan(["biome.json"]); |
| 47 | + |
| 48 | + expect(plan.run_biome_format).toBe(true); |
| 49 | + expect(plan.run_typescript_packages).toBe(false); |
| 50 | + expect(plan.run_extension).toBe(false); |
| 51 | + expect(plan.run_docs).toBe(false); |
| 52 | + expect(plan.run_landing).toBe(false); |
| 53 | + expect(plan.run_demo).toBe(false); |
| 54 | + expect(plan.run_playground).toBe(false); |
| 55 | + expect(plan.run_desktop_macos).toBe(false); |
| 56 | + expect(plan.run_python_sdk).toBe(false); |
| 57 | + expect(plan.run_rust_sdk).toBe(false); |
| 58 | + expect(plan.run_go_sdk).toBe(false); |
| 59 | + }); |
| 60 | + |
| 61 | + test("root TypeScript build script changes trigger only jobs that use it", () => { |
| 62 | + const plan = getCiJobPlan(["scripts/build-typescript-packages.ts"]); |
| 63 | + |
| 64 | + expect(plan.run_biome_format).toBe(true); |
| 65 | + expect(plan.run_typescript_packages).toBe(true); |
| 66 | + expect(plan.run_extension).toBe(false); |
| 67 | + expect(plan.run_docs).toBe(false); |
| 68 | + expect(plan.run_landing).toBe(false); |
| 69 | + expect(plan.run_demo).toBe(true); |
| 70 | + expect(plan.run_playground).toBe(true); |
| 71 | + expect(plan.run_desktop_macos).toBe(false); |
| 72 | + expect(plan.run_python_sdk).toBe(false); |
| 73 | + expect(plan.run_rust_sdk).toBe(false); |
| 74 | + expect(plan.run_go_sdk).toBe(false); |
| 75 | + }); |
| 76 | + |
| 77 | + test("workflow changes force every preflight job to run", () => { |
| 78 | + const plan = getCiJobPlan([".github/workflows/preflight.yml"]); |
| 79 | + |
| 80 | + for (const shouldRun of Object.values(plan)) { |
| 81 | + expect(shouldRun).toBe(true); |
| 82 | + } |
| 83 | + }); |
| 84 | +}); |
0 commit comments