Skip to content

Commit

Permalink
Changes [build image]
Browse files Browse the repository at this point in the history
  • Loading branch information
Electroid committed Nov 13, 2024
1 parent 727d8b7 commit 1680ffc
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 46 deletions.
131 changes: 86 additions & 45 deletions .buildkite/ci.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { writeFileSync } from "node:fs";
import { join } from "node:path";
import {
getBuildNumber,
getCanaryRevision,
getChangedFiles,
getCommit,
Expand Down Expand Up @@ -153,6 +154,47 @@ function getPipeline(options) {
return 0;
};

const getAgentV2 = platform => {
const { os, arch, abi, distro, release } = platform;
return {
robobun: true,
robobun2: true,
os,
arch,
abi,
distro,
release,
"image-name": `${os}-${arch}-${distro}-${release}-build-${getBuildNumber()}`,
};
};

const getBuildAgent = platform => {
const { os, arch, abi } = platform;
if (buildImages && abi === "musl") {
return getAgentV2(platform);
}
return {
queue: abi ? `build-${os}-${abi}` : `build-${os}`,
os,
arch,
abi,
};
};

const getTestAgent = platform => {
const { os, arch, abi, distro, release } = platform;
if (buildImages && abi === "musl") {
return getAgentV2(platform);
}
if (os === "darwin") {
return { os, arch, abi, queue: `test-darwin` };
} else if (os === "windows") {
return { os, arch, abi, robobun: true };
} else {
return { os, arch, abi, distro, release, robobun: true };
}
};

/**
* Steps
*/
Expand All @@ -176,17 +218,18 @@ function getPipeline(options) {
const getBuildVendorStep = platform => {
const { os, arch, abi, baseline } = platform;

let depends;
if (buildImages) {
depends = [`${getKey(platform)}-build-image`];
}

return {
key: `${getKey(platform)}-build-vendor`,
label: `${getLabel(platform)} - build-vendor`,
agents: {
os,
arch,
abi,
queue: abi ? `build-${os}-${abi}` : `build-${os}`,
},
agents: getBuildAgent(platform),
retry: getRetry(),
cancel_on_build_failing: isMergeQueue(),
depends_on: depends,
env: {
ENABLE_BASELINE: baseline ? "ON" : "OFF",
},
Expand All @@ -197,17 +240,18 @@ function getPipeline(options) {
const getBuildCppStep = platform => {
const { os, arch, abi, baseline } = platform;

let depends;
if (buildImages) {
depends = [`${getKey(platform)}-build-image`];
}

return {
key: `${getKey(platform)}-build-cpp`,
label: `${getLabel(platform)} - build-cpp`,
agents: {
os,
arch,
abi,
queue: abi ? `build-${os}-${abi}` : `build-${os}`,
},
agents: getBuildAgent(platform),
retry: getRetry(),
cancel_on_build_failing: isMergeQueue(),
depends_on: depends,
env: {
BUN_CPP_ONLY: "ON",
ENABLE_BASELINE: baseline ? "ON" : "OFF",
Expand All @@ -220,14 +264,27 @@ function getPipeline(options) {
const { os, arch, abi, baseline } = platform;
const toolchain = getKey(platform);

let depends;
if (buildImages) {
depends = [`${getKey(platform)}-build-image`];
}

let agents;
if (buildImages) {
agents = getBuildAgent(platform);
} else {
agents = {
queue: "build-zig",
};
}

return {
key: `${getKey(platform)}-build-zig`,
label: `${getLabel(platform)} - build-zig`,
agents: {
queue: "build-zig",
},
agents,
retry: getRetry(),
cancel_on_build_failing: isMergeQueue(),
depends_on: depends,
env: {
ENABLE_BASELINE: baseline ? "ON" : "OFF",
},
Expand All @@ -246,12 +303,7 @@ function getPipeline(options) {
`${getKey(platform)}-build-cpp`,
`${getKey(platform)}-build-zig`,
],
agents: {
os,
arch,
abi,
queue: `build-${os}`,
},
agents: getBuildAgent(platform),
retry: getRetry(),
cancel_on_build_failing: isMergeQueue(),
env: {
Expand All @@ -272,15 +324,6 @@ function getPipeline(options) {
name = getLabel({ ...platform, os: distro, release });
}

let agents;
if (os === "darwin") {
agents = { os, arch, abi, queue: `test-darwin` };
} else if (os === "windows") {
agents = { os, arch, abi, robobun: true };
} else {
agents = { os, arch, abi, distro, release, robobun: true };
}

let command;
if (os === "windows") {
command = `node .\\scripts\\runner.node.mjs --step ${getKey(platform)}-build-bun`;
Expand Down Expand Up @@ -316,7 +359,7 @@ function getPipeline(options) {
key: `${getKey(platform)}-${distro}-${release.replace(/\./g, "")}-test-bun`,
label: `${name} - test-bun`,
depends_on: depends,
agents,
agents: getTestAgent(platform),
retry,
cancel_on_build_failing: isMergeQueue(),
soft_fail: isMainBranch(),
Expand Down Expand Up @@ -365,20 +408,18 @@ function getPipeline(options) {
steps.push(...images.map(platform => getBuildImageStep(platform)));
}

// if (buildImages) {
// steps.push(...builds.map(platform => getBuildImageStep(platform)));
// } else {
// steps.push(...platforms.map(platform => getTestBunStep(platform)));
// }

// if (!buildId && !buildImages) {
// steps.unshift(
// getBuildVendorStep(platform),
// getBuildCppStep(platform),
// getBuildZigStep(platform),
// getBuildBunStep(platform),
// );
// }
if (!buildId) {
for (const platform of builds) {
steps.push(getBuildVendorStep(platform));
steps.push(getBuildCppStep(platform));
steps.push(getBuildZigStep(platform));
steps.push(getBuildBunStep(platform));
}
}

for (const platform of tests) {
steps.push(getTestBunStep(platform));
}

return {
key: getKey(target),
Expand Down
6 changes: 5 additions & 1 deletion scripts/machine.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,11 @@ async function main() {
throw new Error(`Unsupported cloud: ${inspect(options)}`);
}

let metadata;
let metadata = {
"robobun": true,
"robobun2": true,
};

if (buildkiteToken) {
metadata = {
"buildkite:token": buildkiteToken,
Expand Down

0 comments on commit 1680ffc

Please sign in to comment.