Skip to content

Commit 24a5ba7

Browse files
committed
fix: harden docker smoke packaging
1 parent ccfc97c commit 24a5ba7

3 files changed

Lines changed: 40 additions & 2 deletions

File tree

scripts/lib/live-docker-stage.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,21 @@ openclaw_live_stage_state_dir() {
5454
# Sandbox workspaces can accumulate root-owned artifacts from prior Docker
5555
# runs. They are not needed for live-test auth/config staging and can make
5656
# temp-dir cleanup fail on exit, so keep them out of the staged state copy.
57+
set +e
5758
tar -C "$source_dir" \
59+
--warning=no-file-changed \
60+
--ignore-failed-read \
5861
--exclude=workspace \
5962
--exclude=sandboxes \
6063
--exclude=relay.sock \
6164
--exclude='*.sock' \
6265
--exclude='*/*.sock' \
6366
-cf - . | tar -C "$dest_dir" -xf -
67+
local status=$?
68+
set -e
69+
if [ "$status" -gt 1 ]; then
70+
return "$status"
71+
fi
6472
chmod -R u+rwX "$dest_dir" || true
6573
if [ -d "$source_dir/workspace" ] && [ ! -e "$dest_dir/workspace" ]; then
6674
ln -s "$source_dir/workspace" "$dest_dir/workspace"

src/plugin-sdk/qa-lab.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
22

33
const loadBundledPluginPublicSurfaceModuleSync = vi.hoisted(() => vi.fn());
44
const registerQaLabCliImpl = vi.hoisted(() => vi.fn());
5+
const isQaLabCliAvailableImpl = vi.hoisted(() => vi.fn());
56

67
vi.mock("./facade-loader.js", async () => {
78
const actual = await vi.importActual<typeof import("./facade-loader.js")>("./facade-loader.js");
@@ -14,7 +15,9 @@ vi.mock("./facade-loader.js", async () => {
1415
describe("plugin-sdk qa-lab", () => {
1516
beforeEach(() => {
1617
registerQaLabCliImpl.mockReset();
18+
isQaLabCliAvailableImpl.mockReset().mockReturnValue(true);
1719
loadBundledPluginPublicSurfaceModuleSync.mockReset().mockReturnValue({
20+
isQaLabCliAvailable: isQaLabCliAvailableImpl,
1821
registerQaLabCli: registerQaLabCliImpl,
1922
});
2023
});
@@ -36,4 +39,13 @@ describe("plugin-sdk qa-lab", () => {
3639
module.registerQaLabCli({} as never);
3740
expect(registerQaLabCliImpl).toHaveBeenCalledWith({} as never);
3841
});
42+
43+
it("reports qa-lab unavailable when private facade artifacts are not packed", async () => {
44+
loadBundledPluginPublicSurfaceModuleSync.mockImplementation(() => {
45+
throw new Error("Unable to resolve bundled plugin public surface qa-lab/cli.js");
46+
});
47+
const module = await import("./qa-lab.js");
48+
49+
expect(module.isQaLabCliAvailable()).toBe(false);
50+
});
3951
});

src/plugin-sdk/qa-lab.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,26 @@ function loadFacadeModule(): FacadeModule {
99
});
1010
}
1111

12+
function isMissingQaLabFacadeError(err: unknown): boolean {
13+
if (!(err instanceof Error)) {
14+
return false;
15+
}
16+
return (
17+
err.message === "Unable to resolve bundled plugin public surface qa-lab/cli.js" ||
18+
err.message.startsWith("Unable to open bundled plugin public surface ")
19+
);
20+
}
21+
1222
export const registerQaLabCli: FacadeModule["registerQaLabCli"] = ((...args) =>
1323
loadFacadeModule().registerQaLabCli(...args)) as FacadeModule["registerQaLabCli"];
1424

15-
export const isQaLabCliAvailable: FacadeModule["isQaLabCliAvailable"] = (() =>
16-
loadFacadeModule().isQaLabCliAvailable()) as FacadeModule["isQaLabCliAvailable"];
25+
export const isQaLabCliAvailable: FacadeModule["isQaLabCliAvailable"] = (() => {
26+
try {
27+
return loadFacadeModule().isQaLabCliAvailable();
28+
} catch (err) {
29+
if (isMissingQaLabFacadeError(err)) {
30+
return false;
31+
}
32+
throw err;
33+
}
34+
}) as FacadeModule["isQaLabCliAvailable"];

0 commit comments

Comments
 (0)