Skip to content
TypeScript

fix(ci): a change to the T3 Connect troubleshooting guide runs the server test that reads it (#28273)

Victor Vogel906156b4e5f7
diff --git a/.github/scripts/ci-changes.cjs b/.github/scripts/ci-changes.cjs
index 77a526076de..0f817be60c3 100644
--- a/.github/scripts/ci-changes.cjs
+++ b/.github/scripts/ci-changes.cjs
@@ -27,6 +27,8 @@ const EXTRA_OWNERS = [
[/^native\/browser-secret\//, ["@t3tools/desktop"]],
[/^native\/kde-snap-shot\//, ["@t3tools/desktop"]],
[/^native\/libghostty-vt\//, ["@t3tools/web"]],
+ // apps/server/src/cloud/ConnectReachability.test.ts checks the guide's headings.
+ [/^docs\/user\/t3-connect-troubleshooting\.md$/, ["t3"]],
];
const RUST = /^native\/(resource-monitor|kde-snap-shot|hyprland-snap-shot)\//;
@@ -92,11 +94,11 @@ function readWorkspace() {
// [] means inert; null means unknown and requires every job.
function ownersOf(file, packages) {
- if (INERT.some((pattern) => pattern.test(file))) return [];
+ const extra = EXTRA_OWNERS.flatMap(([pattern, names]) => (pattern.test(file) ? names : []));
+ if (INERT.some((pattern) => pattern.test(file))) return extra;
// A manifest can change dependencies or versions other packages read.
if (path.posix.basename(file) === "package.json") return null;
if (RUNS_EVERYTHING.some((pattern) => pattern.test(file))) return null;
- const extra = EXTRA_OWNERS.flatMap(([pattern, names]) => (pattern.test(file) ? names : []));
// scripts/build-desktop-artifact.test.ts reads the crates' sources.
if (RUST.test(file)) return ["@t3tools/scripts", ...extra];
diff --git a/scripts/check-changed.test.ts b/scripts/check-changed.test.ts
index b01c3556766..b0e0fe01e85 100644
--- a/scripts/check-changed.test.ts
+++ b/scripts/check-changed.test.ts
@@ -17,10 +17,12 @@ import * as TestClock from "effect/testing/TestClock";
import {
comparisonBase,
defaultConcurrency,
+ docReaderTests,
gitLines,
runSteps,
type Step,
} from "./check-changed.ts";
+import { decide, readWorkspace } from "../.github/scripts/ci-changes.cjs";
const GiB = 1024 ** 3;
@@ -33,6 +35,17 @@ describe("check:changed", () => {
assert.strictEqual(defaultConcurrency(1, 64 * GiB), 1);
});
+ it("runs the server tests for the one guide they read and leaves other docs inert", () => {
+ const packages = readWorkspace();
+ assert.isTrue(
+ decide(["docs/user/t3-connect-troubleshooting.md"], packages, false).outputs.test_server,
+ );
+ assert.deepStrictEqual(docReaderTests(["docs/user/t3-connect-troubleshooting.md"]), [
+ "apps/server/src/cloud/ConnectReachability.test.ts",
+ ]);
+ assert.deepStrictEqual(decide(["docs/user/install.md"], packages, false).affected, []);
+ });
+
it.effect(
"keeps weighted steps within the budget, in order, and serial steps one at a time",
() =>
diff --git a/scripts/check-changed.ts b/scripts/check-changed.ts
index b23289211b9..583b00b5361 100644
--- a/scripts/check-changed.ts
+++ b/scripts/check-changed.ts
@@ -190,6 +190,12 @@ const override = Effect.fn("checkChanged.override")(function* (
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>;
@@ -309,6 +315,7 @@ const checkChanged = Effect.fn("checkChanged")(function* (input: {
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");