diff --git a/.buildkite/ci.mjs b/.buildkite/ci.mjs new file mode 100644 index 0000000000..dceb21a960 --- /dev/null +++ b/.buildkite/ci.mjs @@ -0,0 +1,384 @@ +#!/usr/bin/env node + +/** + * Build and test Bun on macOS, Linux, and Windows. + * @link https://buildkite.com/docs/pipelines/defining-steps + */ + +import { writeFileSync } from "node:fs"; +import { join } from "node:path"; + +function getEnv(name, required = true) { + const value = process.env[name]; + + if (!value && required) { + throw new Error(`Missing environment variable: ${name}`); + } + + return value; +} + +function isPullRequest() { + return ( + getEnv("BUILDKITE_PULL_REQUEST", false) === "true" && + getEnv("BUILDKITE_REPO") !== getEnv("BUILDKITE_PULL_REQUEST_REPO", false) + ); +} + +function getCommit() { + return getEnv("BUILDKITE_COMMIT"); +} + +function getRepository() { + const url = getEnv("BUILDKITE_PULL_REQUEST_REPO", false) || getEnv("BUILDKITE_REPO"); + const match = url.match(/github.com\/([^/]+)\/([^/]+)\.git$/); + if (!match) { + throw new Error(`Unsupported repository: ${url}`); + } + const [, owner, repo] = match; + return `${owner}/${repo}`; +} + +function getBranch() { + return getEnv("BUILDKITE_BRANCH"); +} + +function isMainBranch() { + const mainBranch = getEnv("BUILDKITE_PIPELINE_DEFAULT_BRANCH", false) || "main"; + return getBranch() === mainBranch && !isPullRequest(); +} + +function isMergeQueue() { + return /^gh-readonly-queue/.test(getEnv("BUILDKITE_BRANCH")); +} + +async function getChangedFiles() { + const repository = getRepository(); + const commit = getCommit(); + + try { + const response = await fetch(`https://api.github.com/repos/${repository}/compare/main...${commit}`); + if (response.ok) { + const { files } = await response.json(); + return files.filter(({ status }) => !/removed|unchanged/i.test(status)).map(({ filename }) => filename); + } + } catch (error) { + console.error(error); + } +} + +function isDocumentation(filename) { + return /^(\.vscode|\.github|bench|docs|examples)|\.(md)$/.test(filename); +} + +function isTest(filename) { + return /^test/.test(filename); +} + +function toYaml(obj, indent = 0) { + const spaces = " ".repeat(indent); + let result = ""; + + for (const [key, value] of Object.entries(obj)) { + if (value === null) { + result += `${spaces}${key}: null\n`; + continue; + } + + if (Array.isArray(value)) { + result += `${spaces}${key}:\n`; + value.forEach(item => { + if (typeof item === "object" && item !== null) { + result += `${spaces}- \n${toYaml(item, indent + 2) + .split("\n") + .map(line => `${spaces} ${line}`) + .join("\n")}\n`; + } else { + result += `${spaces}- ${item}\n`; + } + }); + continue; + } + + if (typeof value === "object") { + result += `${spaces}${key}:\n${toYaml(value, indent + 2)}`; + continue; + } + + if ( + typeof value === "string" && + (value.includes(":") || value.includes("#") || value.includes("'") || value.includes('"') || value.includes("\n")) + ) { + result += `${spaces}${key}: "${value.replace(/"/g, '\\"')}"\n`; + continue; + } + + result += `${spaces}${key}: ${value}\n`; + } + + return result; +} + +function getPipeline() { + /** + * Helpers + */ + + const getKey = platform => { + const { os, arch, baseline } = platform; + + if (baseline) { + return `${os}-${arch}-baseline`; + } + + return `${os}-${arch}`; + }; + + const getLabel = platform => { + const { os, arch, baseline } = platform; + + if (baseline) { + return `:${os}: ${arch}-baseline`; + } + + return `:${os}: ${arch}`; + }; + + // https://buildkite.com/docs/pipelines/command-step#retry-attributes + const getRetry = (limit = 3) => { + return { + automatic: [ + { exit_status: 1, limit: 1 }, + { exit_status: -1, limit }, + { exit_status: 255, limit }, + { signal_reason: "agent_stop", limit }, + ], + }; + }; + + /** + * Steps + */ + + const getBuildVendorStep = platform => { + const { os, arch, baseline } = platform; + + return { + key: `${getKey(platform)}-build-vendor`, + label: `${getLabel(platform)} - build-vendor`, + agents: { + os, + arch, + queue: `build-${os}`, + }, + retry: getRetry(), + cancel_on_build_failing: isMergeQueue(), + env: { + ENABLE_BASELINE: baseline ? "ON" : "OFF", + }, + command: "bun run build:ci --target dependencies", + }; + }; + + const getBuildCppStep = platform => { + const { os, arch, baseline } = platform; + + return { + key: `${getKey(platform)}-build-cpp`, + label: `${getLabel(platform)} - build-cpp`, + agents: { + os, + arch, + queue: `build-${os}`, + }, + retry: getRetry(), + cancel_on_build_failing: isMergeQueue(), + env: { + BUN_CPP_ONLY: "ON", + ENABLE_BASELINE: baseline ? "ON" : "OFF", + }, + command: "bun run build:ci --target bun", + }; + }; + + const getBuildZigStep = platform => { + const { os, arch, baseline } = platform; + const toolchain = baseline ? `${os}-${arch}-baseline` : `${os}-${arch}`; + + return { + key: `${getKey(platform)}-build-zig`, + label: `${getLabel(platform)} - build-zig`, + agents: { + queue: "build-zig", + }, + retry: getRetry(), + cancel_on_build_failing: isMergeQueue(), + env: { + ENABLE_BASELINE: baseline ? "ON" : "OFF", + }, + command: `bun run build:ci --target bun-zig --toolchain ${toolchain}`, + }; + }; + + const getBuildBunStep = platform => { + const { os, arch, baseline } = platform; + + return { + key: `${getKey(platform)}-build-bun`, + label: `${getLabel(platform)} - build-bun`, + depends_on: [ + `${getKey(platform)}-build-vendor`, + `${getKey(platform)}-build-cpp`, + `${getKey(platform)}-build-zig`, + ], + agents: { + os, + arch, + queue: `build-${os}`, + }, + retry: getRetry(), + cancel_on_build_failing: isMergeQueue(), + env: { + BUN_LINK_ONLY: "ON", + ENABLE_BASELINE: baseline ? "ON" : "OFF", + }, + command: "bun run build:ci --target bun", + }; + }; + + const getTestBunStep = platform => { + const { os, arch, distro, release } = platform; + + let name; + if (os === "darwin" || os === "windows") { + name = getLabel(platform); + } else { + name = getLabel({ ...platform, os: distro }); + } + + let agents; + if (os === "darwin") { + agents = { os, arch, queue: `test-darwin` }; + } else if (os === "windows") { + agents = { os, arch, robobun: true }; + } else { + agents = { os, arch, distro, release, robobun: true }; + } + + let command; + if (os === "windows") { + command = `node .\\scripts\\runner.node.mjs --step ${getKey(platform)}-build-bun`; + } else { + command = `./scripts/runner.node.mjs --step ${getKey(platform)}-build-bun`; + } + + let parallelism; + if (os === "darwin") { + parallelism = 2; + } else { + parallelism = 10; + } + + return { + key: `${getKey(platform)}-${distro}-${release.replace(/\./g, "")}-test-bun`, + label: `${name} - test-bun`, + depends_on: [`${getKey(platform)}-build-bun`], + agents, + retry: getRetry(), + cancel_on_build_failing: isMergeQueue(), + parallelism, + command, + }; + }; + + /** + * Config + */ + + const buildPlatforms = [ + { os: "darwin", arch: "aarch64" }, + { os: "darwin", arch: "x64" }, + { os: "linux", arch: "aarch64" }, + { os: "linux", arch: "x64" }, + { os: "linux", arch: "x64", baseline: true }, + { os: "windows", arch: "x64" }, + { os: "windows", arch: "x64", baseline: true }, + ]; + + const testPlatforms = [ + { os: "darwin", arch: "aarch64", distro: "sonoma", release: "14" }, + { os: "darwin", arch: "aarch64", distro: "ventura", release: "13" }, + { os: "darwin", arch: "x64", distro: "sonoma", release: "14" }, + { os: "darwin", arch: "x64", distro: "ventura", release: "13" }, + { os: "linux", arch: "aarch64", distro: "debian", release: "12" }, + { os: "linux", arch: "aarch64", distro: "ubuntu", release: "22.04" }, + { os: "linux", arch: "aarch64", distro: "ubuntu", release: "20.04" }, + { os: "linux", arch: "x64", distro: "debian", release: "12" }, + { os: "linux", arch: "x64", distro: "ubuntu", release: "22.04" }, + { os: "linux", arch: "x64", distro: "ubuntu", release: "20.04" }, + { os: "linux", arch: "x64", distro: "debian", release: "12", baseline: true }, + { os: "linux", arch: "x64", distro: "ubuntu", release: "22.04", baseline: true }, + { os: "linux", arch: "x64", distro: "ubuntu", release: "20.04", baseline: true }, + { os: "windows", arch: "x64", distro: "server", release: "2019" }, + { os: "windows", arch: "x64", distro: "server", release: "2019", baseline: true }, + ]; + + return { + steps: [ + ...buildPlatforms.map(platform => { + const { os, arch, baseline } = platform; + + return { + key: getKey(platform), + group: getLabel(platform), + steps: [ + getBuildVendorStep(platform), + getBuildCppStep(platform), + getBuildZigStep(platform), + getBuildBunStep(platform), + ...testPlatforms + .filter(platform => platform.os === os && platform.arch === arch && baseline === platform.baseline) + .map(platform => getTestBunStep(platform)), + ], + }; + }), + ], + }; +} + +async function main() { + console.log("Checking environment..."); + console.log(" - Repository:", getRepository()); + console.log(" - Branch:", getBranch()); + console.log(" - Commit:", getCommit()); + console.log(" - Is Main Branch:", isMainBranch()); + console.log(" - Is Merge Queue:", isMergeQueue()); + console.log(" - Is Pull Request:", isPullRequest()); + + const changedFiles = await getChangedFiles(); + if (changedFiles) { + console.log( + `Found ${changedFiles.length} changed files: \n${changedFiles.map(filename => ` - ${filename}`).join("\n")}`, + ); + + if (changedFiles.every(filename => isDocumentation(filename))) { + console.log("Since changed files are only documentation, skipping..."); + return; + } + + if (changedFiles.every(filename => isTest(filename) || isDocumentation(filename))) { + // TODO: console.log("Since changed files contain tests, skipping build..."); + } + } + + const pipeline = getPipeline(); + const content = toYaml(pipeline); + const contentPath = join(process.cwd(), ".buildkite", "ci.yml"); + writeFileSync(contentPath, content); + + console.log("Generated pipeline:"); + console.log(" - Path:", contentPath); + console.log(" - Size:", (content.length / 1024).toFixed(), "KB"); +} + +await main(); diff --git a/.buildkite/ci.yml b/.buildkite/ci.yml deleted file mode 100644 index 155e4f857b..0000000000 --- a/.buildkite/ci.yml +++ /dev/null @@ -1,790 +0,0 @@ -# Build and test Bun on macOS, Linux, and Windows. -# https://buildkite.com/docs/pipelines/defining-steps -# -# If a step has the `robobun: true` label, robobun will listen -# to webhooks from Buildkite and provision a VM to run the step. -# -# Changes to this file will be automatically uploaded on the next run -# for a particular commit. - -steps: - # macOS aarch64 - - key: "darwin-aarch64" - group: ":darwin: aarch64" - steps: - - key: "darwin-aarch64-build-deps" - label: "build-deps" - agents: - queue: "build-darwin" - os: "darwin" - arch: "aarch64" - command: - - "bun run build:ci --target dependencies" - - - key: "darwin-aarch64-build-cpp" - label: "build-cpp" - agents: - queue: "build-darwin" - os: "darwin" - arch: "aarch64" - env: - BUN_CPP_ONLY: "ON" - command: - - "bun run build:ci --target bun" - - - key: "darwin-aarch64-build-zig" - label: "build-zig" - agents: - queue: "build-zig" - command: - - "bun run build:ci --target bun-zig --toolchain darwin-aarch64" - - - key: "darwin-aarch64-build-bun" - label: "build-bun" - agents: - queue: "build-darwin" - os: "darwin" - arch: "aarch64" - depends_on: - - "darwin-aarch64-build-deps" - - "darwin-aarch64-build-cpp" - - "darwin-aarch64-build-zig" - env: - BUN_LINK_ONLY: "ON" - command: - - "bun run build:ci --target bun" - - - key: "darwin-aarch64-test-macos-14" - label: ":darwin: 14 aarch64 - test-bun" - if: "build.branch != 'main'" - parallelism: 3 - soft_fail: - - exit_status: 2 - retry: - automatic: - - exit_status: 1 - limit: 1 - - exit_status: -1 - limit: 3 - - exit_status: 255 - limit: 3 - - signal_reason: agent_stop - limit: 3 - - signal: SIGTERM - limit: 3 - depends_on: - - "darwin-aarch64-build-bun" - agents: - queue: "test-darwin" - os: "darwin" - arch: "aarch64" - release: "14" - command: - - "./scripts/runner.node.mjs --step darwin-aarch64-build-bun" - - - key: "darwin-aarch64-test-macos-13" - label: ":darwin: 13 aarch64 - test-bun" - if: "build.branch != 'main'" - parallelism: 3 - soft_fail: - - exit_status: 2 - retry: - automatic: - - exit_status: 1 - limit: 1 - - exit_status: -1 - limit: 3 - - exit_status: 255 - limit: 3 - - signal_reason: agent_stop - limit: 3 - - signal: SIGTERM - limit: 3 - depends_on: - - "darwin-aarch64-build-bun" - agents: - queue: "test-darwin" - os: "darwin" - arch: "aarch64" - release: "13" - command: - - "./scripts/runner.node.mjs --step darwin-aarch64-build-bun" - - # macOS x64 - - key: "darwin-x64" - group: ":darwin: x64" - steps: - - key: "darwin-x64-build-deps" - label: "build-deps" - agents: - queue: "build-darwin" - os: "darwin" - arch: "x64" - command: - - "bun run build:ci --target dependencies" - - - key: "darwin-x64-build-cpp" - label: "build-cpp" - agents: - queue: "build-darwin" - os: "darwin" - arch: "x64" - env: - BUN_CPP_ONLY: "ON" - command: - - "bun run build:ci --target bun" - - - key: "darwin-x64-build-zig" - label: "build-zig" - agents: - queue: "build-zig" - command: - - "bun run build:ci --target bun-zig --toolchain darwin-x64" - - - key: "darwin-x64-build-bun" - label: "build-bun" - agents: - queue: "build-darwin" - os: "darwin" - arch: "x64" - depends_on: - - "darwin-x64-build-deps" - - "darwin-x64-build-cpp" - - "darwin-x64-build-zig" - env: - BUN_LINK_ONLY: "ON" - command: - - "bun run build:ci --target bun" - - - key: "darwin-x64-test-macos-14" - label: ":darwin: 14 x64 - test-bun" - if: "build.branch != 'main'" - parallelism: 3 - soft_fail: - - exit_status: 2 - retry: - automatic: - - exit_status: 1 - limit: 1 - - exit_status: -1 - limit: 3 - - exit_status: 255 - limit: 3 - - signal_reason: agent_stop - limit: 3 - - signal: SIGTERM - limit: 3 - depends_on: - - "darwin-x64-build-bun" - agents: - queue: "test-darwin" - os: "darwin" - arch: "x64" - release: "14" - command: - - "./scripts/runner.node.mjs --step darwin-x64-build-bun" - - - key: "darwin-x64-test-macos-13" - label: ":darwin: 13 x64 - test-bun" - if: "build.branch != 'main'" - parallelism: 3 - soft_fail: - - exit_status: 2 - retry: - automatic: - - exit_status: 1 - limit: 1 - - exit_status: -1 - limit: 3 - - exit_status: 255 - limit: 3 - - signal_reason: agent_stop - limit: 3 - - signal: SIGTERM - limit: 3 - depends_on: - - "darwin-x64-build-bun" - agents: - queue: "test-darwin" - os: "darwin" - arch: "x64" - release: "13" - command: - - "./scripts/runner.node.mjs --step darwin-x64-build-bun" - - # Linux x64 - - key: "linux-x64" - group: ":linux: x64" - steps: - - key: "linux-x64-build-deps" - label: "build-deps" - agents: - queue: "build-linux" - os: "linux" - arch: "x64" - command: - - "bun run build:ci --target dependencies" - - - key: "linux-x64-build-cpp" - label: "build-cpp" - agents: - queue: "build-linux" - os: "linux" - arch: "x64" - env: - BUN_CPP_ONLY: "ON" - command: - - "bun run build:ci --target bun" - - - key: "linux-x64-build-zig" - label: "build-zig" - agents: - queue: "build-zig" - command: - - "bun run build:ci --target bun-zig --toolchain linux-x64" - - - key: "linux-x64-build-bun" - label: "build-bun" - agents: - queue: "build-linux" - os: "linux" - arch: "x64" - depends_on: - - "linux-x64-build-deps" - - "linux-x64-build-cpp" - - "linux-x64-build-zig" - env: - BUN_LINK_ONLY: "ON" - command: - - "bun run build:ci --target bun" - - - key: "linux-x64-test-debian-12" - label: ":debian: 12 x64 - test-bun" - if: "build.branch != 'main'" - parallelism: 10 - soft_fail: - - exit_status: 2 - retry: - automatic: - - exit_status: 1 - limit: 1 - - exit_status: -1 - limit: 3 - - exit_status: 255 - limit: 3 - - signal_reason: agent_stop - limit: 3 - - signal: SIGTERM - limit: 3 - depends_on: - - "linux-x64-build-bun" - agents: - robobun: "true" - os: "linux" - arch: "x64" - distro: "debian" - release: "12" - command: - - "./scripts/runner.node.mjs --step linux-x64-build-bun" - - - key: "linux-x64-test-ubuntu-2204" - label: ":ubuntu: 22.04 x64 - test-bun" - if: "build.branch != 'main'" - parallelism: 10 - soft_fail: - - exit_status: 2 - retry: - automatic: - - exit_status: 1 - limit: 1 - - exit_status: -1 - limit: 3 - - exit_status: 255 - limit: 3 - - signal_reason: agent_stop - limit: 3 - - signal: SIGTERM - limit: 3 - depends_on: - - "linux-x64-build-bun" - agents: - robobun: "true" - os: "linux" - arch: "x64" - distro: "ubuntu" - release: "22.04" - command: - - "./scripts/runner.node.mjs --step linux-x64-build-bun" - - - key: "linux-x64-test-ubuntu-2004" - label: ":ubuntu: 20.04 x64 - test-bun" - if: "build.branch != 'main'" - parallelism: 10 - soft_fail: - - exit_status: 2 - retry: - automatic: - - exit_status: 1 - limit: 1 - - exit_status: -1 - limit: 3 - - exit_status: 255 - limit: 3 - - signal_reason: agent_stop - limit: 3 - - signal: SIGTERM - limit: 3 - depends_on: - - "linux-x64-build-bun" - agents: - robobun: "true" - os: "linux" - arch: "x64" - distro: "ubuntu" - release: "20.04" - command: - - "./scripts/runner.node.mjs --step linux-x64-build-bun" - - # Linux x64-baseline - - key: "linux-x64-baseline" - group: ":linux: x64-baseline" - steps: - - key: "linux-x64-baseline-build-deps" - label: "build-deps" - agents: - queue: "build-linux" - os: "linux" - arch: "x64" - env: - ENABLE_BASELINE: "ON" - command: - - "bun run build:ci --target dependencies" - - - key: "linux-x64-baseline-build-cpp" - label: "build-cpp" - agents: - queue: "build-linux" - os: "linux" - arch: "x64" - env: - ENABLE_BASELINE: "ON" - BUN_CPP_ONLY: "ON" - command: - - "bun run build:ci --target bun" - - - key: "linux-x64-baseline-build-zig" - label: "build-zig" - agents: - queue: "build-zig" - env: - ENABLE_BASELINE: "ON" - command: - - "bun run build:ci --target bun-zig --toolchain linux-x64-baseline" - - - key: "linux-x64-baseline-build-bun" - label: "build-bun" - agents: - queue: "build-linux" - os: "linux" - arch: "x64" - depends_on: - - "linux-x64-baseline-build-deps" - - "linux-x64-baseline-build-cpp" - - "linux-x64-baseline-build-zig" - env: - ENABLE_BASELINE: "ON" - BUN_LINK_ONLY: "ON" - command: - - "bun run build:ci --target bun" - - - key: "linux-x64-baseline-test-debian-12" - label: ":debian: 12 x64-baseline - test-bun" - if: "build.branch != 'main'" - parallelism: 10 - soft_fail: - - exit_status: 2 - retry: - automatic: - - exit_status: 1 - limit: 1 - - exit_status: -1 - limit: 3 - - exit_status: 255 - limit: 3 - - signal_reason: agent_stop - limit: 3 - - signal: SIGTERM - limit: 3 - depends_on: - - "linux-x64-baseline-build-bun" - agents: - robobun: "true" - os: "linux" - arch: "x64" - distro: "debian" - release: "12" - command: - - "./scripts/runner.node.mjs --step linux-x64-baseline-build-bun" - - - key: "linux-x64-baseline-test-ubuntu-2204" - label: ":ubuntu: 22.04 x64-baseline - test-bun" - if: "build.branch != 'main'" - parallelism: 10 - soft_fail: - - exit_status: 2 - retry: - automatic: - - exit_status: 1 - limit: 1 - - exit_status: -1 - limit: 3 - - exit_status: 255 - limit: 3 - - signal_reason: agent_stop - limit: 3 - - signal: SIGTERM - limit: 3 - depends_on: - - "linux-x64-baseline-build-bun" - agents: - robobun: "true" - os: "linux" - arch: "x64" - distro: "ubuntu" - release: "22.04" - command: - - "./scripts/runner.node.mjs --step linux-x64-baseline-build-bun" - - - key: "linux-x64-baseline-test-ubuntu-2004" - label: ":ubuntu: 20.04 x64-baseline - test-bun" - if: "build.branch != 'main'" - parallelism: 10 - soft_fail: - - exit_status: 2 - retry: - automatic: - - exit_status: 1 - limit: 1 - - exit_status: -1 - limit: 3 - - exit_status: 255 - limit: 3 - - signal_reason: agent_stop - limit: 3 - - signal: SIGTERM - limit: 3 - depends_on: - - "linux-x64-baseline-build-bun" - agents: - robobun: "true" - os: "linux" - arch: "x64" - distro: "ubuntu" - release: "20.04" - command: - - "./scripts/runner.node.mjs --step linux-x64-baseline-build-bun" - - # Linux aarch64 - - key: "linux-aarch64" - group: ":linux: aarch64" - steps: - - key: "linux-aarch64-build-deps" - label: "build-deps" - agents: - queue: "build-linux" - os: "linux" - arch: "aarch64" - command: - - "bun run build:ci --target dependencies" - - - key: "linux-aarch64-build-cpp" - label: "build-cpp" - agents: - queue: "build-linux" - os: "linux" - arch: "aarch64" - env: - BUN_CPP_ONLY: "ON" - command: - - "bun run build:ci --target bun" - - - key: "linux-aarch64-build-zig" - label: "build-zig" - agents: - queue: "build-zig" - command: - - "bun run build:ci --target bun-zig --toolchain linux-aarch64" - - - key: "linux-aarch64-build-bun" - label: "build-bun" - agents: - queue: "build-linux" - os: "linux" - arch: "aarch64" - depends_on: - - "linux-aarch64-build-deps" - - "linux-aarch64-build-cpp" - - "linux-aarch64-build-zig" - env: - BUN_LINK_ONLY: "ON" - command: - - "bun run build:ci --target bun" - - - key: "linux-aarch64-test-debian-12" - label: ":debian: 12 aarch64 - test-bun" - if: "build.branch != 'main'" - parallelism: 10 - soft_fail: - - exit_status: 2 - retry: - automatic: - - exit_status: 1 - limit: 1 - - exit_status: -1 - limit: 3 - - exit_status: 255 - limit: 3 - - signal_reason: agent_stop - limit: 3 - - signal: SIGTERM - limit: 3 - depends_on: - - "linux-aarch64-build-bun" - agents: - robobun: "true" - os: "linux" - arch: "aarch64" - distro: "debian" - release: "12" - command: - - "./scripts/runner.node.mjs --step linux-aarch64-build-bun" - - - key: "linux-aarch64-test-ubuntu-2204" - label: ":ubuntu: 22.04 aarch64 - test-bun" - if: "build.branch != 'main'" - parallelism: 10 - soft_fail: - - exit_status: 2 - retry: - automatic: - - exit_status: 1 - limit: 1 - - exit_status: -1 - limit: 3 - - exit_status: 255 - limit: 3 - - signal_reason: agent_stop - limit: 3 - - signal: SIGTERM - limit: 3 - depends_on: - - "linux-aarch64-build-bun" - agents: - robobun: "true" - os: "linux" - arch: "aarch64" - distro: "ubuntu" - release: "22.04" - command: - - "./scripts/runner.node.mjs --step linux-aarch64-build-bun" - - - key: "linux-aarch64-test-ubuntu-2004" - label: ":ubuntu: 20.04 aarch64 - test-bun" - if: "build.branch != 'main'" - parallelism: 10 - soft_fail: - - exit_status: 2 - retry: - automatic: - - exit_status: 1 - limit: 1 - - exit_status: -1 - limit: 3 - - exit_status: 255 - limit: 3 - - signal_reason: agent_stop - limit: 3 - - signal: SIGTERM - limit: 3 - depends_on: - - "linux-aarch64-build-bun" - agents: - robobun: "true" - os: "linux" - arch: "aarch64" - distro: "ubuntu" - release: "20.04" - command: - - "./scripts/runner.node.mjs --step linux-aarch64-build-bun" - - # Windows x64 - - key: "windows-x64" - group: ":windows: x64" - steps: - - key: "windows-x64-build-deps" - label: "build-deps" - agents: - queue: "build-windows" - os: "windows" - arch: "x64" - retry: - automatic: - - exit_status: 255 - limit: 5 - command: - - "bun run build:ci --target dependencies" - - - key: "windows-x64-build-cpp" - label: "build-cpp" - agents: - queue: "build-windows" - os: "windows" - arch: "x64" - retry: - automatic: - - exit_status: 255 - limit: 5 - env: - BUN_CPP_ONLY: "ON" - command: - - "bun run build:ci --target bun" - - - key: "windows-x64-build-zig" - label: "build-zig" - agents: - queue: "build-zig" - command: - - "bun run build:ci --target bun-zig --toolchain windows-x64" - - - key: "windows-x64-build-bun" - label: "build-bun" - agents: - queue: "build-windows" - os: "windows" - arch: "x64" - depends_on: - - "windows-x64-build-deps" - - "windows-x64-build-cpp" - - "windows-x64-build-zig" - retry: - automatic: - - exit_status: 255 - limit: 5 - env: - BUN_LINK_ONLY: "ON" - command: - - "bun run build:ci --target bun" - - - key: "windows-x64-test-bun" - label: ":windows: x64 - test-bun" - if: "build.branch != 'main'" - parallelism: 10 - soft_fail: - - exit_status: 1 - retry: - automatic: - - exit_status: -1 - limit: 3 - - exit_status: 255 - limit: 3 - - signal_reason: agent_stop - limit: 3 - - signal: SIGTERM - limit: 3 - depends_on: - - "windows-x64-build-bun" - agents: - robobun: "true" - os: "windows" - arch: "x64" - command: - - "node .\\scripts\\runner.node.mjs --step windows-x64-build-bun" - - # Windows x64-baseline - - key: "windows-x64-baseline" - group: ":windows: x64-baseline" - steps: - - key: "windows-x64-baseline-build-deps" - label: "build-deps" - agents: - queue: "build-windows" - os: "windows" - arch: "x64" - retry: - automatic: - - exit_status: 255 - limit: 5 - env: - ENABLE_BASELINE: "ON" - command: - - "bun run build:ci --target dependencies" - - - key: "windows-x64-baseline-build-cpp" - label: "build-cpp" - agents: - queue: "build-windows" - os: "windows" - arch: "x64" - retry: - automatic: - - exit_status: 255 - limit: 5 - env: - ENABLE_BASELINE: "ON" - BUN_CPP_ONLY: "ON" - command: - - "bun run build:ci --target bun" - - - key: "windows-x64-baseline-build-zig" - label: "build-zig" - agents: - queue: "build-zig" - env: - ENABLE_BASELINE: "ON" - command: - - "bun run build:ci --target bun-zig --toolchain windows-x64-baseline" - - - key: "windows-x64-baseline-build-bun" - label: "build-bun" - agents: - queue: "build-windows" - os: "windows" - arch: "x64" - depends_on: - - "windows-x64-baseline-build-deps" - - "windows-x64-baseline-build-cpp" - - "windows-x64-baseline-build-zig" - retry: - automatic: - - exit_status: 255 - limit: 5 - env: - ENABLE_BASELINE: "ON" - BUN_LINK_ONLY: "ON" - command: - - "bun run build:ci --target bun" - - - key: "windows-x64-baseline-test-bun" - label: ":windows: x64-baseline - test-bun" - if: "build.branch != 'main'" - parallelism: 10 - soft_fail: - - exit_status: 1 - retry: - automatic: - - exit_status: -1 - limit: 3 - - exit_status: 255 - limit: 3 - - signal_reason: agent_stop - limit: 3 - - signal: SIGTERM - limit: 3 - depends_on: - - "windows-x64-baseline-build-bun" - agents: - robobun: "true" - os: "windows" - arch: "x64" - command: - - "node .\\scripts\\runner.node.mjs --step windows-x64-baseline-build-bun" diff --git a/.buildkite/scripts/prepare-build.sh b/.buildkite/scripts/prepare-build.sh index 1c245d9618..56f9619ff5 100755 --- a/.buildkite/scripts/prepare-build.sh +++ b/.buildkite/scripts/prepare-build.sh @@ -29,6 +29,10 @@ function assert_curl() { assert_command "curl" "curl" "https://curl.se/download.html" } +function assert_node() { + assert_command "node" "node" "https://nodejs.org/en/download/" +} + function assert_command() { local command="$1" local package="$2" @@ -92,6 +96,9 @@ assert_build assert_buildkite_agent assert_jq assert_curl +assert_node assert_release assert_canary + +run_command node .buildkite/ci.mjs upload_buildkite_pipeline ".buildkite/ci.yml" diff --git a/.gitignore b/.gitignore index 126af7cebd..20f7a4530d 100644 --- a/.gitignore +++ b/.gitignore @@ -163,3 +163,7 @@ scripts/env.local /src/deps/zstd /src/deps/zlib /src/deps/zig + +# Generated files + +.buildkite/ci.yml