mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 15:30:47 +00:00
fix(ci): slim build-artifacts dist producer
This commit is contained in:
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -421,7 +421,7 @@ jobs:
|
||||
use-sticky-disk: "false"
|
||||
|
||||
- name: Build dist
|
||||
run: pnpm build
|
||||
run: pnpm build:ci-artifacts
|
||||
|
||||
- name: Build Control UI
|
||||
run: pnpm ui:build
|
||||
|
||||
@@ -1124,6 +1124,7 @@
|
||||
"android:test:third-party": "cd apps/android && ./gradlew :app:testThirdPartyDebugUnitTest",
|
||||
"audit:seams": "node scripts/audit-seams.mjs",
|
||||
"build": "node scripts/build-all.mjs",
|
||||
"build:ci-artifacts": "node scripts/build-all.mjs ciArtifacts",
|
||||
"build:docker": "node scripts/tsdown-build.mjs && node scripts/runtime-postbuild.mjs && node scripts/build-stamp.mjs && node --import tsx scripts/canvas-a2ui-copy.ts && node --import tsx scripts/copy-hook-metadata.ts && node --import tsx scripts/copy-export-html-templates.ts && node --import tsx scripts/write-build-info.ts && node --experimental-strip-types scripts/write-cli-startup-metadata.ts && node --import tsx scripts/write-cli-compat.ts",
|
||||
"build:plugin-sdk:dts": "tsc -p tsconfig.plugin-sdk.dts.json",
|
||||
"build:strict-smoke": "pnpm canvas:a2ui:bundle && node scripts/tsdown-build.mjs && node scripts/runtime-postbuild.mjs && node scripts/build-stamp.mjs && pnpm build:plugin-sdk:dts && node --import tsx scripts/write-plugin-sdk-entry-dts.ts && node scripts/check-plugin-sdk-exports.mjs",
|
||||
|
||||
@@ -59,6 +59,35 @@ export const BUILD_ALL_STEPS = [
|
||||
},
|
||||
];
|
||||
|
||||
export const BUILD_ALL_PROFILES = {
|
||||
full: BUILD_ALL_STEPS.map((step) => step.label),
|
||||
ciArtifacts: [
|
||||
"canvas:a2ui:bundle",
|
||||
"tsdown",
|
||||
"runtime-postbuild",
|
||||
"build-stamp",
|
||||
"canvas-a2ui-copy",
|
||||
"copy-hook-metadata",
|
||||
"copy-export-html-templates",
|
||||
"write-build-info",
|
||||
"write-cli-startup-metadata",
|
||||
"write-cli-compat",
|
||||
],
|
||||
};
|
||||
|
||||
export function resolveBuildAllSteps(profile = "full") {
|
||||
const labels = BUILD_ALL_PROFILES[profile];
|
||||
if (!labels) {
|
||||
throw new Error(`Unknown build profile: ${profile}`);
|
||||
}
|
||||
const selected = labels.map((label) => BUILD_ALL_STEPS.find((step) => step.label === label));
|
||||
if (selected.some((step) => !step)) {
|
||||
const missing = labels.filter((label) => !BUILD_ALL_STEPS.some((step) => step.label === label));
|
||||
throw new Error(`Build profile ${profile} references unknown steps: ${missing.join(", ")}`);
|
||||
}
|
||||
return selected;
|
||||
}
|
||||
|
||||
function resolveStepEnv(step, env, platform) {
|
||||
if (platform !== "win32" || !step.windowsNodeOptions) {
|
||||
return env;
|
||||
@@ -116,7 +145,8 @@ function isMainModule() {
|
||||
}
|
||||
|
||||
if (isMainModule()) {
|
||||
for (const step of BUILD_ALL_STEPS) {
|
||||
const profile = process.argv[2] ?? "full";
|
||||
for (const step of resolveBuildAllSteps(profile)) {
|
||||
console.error(`[build-all] ${step.label}`);
|
||||
const invocation = resolveBuildAllStep(step);
|
||||
const result = spawnSync(invocation.command, invocation.args, invocation.options);
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { BUILD_ALL_STEPS, resolveBuildAllStep } from "../../scripts/build-all.mjs";
|
||||
import {
|
||||
BUILD_ALL_PROFILES,
|
||||
BUILD_ALL_STEPS,
|
||||
resolveBuildAllStep,
|
||||
resolveBuildAllSteps,
|
||||
} from "../../scripts/build-all.mjs";
|
||||
|
||||
describe("resolveBuildAllStep", () => {
|
||||
it("routes pnpm steps through the npm_execpath pnpm runner on Windows", () => {
|
||||
@@ -70,3 +75,29 @@ describe("resolveBuildAllStep", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveBuildAllSteps", () => {
|
||||
it("keeps the full profile aligned with the declared steps", () => {
|
||||
expect(resolveBuildAllSteps("full")).toEqual(BUILD_ALL_STEPS);
|
||||
expect(BUILD_ALL_PROFILES.full).toEqual(BUILD_ALL_STEPS.map((step) => step.label));
|
||||
});
|
||||
|
||||
it("uses a runtime-only profile for ci artifacts", () => {
|
||||
expect(resolveBuildAllSteps("ciArtifacts").map((step) => step.label)).toEqual([
|
||||
"canvas:a2ui:bundle",
|
||||
"tsdown",
|
||||
"runtime-postbuild",
|
||||
"build-stamp",
|
||||
"canvas-a2ui-copy",
|
||||
"copy-hook-metadata",
|
||||
"copy-export-html-templates",
|
||||
"write-build-info",
|
||||
"write-cli-startup-metadata",
|
||||
"write-cli-compat",
|
||||
]);
|
||||
});
|
||||
|
||||
it("rejects unknown build profiles", () => {
|
||||
expect(() => resolveBuildAllSteps("wat")).toThrow("Unknown build profile: wat");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user