Skip to content

Commit 019d3fb

Browse files
committed
fix(ci): detect typecheck scripts from package manifest
1 parent f650244 commit 019d3fb

2 files changed

Lines changed: 57 additions & 7 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3451,14 +3451,14 @@ jobs:
34513451
root_covered=true
34523452
fi
34533453
fi
3454-
if pnpm run --silent 2>/dev/null | grep -q '^ tsgo:scripts$'; then
3454+
if has_package_script "tsgo:scripts"; then
34553455
pnpm tsgo:scripts
34563456
elif [[ "$HISTORICAL_TARGET" != "true" ]]; then
34573457
echo "Current CI targets must provide the tsgo:scripts package script." >&2
34583458
exit 1
34593459
fi
34603460
if [ "$root_covered" != "true" ]; then
3461-
if pnpm run --silent 2>/dev/null | grep -q '^ tsgo:test:root$'; then
3461+
if has_package_script "tsgo:test:root"; then
34623462
pnpm tsgo:test:root
34633463
elif [[ "$HISTORICAL_TARGET" != "true" ]]; then
34643464
echo "Current CI targets must provide the tsgo:test:root package script." >&2

‎test/scripts/ci-workflow-guards.test.ts‎

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,11 @@ function runProtocolSinceFixture(checkout: string, baseSha: string) {
13361336
);
13371337
}
13381338

1339-
function runGuardCheckFixture(options: { frozenTarget: boolean; scripts: string[] }): {
1339+
function runCheckShardFixture(options: {
1340+
frozenTarget: boolean;
1341+
scripts: string[];
1342+
task?: "guards" | "test-types";
1343+
}): {
13401344
calls: string[];
13411345
output: string;
13421346
status: number | null;
@@ -1345,6 +1349,10 @@ function runGuardCheckFixture(options: { frozenTarget: boolean; scripts: string[
13451349
const fakeBin = path.join(root, "bin");
13461350
const callsPath = path.join(root, "pnpm-calls.txt");
13471351
mkdirSync(fakeBin);
1352+
if (options.task === "test-types") {
1353+
mkdirSync(path.join(root, "scripts"));
1354+
writeFileSync(path.join(root, "scripts/run-tsgo-core-test-shards.mts"), "// --stripe\n");
1355+
}
13481356
writeFileSync(
13491357
path.join(root, "package.json"),
13501358
`${JSON.stringify({
@@ -1354,6 +1362,7 @@ function runGuardCheckFixture(options: { frozenTarget: boolean; scripts: string[
13541362
writeExecutable(path.join(fakeBin, "pnpm"), [
13551363
"#!/usr/bin/env bash",
13561364
"set -euo pipefail",
1365+
'if [ "$*" = "run --silent" ]; then exit 1; fi',
13571366
'printf "%s\\n" "$*" >> "$PNPM_CALLS"',
13581367
]);
13591368
const checkShardRun = readCiWorkflow().jobs["check-shard"].steps.find(
@@ -1367,10 +1376,11 @@ function runGuardCheckFixture(options: { frozenTarget: boolean; scripts: string[
13671376
FROZEN_TARGET: options.frozenTarget ? "true" : "false",
13681377
FORMAT_CHECK: "false",
13691378
HISTORICAL_TARGET: options.frozenTarget ? "true" : "false",
1379+
HOSTED_RUNNER_STRIPES: "true",
13701380
PATH: `${fakeBin}:${process.env.PATH ?? ""}`,
13711381
PNPM_CALLS: callsPath,
13721382
PR_BASE_SHA: "",
1373-
TASK: "guards",
1383+
TASK: options.task ?? "guards",
13741384
},
13751385
});
13761386
return {
@@ -7965,7 +7975,7 @@ printf '%s\n' "\${CURL_SUCCESS_IP:-203.0.113.7}"
79657975

79667976
it("runs temp path guardrails in the hosted guard shard", () => {
79677977
const requiredScripts = ["check:doctor-deprecation-registry", "check:coercion-helpers"];
7968-
const current = runGuardCheckFixture({
7978+
const current = runCheckShardFixture({
79697979
frozenTarget: false,
79707980
scripts: [...requiredScripts, "check:temp-path-guardrails"],
79717981
});
@@ -7975,7 +7985,7 @@ printf '%s\n' "\${CURL_SUCCESS_IP:-203.0.113.7}"
79757985
current.calls.indexOf("dup:check"),
79767986
);
79777987

7978-
const frozenMissing = runGuardCheckFixture({
7988+
const frozenMissing = runCheckShardFixture({
79797989
frozenTarget: true,
79807990
scripts: requiredScripts,
79817991
});
@@ -7986,7 +7996,7 @@ printf '%s\n' "\${CURL_SUCCESS_IP:-203.0.113.7}"
79867996
"[skip] frozen target predates the temp path guardrails",
79877997
);
79887998

7989-
const currentMissing = runGuardCheckFixture({
7999+
const currentMissing = runCheckShardFixture({
79908000
frozenTarget: false,
79918001
scripts: requiredScripts,
79928002
});
@@ -8007,6 +8017,46 @@ printf '%s\n' "\${CURL_SUCCESS_IP:-203.0.113.7}"
80078017
);
80088018
});
80098019

8020+
it.each([
8021+
{
8022+
scripts: ["tsgo:scripts", "tsgo:test:root"],
8023+
frozenTarget: false,
8024+
status: 0,
8025+
calls: ["tsgo:extensions:test", "tsgo:scripts", "tsgo:test:root"],
8026+
},
8027+
{
8028+
scripts: ["tsgo:scripts"],
8029+
frozenTarget: false,
8030+
status: 1,
8031+
calls: ["tsgo:extensions:test", "tsgo:scripts"],
8032+
},
8033+
{
8034+
scripts: [],
8035+
frozenTarget: false,
8036+
status: 1,
8037+
calls: ["tsgo:extensions:test"],
8038+
},
8039+
{
8040+
scripts: [],
8041+
frozenTarget: true,
8042+
status: 0,
8043+
calls: ["tsgo:extensions:test"],
8044+
},
8045+
{
8046+
scripts: ["tsgo:test:root"],
8047+
frozenTarget: true,
8048+
status: 0,
8049+
calls: ["tsgo:extensions:test", "tsgo:test:root"],
8050+
},
8051+
])(
8052+
"runs declared typechecks for scripts=$scripts frozen=$frozenTarget",
8053+
({ scripts, frozenTarget, status, calls }) => {
8054+
const result = runCheckShardFixture({ scripts, frozenTarget, task: "test-types" });
8055+
expect(result.status, result.output).toBe(status);
8056+
expect(result.calls).toEqual(calls);
8057+
},
8058+
);
8059+
80108060
it("rejects ambiguous zero-before main pushes and preserves concrete bases", () => {
80118061
const zeroSha = "0".repeat(40);
80128062
const threeCommit = runPushDiffBaseFixture({ commitCount: 3, eventBaseSha: zeroSha });

0 commit comments

Comments
 (0)