Skip to content

Commit 6540028

Browse files
steipeteampagent
andauthored
fix(ci): snapshot synced Testbox candidates (#124743)
Co-authored-by: Amp <[email protected]>
1 parent 6c9eda0 commit 6540028

2 files changed

Lines changed: 16 additions & 15 deletions

File tree

‎scripts/crabbox-wrapper.mts‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3741,21 +3741,21 @@ function injectFullCheckoutLeaseReclaim(commandArgs: string[]) {
37413741
return normalizedArgs;
37423742
}
37433743

3744-
function injectRemoteTestboxCi(commandArgs: string[], providerName: string) {
3744+
function injectRemoteTestboxBootstrap(commandArgs: string[], providerName: string) {
37453745
if (commandArgs[0] !== "run" || canonicalProviderName(providerName) !== "blacksmith-testbox") {
37463746
return commandArgs;
37473747
}
3748-
const normalizedArgs = [...commandArgs];
3749-
const { start } = parseRunInvocation(help.text, normalizedArgs);
3750-
if (start < 0) {
3751-
return normalizedArgs;
3752-
}
3753-
if (hasOption(normalizedArgs, "--shell")) {
3754-
normalizedArgs[start] = `export CI=true; ${normalizedArgs[start]}`;
3755-
} else {
3756-
normalizedArgs.splice(start, 0, "env", "CI=true");
3748+
const invocation = parseRunInvocation(help.text, commandArgs);
3749+
if (invocation.start < 0) {
3750+
return commandArgs;
37573751
}
3758-
return normalizedArgs;
3752+
const snapshot = hasOption(commandArgs, "--no-sync")
3753+
? ""
3754+
: `if [ -n "$(git status --porcelain=v1)" ]; then git add -A && git -c user.name=OpenClaw -c [email protected] -c commit.gpgsign=false commit --no-verify -qm remote-testbox-sync || exit $?; fi; `;
3755+
return replaceRunCommandWithShell(
3756+
invocation,
3757+
`${snapshot}export CI=true; ${renderRunShellCommand(invocation)}`,
3758+
);
37593759
}
37603760

37613761
function applyRunTransforms(
@@ -3807,7 +3807,7 @@ function applyRunTransforms(
38073807
invocation = parseRunInvocation(help.text, transformedArgs);
38083808
transformedArgs = injectRemotePosixHydratedNodeModulesBootstrap(invocation);
38093809
return {
3810-
args: injectRemoteTestboxCi(transformedArgs, options.provider),
3810+
args: injectRemoteTestboxBootstrap(transformedArgs, options.provider),
38113811
wsl2ScriptBootstrap,
38123812
};
38133813
}

‎test/scripts/crabbox-wrapper.test.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ const defaultGitResponses: Record<string, { status?: number; stdout?: string; st
6666
[GIT_CONFIG_SPARSE_KEY]: { stdout: "false\n" },
6767
[GIT_SPARSE_LIST_KEY]: { status: 1 },
6868
};
69+
const remoteTestboxBootstrap = `if [ -n "$(git status --porcelain=v1)" ]; then git add -A && git -c user.name=OpenClaw -c [email protected] -c commit.gpgsign=false commit --no-verify -qm remote-testbox-sync || exit $?; fi; export CI=true;`;
6970

7071
function makeFakeCrabbox(helpText: string): string {
7172
const cached = fakeCrabboxBinDirs.get(helpText);
@@ -1680,7 +1681,7 @@ describe("scripts/crabbox-wrapper", () => {
16801681
"tbx_owned",
16811682
"--shell",
16821683
"--",
1683-
`export CI=true; ${remotePosixHydratedModulesBootstrap} 'echo ok'`,
1684+
`${remoteTestboxBootstrap} ${remotePosixHydratedModulesBootstrap} 'echo ok'`,
16841685
]);
16851686
});
16861687

@@ -1897,7 +1898,7 @@ describe("scripts/crabbox-wrapper", () => {
18971898
"blue-hermit",
18981899
"--shell",
18991900
"--",
1900-
`export CI=true; ${remotePosixHydratedModulesBootstrap} 'echo ok'`,
1901+
`${remoteTestboxBootstrap} ${remotePosixHydratedModulesBootstrap} 'echo ok'`,
19011902
]);
19021903
});
19031904

@@ -1917,7 +1918,7 @@ describe("scripts/crabbox-wrapper", () => {
19171918
"blacksmith-testbox",
19181919
"--shell",
19191920
"--",
1920-
`export CI=true; ${remotePosixHydratedModulesBootstrap} cd packages && pnpm install && pnpm build`,
1921+
`${remoteTestboxBootstrap} ${remotePosixHydratedModulesBootstrap} cd packages && pnpm install && pnpm build`,
19211922
]);
19221923
});
19231924

0 commit comments

Comments
 (0)