From 81dec2657faf06251112dd9f3bb7b51e441cfd27 Mon Sep 17 00:00:00 2001 From: Ashcon Partovi Date: Mon, 29 Jul 2024 14:39:50 -0700 Subject: [PATCH] Enable buildkite (#12653) --- .buildkite/bootstrap.yml | 5 +- .buildkite/ci.yml | 863 ++------------------- .buildkite/scripts/build-bun.sh | 55 ++ .buildkite/scripts/build-cpp.sh | 34 + .buildkite/scripts/build-deps.ps1 | 0 .buildkite/scripts/build-deps.sh | 22 + .buildkite/scripts/build-old-js.sh | 40 + .buildkite/scripts/build-zig.sh | 80 ++ .buildkite/scripts/download-artifact.ps1 | 47 ++ .buildkite/scripts/download-artifact.sh | 46 ++ .buildkite/scripts/env.sh | 118 +++ .buildkite/scripts/prepare-build.sh | 90 +++ .buildkite/scripts/upload-artifact.ps1 | 47 ++ .buildkite/scripts/upload-artifact.sh | 54 ++ .buildkite/scripts/upload-release.sh | 184 +++-- .github/workflows/build-darwin.yml | 286 ------- .github/workflows/build-linux.yml | 64 -- .github/workflows/build-windows.yml | 348 --------- .github/workflows/build-zig.yml | 122 --- .github/workflows/ci.yml | 245 ------ .github/workflows/comment.yml | 55 -- .github/workflows/create-release-build.yml | 183 ----- .github/workflows/release.yml | 3 + .github/workflows/run-test.yml | 224 ------ .github/workflows/upload.yml | 94 --- scripts/all-dependencies.sh | 6 +- scripts/build-bun-cpp.ps1 | 40 +- scripts/build-bun-cpp.sh | 48 -- scripts/build-bun-zig.sh | 95 --- scripts/build-tinycc.ps1 | 2 - scripts/buildkite-link-bun.ps1 | 33 +- scripts/buildkite-link-bun.sh | 80 -- scripts/env.ps1 | 35 +- scripts/env.sh | 2 +- scripts/experimental-build.mjs | 320 ++++---- scripts/runner.node.mjs | 36 +- test/cli/run/run-crash-handler.test.ts | 16 +- test/js/bun/dns/resolve-dns.test.ts | 2 +- 38 files changed, 1098 insertions(+), 2926 deletions(-) create mode 100755 .buildkite/scripts/build-bun.sh create mode 100755 .buildkite/scripts/build-cpp.sh create mode 100644 .buildkite/scripts/build-deps.ps1 create mode 100755 .buildkite/scripts/build-deps.sh create mode 100755 .buildkite/scripts/build-old-js.sh create mode 100755 .buildkite/scripts/build-zig.sh create mode 100755 .buildkite/scripts/download-artifact.ps1 create mode 100755 .buildkite/scripts/download-artifact.sh create mode 100755 .buildkite/scripts/env.sh create mode 100755 .buildkite/scripts/prepare-build.sh create mode 100755 .buildkite/scripts/upload-artifact.ps1 create mode 100755 .buildkite/scripts/upload-artifact.sh delete mode 100644 .github/workflows/build-darwin.yml delete mode 100644 .github/workflows/build-linux.yml delete mode 100644 .github/workflows/build-windows.yml delete mode 100644 .github/workflows/build-zig.yml delete mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/comment.yml delete mode 100644 .github/workflows/create-release-build.yml delete mode 100644 .github/workflows/run-test.yml delete mode 100644 .github/workflows/upload.yml delete mode 100755 scripts/build-bun-cpp.sh delete mode 100755 scripts/build-bun-zig.sh delete mode 100755 scripts/buildkite-link-bun.sh diff --git a/.buildkite/bootstrap.yml b/.buildkite/bootstrap.yml index 1fef8b6cc0..b0b84616b3 100644 --- a/.buildkite/bootstrap.yml +++ b/.buildkite/bootstrap.yml @@ -10,9 +10,10 @@ steps: blocked_state: "running" - label: ":pipeline:" - command: "buildkite-agent pipeline upload .buildkite/ci.yml" agents: - queue: "build-linux" + queue: "build-darwin" + command: + - ".buildkite/scripts/prepare-build.sh" - if: "build.branch == 'main' && !build.pull_request.repository.fork" label: ":github:" diff --git a/.buildkite/ci.yml b/.buildkite/ci.yml index e586d3ec53..b7aa6f29b2 100644 --- a/.buildkite/ci.yml +++ b/.buildkite/ci.yml @@ -25,16 +25,8 @@ steps: queue: "build-darwin" os: "darwin" arch: "aarch64" - artifact_paths: - - "build/bun-deps/**/*" - env: - CPU_TARGET: "native" - CCACHE_DIR: "$$HOME/.cache/ccache" - SCCACHE_DIR: "$$HOME/.cache/sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME/.cache/zig-cache" - BUN_DEPS_CACHE_DIR: "$$HOME/.cache/bun-deps" command: - - "./scripts/all-dependencies.sh" + - "./.buildkite/scripts/build-deps.sh" - key: "darwin-aarch64-build-zig" label: ":darwin: aarch64 - build-zig" @@ -42,15 +34,8 @@ steps: queue: "build-darwin" os: "darwin" arch: "aarch64" - artifact_paths: - - "build/bun-zig.o" - env: - CPU_TARGET: "native" - CCACHE_DIR: "$$HOME/.cache/ccache" - SCCACHE_DIR: "$$HOME/.cache/sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME/.cache/zig-cache" command: - - "./scripts/build-bun-zig.sh darwin aarch64" + - "./.buildkite/scripts/build-zig.sh darwin aarch64" - key: "darwin-aarch64-build-cpp" label: ":darwin: aarch64 - build-cpp" @@ -58,37 +43,8 @@ steps: queue: "build-darwin" os: "darwin" arch: "aarch64" - artifact_paths: - - "build/bun-cpp-objects.a" - env: - CPU_TARGET: "native" - CCACHE_DIR: "$$HOME/.cache/ccache" - SCCACHE_DIR: "$$HOME/.cache/sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME/.cache/zig-cache" command: - - "./scripts/build-bun-cpp.sh" - - - key: "darwin-aarch64-build-bun-nolto" - label: ":darwin: aarch64 - build-bun (no-lto)" - if: "build.branch != 'main'" - depends_on: - - "darwin-aarch64-build-deps" - - "darwin-aarch64-build-zig" - - "darwin-aarch64-build-cpp" - agents: - queue: "build-darwin" - os: "darwin" - arch: "aarch64" - artifact_paths: - - "bun-darwin-aarch64-nolto.zip" - - "bun-darwin-aarch64-nolto-profile.zip" - env: - CPU_TARGET: "native" - CCACHE_DIR: "$$HOME/.cache/ccache" - SCCACHE_DIR: "$$HOME/.cache/sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME/.cache/zig-cache" - command: - - "./scripts/buildkite-link-bun.sh --tag darwin-aarch64 --fast" + - "./.buildkite/scripts/build-cpp.sh" - key: "darwin-aarch64-build-bun" label: ":darwin: aarch64 - build-bun" @@ -100,16 +56,8 @@ steps: queue: "build-darwin" os: "darwin" arch: "aarch64" - artifact_paths: - - "bun-darwin-aarch64.zip" - - "bun-darwin-aarch64-profile.zip" - env: - CPU_TARGET: "native" - CCACHE_DIR: "$$HOME/.cache/ccache" - SCCACHE_DIR: "$$HOME/.cache/sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME/.cache/zig-cache" command: - - "./scripts/buildkite-link-bun.sh --tag darwin-aarch64" + - "./.buildkite/scripts/build-bun.sh" - key: "darwin-aarch64-test-macos-14" label: ":darwin: 14 aarch64 - test-bun" @@ -129,77 +77,20 @@ steps: limit: 3 - signal: SIGTERM limit: 3 - depends_on: - - "darwin-aarch64-build-bun-nolto" + - "darwin-aarch64-build-bun" agents: queue: "test-darwin" os: "darwin" arch: "aarch64" release: "14" command: - - "./scripts/runner.node.mjs --step darwin-aarch64-build-bun-nolto" + - "./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-nolto" - agents: - queue: "test-darwin" - os: "darwin" - arch: "aarch64" - release: "13" - command: - - "./scripts/runner.node.mjs --step darwin-aarch64-build-bun-nolto" - - - key: "darwin-aarch64-test-macos-14-smoke" - label: ":darwin: 14 aarch64 - test-bun (smoke)" - if: "build.branch != 'main'" - parallelism: 1 - 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 --smoke 0.05" - - - key: "darwin-aarch64-test-macos-13-smoke" - label: ":darwin: 13 aarch64 - test-bun (smoke)" - if: "build.branch != 'main'" - parallelism: 1 soft_fail: - exit_status: 2 retry: @@ -222,7 +113,7 @@ steps: arch: "aarch64" release: "13" command: - - "./scripts/runner.node.mjs --step darwin-aarch64-build-bun --smoke 0.05" + - "./scripts/runner.node.mjs --step darwin-aarch64-build-bun" # macOS x64 - key: "darwin-x64" @@ -234,16 +125,8 @@ steps: queue: "build-darwin" os: "darwin" arch: "x64" - artifact_paths: - - "build/bun-deps/**/*" - env: - CPU_TARGET: "haswell" - CCACHE_DIR: "$$HOME/.cache/ccache" - SCCACHE_DIR: "$$HOME/.cache/sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME/.cache/zig-cache" - BUN_DEPS_CACHE_DIR: "$$HOME/.cache/bun-deps" command: - - "./scripts/all-dependencies.sh" + - "./.buildkite/scripts/build-deps.sh" - key: "darwin-x64-build-zig" label: ":darwin: x64 - build-zig" @@ -251,15 +134,8 @@ steps: queue: "build-darwin" os: "darwin" arch: "aarch64" - artifact_paths: - - "build/bun-zig.o" - env: - CPU_TARGET: "haswell" - CCACHE_DIR: "$$HOME/.cache/ccache" - SCCACHE_DIR: "$$HOME/.cache/sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME/.cache/zig-cache" command: - - "./scripts/build-bun-zig.sh darwin x64" + - "./.buildkite/scripts/build-zig.sh darwin x64" - key: "darwin-x64-build-cpp" label: ":darwin: x64 - build-cpp" @@ -267,37 +143,8 @@ steps: queue: "build-darwin" os: "darwin" arch: "x64" - artifact_paths: - - "build/bun-cpp-objects.a" - env: - CPU_TARGET: "haswell" - CCACHE_DIR: "$$HOME/.cache/ccache" - SCCACHE_DIR: "$$HOME/.cache/sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME/.cache/zig-cache" command: - - "./scripts/build-bun-cpp.sh" - - - key: "darwin-x64-build-bun-nolto" - label: ":darwin: x64 - build-bun (no-lto)" - if: "build.branch != 'main'" - depends_on: - - "darwin-x64-build-deps" - - "darwin-x64-build-zig" - - "darwin-x64-build-cpp" - agents: - queue: "build-darwin" - os: "darwin" - arch: "x64" - artifact_paths: - - "bun-darwin-x64-nolto.zip" - - "bun-darwin-x64-nolto-profile.zip" - env: - CPU_TARGET: "haswell" - CCACHE_DIR: "$$HOME/.cache/ccache" - SCCACHE_DIR: "$$HOME/.cache/sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME/.cache/zig-cache" - command: - - "./scripts/buildkite-link-bun.sh --tag darwin-x64 --fast" + - "./.buildkite/scripts/build-cpp.sh" - key: "darwin-x64-build-bun" label: ":darwin: x64 - build-bun" @@ -309,77 +156,13 @@ steps: queue: "build-darwin" os: "darwin" arch: "x64" - artifact_paths: - - "bun-darwin-x64.zip" - - "bun-darwin-x64-profile.zip" - env: - CPU_TARGET: "haswell" - CCACHE_DIR: "$$HOME/.cache/ccache" - SCCACHE_DIR: "$$HOME/.cache/sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME/.cache/zig-cache" command: - - "./scripts/buildkite-link-bun.sh --tag darwin-x64" + - "./.buildkite/scripts/build-bun.sh" - 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-nolto" - agents: - queue: "test-darwin" - os: "darwin" - arch: "x64" - release: "14" - command: - - "./scripts/runner.node.mjs --step darwin-x64-build-bun-nolto" - - - 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-nolto" - agents: - queue: "test-darwin" - os: "darwin" - arch: "x64" - release: "13" - command: - - "./scripts/runner.node.mjs --step darwin-x64-build-bun-nolto" - - - key: "darwin-x64-test-macos-14-smoke" - label: ":darwin: 14 x64 - test-bun (smoke)" - if: "build.branch != 'main'" - parallelism: 1 + parallelism: 2 soft_fail: - exit_status: 2 retry: @@ -402,12 +185,12 @@ steps: arch: "x64" release: "14" command: - - "./scripts/runner.node.mjs --step darwin-x64-build-bun --smoke 0.05" + - "./scripts/runner.node.mjs --step darwin-x64-build-bun" - - key: "darwin-x64-test-macos-13-smoke" - label: ":darwin: 13 x64 - test-bun (smoke)" + - key: "darwin-x64-test-macos-13" + label: ":darwin: 13 x64 - test-bun" if: "build.branch != 'main'" - parallelism: 1 + parallelism: 2 soft_fail: - exit_status: 2 retry: @@ -423,14 +206,14 @@ steps: - signal: SIGTERM limit: 3 depends_on: - - "darwin-x64-build-bun-nolto" + - "darwin-x64-build-bun" agents: queue: "test-darwin" os: "darwin" arch: "x64" release: "13" command: - - "./scripts/runner.node.mjs --step darwin-x64-build-bun --smoke 0.05" + - "./scripts/runner.node.mjs --step darwin-x64-build-bun" # Linux aarch64 - key: "linux-aarch64" @@ -442,16 +225,8 @@ steps: queue: "build-linux" os: "linux" arch: "aarch64" - artifact_paths: - - "build/bun-deps/**/*" - env: - CPU_TARGET: "native" - CCACHE_DIR: "$$HOME/.cache/ccache" - SCCACHE_DIR: "$$HOME/.cache/sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME/.cache/zig-cache" - BUN_DEPS_CACHE_DIR: "$$HOME/.cache/bun-deps" command: - - "./scripts/all-dependencies.sh" + - "./.buildkite/scripts/build-deps.sh" - key: "linux-aarch64-build-zig" label: ":linux: aarch64 - build-zig" @@ -459,15 +234,8 @@ steps: queue: "build-darwin" os: "darwin" arch: "aarch64" - artifact_paths: - - "build/bun-zig.o" - env: - CPU_TARGET: "native" - CCACHE_DIR: "$$HOME/.cache/ccache" - SCCACHE_DIR: "$$HOME/.cache/sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME/.cache/zig-cache" command: - - "./scripts/build-bun-zig.sh linux aarch64" + - "./.buildkite/scripts/build-zig.sh linux aarch64" - key: "linux-aarch64-build-cpp" label: ":linux: aarch64 - build-cpp" @@ -475,37 +243,8 @@ steps: queue: "build-linux" os: "linux" arch: "aarch64" - artifact_paths: - - "build/bun-cpp-objects.a" - env: - CPU_TARGET: "native" - CCACHE_DIR: "$$HOME/.cache/ccache" - SCCACHE_DIR: "$$HOME/.cache/sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME/.cache/zig-cache" command: - - "./scripts/build-bun-cpp.sh" - - - key: "linux-aarch64-build-bun-nolto" - label: ":linux: aarch64 - build-bun (no-lto)" - if: "build.branch != 'main'" - depends_on: - - "linux-aarch64-build-deps" - - "linux-aarch64-build-zig" - - "linux-aarch64-build-cpp" - agents: - queue: "build-linux" - os: "linux" - arch: "aarch64" - artifact_paths: - - "bun-linux-aarch64-nolto.zip" - - "bun-linux-aarch64-nolto-profile.zip" - env: - CPU_TARGET: "native" - CCACHE_DIR: "$$HOME/.cache/ccache" - SCCACHE_DIR: "$$HOME/.cache/sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME/.cache/zig-cache" - command: - - "./scripts/buildkite-link-bun.sh --tag linux-aarch64 --fast" + - "./.buildkite/scripts/build-cpp.sh" - key: "linux-aarch64-build-bun" label: ":linux: aarch64 - build-bun" @@ -517,16 +256,8 @@ steps: queue: "build-linux" os: "linux" arch: "aarch64" - artifact_paths: - - "bun-linux-aarch64.zip" - - "bun-linux-aarch64-profile.zip" - env: - CPU_TARGET: "native" - CCACHE_DIR: "$$HOME/.cache/ccache" - SCCACHE_DIR: "$$HOME/.cache/sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME/.cache/zig-cache" command: - - "./scripts/buildkite-link-bun.sh --tag linux-aarch64" + - "./.buildkite/scripts/build-bun.sh" - key: "linux-aarch64-test-debian-12" label: ":debian: 12 aarch64 - test-bun" @@ -547,7 +278,7 @@ steps: - signal: SIGTERM limit: 3 depends_on: - - "linux-aarch64-build-bun-nolto" + - "linux-aarch64-build-bun" agents: robobun: "true" os: "linux" @@ -555,7 +286,7 @@ steps: distro: "debian" release: "12" command: - - "./scripts/runner.node.mjs --step linux-aarch64-build-bun-nolto" + - "./scripts/runner.node.mjs --step linux-aarch64-build-bun" - key: "linux-aarch64-test-ubuntu-2204" label: ":ubuntu: 22.04 aarch64 - test-bun" @@ -576,7 +307,7 @@ steps: - signal: SIGTERM limit: 3 depends_on: - - "linux-aarch64-build-bun-nolto" + - "linux-aarch64-build-bun" agents: robobun: "true" os: "linux" @@ -584,99 +315,12 @@ steps: distro: "ubuntu" release: "22.04" command: - - "./scripts/runner.node.mjs --step linux-aarch64-build-bun-nolto" + - "./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: 5 - 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-nolto" - agents: - robobun: "true" - os: "linux" - arch: "aarch64" - distro: "ubuntu" - release: "20.04" - command: - - "./scripts/runner.node.mjs --step linux-aarch64-build-bun-nolto" - - - key: "linux-aarch64-test-debian-12-smoke" - label: ":debian: 12 aarch64 - test-bun-smoke" - if: "build.branch != 'main'" - parallelism: 1 - 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 --smoke 0.05" - - - key: "linux-aarch64-test-ubuntu-2204-smoke" - label: ":ubuntu: 22.04 aarch64 - test-bun (smoke)" - if: "build.branch != 'main'" - parallelism: 1 - 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 --smoke 0.05" - - - key: "linux-aarch64-test-ubuntu-2004-smoke" - label: ":ubuntu: 20.04 aarch64 - test-bun (smoke)" - if: "build.branch != 'main'" - parallelism: 1 soft_fail: - exit_status: 2 retry: @@ -700,7 +344,7 @@ steps: distro: "ubuntu" release: "20.04" command: - - "./scripts/runner.node.mjs --step linux-aarch64-build-bun --smoke 0.05" + - "./scripts/runner.node.mjs --step linux-aarch64-build-bun" # Linux x64 - key: "linux-x64" @@ -712,16 +356,8 @@ steps: queue: "build-linux" os: "linux" arch: "x64" - artifact_paths: - - "build/bun-deps/**/*" - env: - CPU_TARGET: "haswell" - CCACHE_DIR: "$$HOME/.cache/ccache" - SCCACHE_DIR: "$$HOME/.cache/sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME/.cache/zig-cache" - BUN_DEPS_CACHE_DIR: "$$HOME/.cache/bun-deps" command: - - "./scripts/all-dependencies.sh" + - "./.buildkite/scripts/build-deps.sh" - key: "linux-x64-build-zig" label: ":linux: x64 - build-zig" @@ -729,15 +365,8 @@ steps: queue: "build-darwin" os: "darwin" arch: "aarch64" - artifact_paths: - - "build/bun-zig.o" - env: - CPU_TARGET: "haswell" - CCACHE_DIR: "$$HOME/.cache/ccache" - SCCACHE_DIR: "$$HOME/.cache/sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME/.cache/zig-cache" command: - - "./scripts/build-bun-zig.sh linux x64" + - "./.buildkite/scripts/build-zig.sh linux x64" - key: "linux-x64-build-cpp" label: ":linux: x64 - build-cpp" @@ -745,37 +374,8 @@ steps: queue: "build-linux" os: "linux" arch: "x64" - artifact_paths: - - "build/bun-cpp-objects.a" - env: - CPU_TARGET: "haswell" - CCACHE_DIR: "$$HOME/.cache/ccache" - SCCACHE_DIR: "$$HOME/.cache/sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME/.cache/zig-cache" command: - - "./scripts/build-bun-cpp.sh" - - - key: "linux-x64-build-bun-nolto" - label: ":linux: x64 - build-bun (no-lto)" - if: "build.branch != 'main'" - depends_on: - - "linux-x64-build-deps" - - "linux-x64-build-zig" - - "linux-x64-build-cpp" - agents: - queue: "build-linux" - os: "linux" - arch: "x64" - artifact_paths: - - "bun-linux-x64-nolto.zip" - - "bun-linux-x64-nolto-profile.zip" - env: - CPU_TARGET: "haswell" - CCACHE_DIR: "$$HOME/.cache/ccache" - SCCACHE_DIR: "$$HOME/.cache/sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME/.cache/zig-cache" - command: - - "./scripts/buildkite-link-bun.sh --tag linux-x64 --fast" + - "./.buildkite/scripts/build-cpp.sh" - key: "linux-x64-build-bun" label: ":linux: x64 - build-bun" @@ -787,16 +387,8 @@ steps: queue: "build-linux" os: "linux" arch: "x64" - artifact_paths: - - "bun-linux-x64.zip" - - "bun-linux-x64-profile.zip" - env: - CPU_TARGET: "haswell" - CCACHE_DIR: "$$HOME/.cache/ccache" - SCCACHE_DIR: "$$HOME/.cache/sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME/.cache/zig-cache" command: - - "./scripts/buildkite-link-bun.sh --tag linux-x64" + - "./.buildkite/scripts/build-bun.sh" - key: "linux-x64-test-debian-12" label: ":debian: 12 x64 - test-bun" @@ -817,7 +409,7 @@ steps: - signal: SIGTERM limit: 3 depends_on: - - "linux-x64-build-bun-nolto" + - "linux-x64-build-bun" agents: robobun: "true" os: "linux" @@ -825,7 +417,7 @@ steps: distro: "debian" release: "12" command: - - "./scripts/runner.node.mjs --step linux-x64-build-bun-nolto" + - "./scripts/runner.node.mjs --step linux-x64-build-bun" - key: "linux-x64-test-ubuntu-2204" label: ":ubuntu: 22.04 x64 - test-bun" @@ -846,7 +438,7 @@ steps: - signal: SIGTERM limit: 3 depends_on: - - "linux-x64-build-bun-nolto" + - "linux-x64-build-bun" agents: robobun: "true" os: "linux" @@ -854,99 +446,12 @@ steps: distro: "ubuntu" release: "22.04" command: - - "./scripts/runner.node.mjs --step linux-x64-build-bun-nolto" + - "./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: 5 - 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-nolto" - agents: - robobun: "true" - os: "linux" - arch: "x64" - distro: "ubuntu" - release: "20.04" - command: - - "./scripts/runner.node.mjs --step linux-x64-build-bun-nolto" - - - key: "linux-x64-test-debian-12-smoke" - label: ":debian: 12 x64 - test-bun (smoke)" - if: "build.branch != 'main'" - parallelism: 1 - 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 --smoke 0.05" - - - key: "linux-x64-test-ubuntu-2204-smoke" - label: ":ubuntu: 22.04 x64 - test-bun (smoke)" - if: "build.branch != 'main'" - parallelism: 1 - 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 --smoke 0.05" - - - key: "linux-x64-test-ubuntu-2004-smoke" - label: ":ubuntu: 20.04 x64 - test-bun (smoke)" - if: "build.branch != 'main'" - parallelism: 1 soft_fail: - exit_status: 2 retry: @@ -970,7 +475,7 @@ steps: distro: "ubuntu" release: "20.04" command: - - "./scripts/runner.node.mjs --step linux-x64-build-bun --smoke 0.05" + - "./scripts/runner.node.mjs --step linux-x64-build-bun" # Linux x64-baseline - key: "linux-x64-baseline" @@ -982,16 +487,8 @@ steps: queue: "build-linux" os: "linux" arch: "x64" - artifact_paths: - - "build/bun-deps/**/*" - env: - CPU_TARGET: "nehalem" - CCACHE_DIR: "$$HOME/.cache/ccache" - SCCACHE_DIR: "$$HOME/.cache/sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME/.cache/zig-cache" - BUN_DEPS_CACHE_DIR: "$$HOME/.cache/bun-deps" command: - - "./scripts/all-dependencies.sh" + - "./.buildkite/scripts/build-deps.sh" - key: "linux-x64-baseline-build-zig" label: ":linux: x64-baseline - build-zig" @@ -999,15 +496,8 @@ steps: queue: "build-darwin" os: "darwin" arch: "aarch64" - artifact_paths: - - "build/bun-zig.o" - env: - CPU_TARGET: "nehalem" - CCACHE_DIR: "$$HOME/.cache/ccache" - SCCACHE_DIR: "$$HOME/.cache/sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME/.cache/zig-cache" command: - - "./scripts/build-bun-zig.sh linux x64" + - "./.buildkite/scripts/build-zig.sh linux x64" - key: "linux-x64-baseline-build-cpp" label: ":linux: x64-baseline - build-cpp" @@ -1015,37 +505,8 @@ steps: queue: "build-linux" os: "linux" arch: "x64" - artifact_paths: - - "build/bun-cpp-objects.a" - env: - CPU_TARGET: "nehalem" - CCACHE_DIR: "$$HOME/.cache/ccache" - SCCACHE_DIR: "$$HOME/.cache/sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME/.cache/zig-cache" command: - - "./scripts/build-bun-cpp.sh" - - - key: "linux-x64-baseline-build-bun-nolto" - label: ":linux: x64-baseline - build-bun (no-lto)" - if: "build.branch != 'main'" - depends_on: - - "linux-x64-baseline-build-deps" - - "linux-x64-baseline-build-zig" - - "linux-x64-baseline-build-cpp" - agents: - queue: "build-linux" - os: "linux" - arch: "x64" - artifact_paths: - - "bun-linux-x64-baseline-nolto.zip" - - "bun-linux-x64-baseline-nolto-profile.zip" - env: - CPU_TARGET: "nehalem" - CCACHE_DIR: "$$HOME/.cache/ccache" - SCCACHE_DIR: "$$HOME/.cache/sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME/.cache/zig-cache" - command: - - "./scripts/buildkite-link-bun.sh --tag linux-x64-baseline --fast" + - "./.buildkite/scripts/build-cpp.sh" - key: "linux-x64-baseline-build-bun" label: ":linux: x64-baseline - build-bun" @@ -1057,16 +518,8 @@ steps: queue: "build-linux" os: "linux" arch: "x64" - artifact_paths: - - "bun-linux-x64-baseline.zip" - - "bun-linux-x64-baseline-profile.zip" - env: - CPU_TARGET: "nehalem" - CCACHE_DIR: "$$HOME/.cache/ccache" - SCCACHE_DIR: "$$HOME/.cache/sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME/.cache/zig-cache" command: - - "./scripts/buildkite-link-bun.sh --tag linux-x64-baseline" + - "./.buildkite/scripts/build-bun.sh" - key: "linux-x64-baseline-test-debian-12" label: ":debian: 12 x64-baseline - test-bun" @@ -1087,7 +540,7 @@ steps: - signal: SIGTERM limit: 3 depends_on: - - "linux-x64-baseline-build-bun-nolto" + - "linux-x64-baseline-build-bun" agents: robobun: "true" os: "linux" @@ -1095,7 +548,7 @@ steps: distro: "debian" release: "12" command: - - "./scripts/runner.node.mjs --step linux-x64-baseline-build-bun-nolto" + - "./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" @@ -1116,7 +569,7 @@ steps: - signal: SIGTERM limit: 3 depends_on: - - "linux-x64-baseline-build-bun-nolto" + - "linux-x64-baseline-build-bun" agents: robobun: "true" os: "linux" @@ -1124,99 +577,12 @@ steps: distro: "ubuntu" release: "22.04" command: - - "./scripts/runner.node.mjs --step linux-x64-baseline-build-bun-nolto" + - "./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: 5 - 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-nolto" - agents: - robobun: "true" - os: "linux" - arch: "x64" - distro: "ubuntu" - release: "20.04" - command: - - "./scripts/runner.node.mjs --step linux-x64-baseline-build-bun-nolto" - - - key: "linux-x64-baseline-test-debian-12-smoke" - label: ":debian: 12 x64-baseline - test-bun (smoke)" - if: "build.branch != 'main'" - parallelism: 1 - 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 --smoke 0.05" - - - key: "linux-x64-baseline-test-ubuntu-2204-smoke" - label: ":ubuntu: 22.04 x64-baseline - test-bun (smoke)" - if: "build.branch != 'main'" - parallelism: 1 - 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 --smoke 0.05" - - - key: "linux-x64-baseline-test-ubuntu-2004-smoke" - label: ":ubuntu: 20.04 x64-baseline - test-bun (smoke)" - if: "build.branch != 'main'" - parallelism: 1 soft_fail: - exit_status: 2 retry: @@ -1240,7 +606,7 @@ steps: distro: "ubuntu" release: "20.04" command: - - "./scripts/runner.node.mjs --step linux-x64-baseline-build-bun --smoke 0.05" + - "./scripts/runner.node.mjs --step linux-x64-baseline-build-bun" # Windows x64 - key: "windows-x64" @@ -1255,9 +621,9 @@ steps: artifact_paths: - "build\\bun-deps\\*.lib" env: - CPU_TARGET: "haswell" SCCACHE_DIR: "$$HOME\\.cache\\sccache" ZIG_LOCAL_CACHE_DIR: "$$HOME\\.cache\\zig-cache" + SCCACHE_IGNORE_SERVER_IO_ERROR: "1" command: - ".\\scripts\\all-dependencies.ps1" @@ -1267,14 +633,8 @@ steps: queue: "build-darwin" os: "darwin" # cross-compile on Linux or Darwin arch: "aarch64" - artifact_paths: - - "build/bun-zig.o" - env: - CPU_TARGET: "haswell" - SCCACHE_DIR: "$$HOME\\.cache\\sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME\\.cache\\zig-cache" command: - - "./scripts/build-bun-zig.sh windows x64" + - "./.buildkite/scripts/build-zig.sh windows x64" - key: "windows-x64-build-cpp" label: ":windows: x64 - build-cpp" @@ -1283,31 +643,11 @@ steps: os: "windows" arch: "x64" artifact_paths: - - "build\\bun-cpp-objects.a" + # HACK: See scripts/build-bun-cpp.ps1 + # - "build\\bun-cpp-objects.a" + - "build\\bun-cpp-objects.a.*" command: - - ".\\scripts\\build-bun-cpp.ps1 -Fast $$True" - - - key: "windows-x64-build-bun-nolto" - label: ":windows: x64 - build-bun (no-lto)" - if: "build.branch != 'main'" - depends_on: - - "windows-x64-build-deps" - - "windows-x64-build-zig" - - "windows-x64-build-cpp" - agents: - queue: "build-windows" - os: "windows" - arch: "x64" - artifact_paths: - - "bun-windows-x64-nolto.zip" - - "bun-windows-x64-nolto-profile.zip" - - "features.json" - env: - CPU_TARGET: "haswell" - SCCACHE_DIR: "$$HOME\\.cache\\sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME\\.cache\\zig-cache" - command: - - ".\\scripts\\buildkite-link-bun.ps1 -Fast $$True" + - ".\\scripts\\build-bun-cpp.ps1" - key: "windows-x64-build-bun" label: ":windows: x64 - build-bun" @@ -1324,9 +664,9 @@ steps: - "bun-windows-x64-profile.zip" - "features.json" env: - CPU_TARGET: "haswell" SCCACHE_DIR: "$$HOME\\.cache\\sccache" ZIG_LOCAL_CACHE_DIR: "$$HOME\\.cache\\zig-cache" + SCCACHE_IGNORE_SERVER_IO_ERROR: "1" command: - ".\\scripts\\buildkite-link-bun.ps1" @@ -1334,31 +674,6 @@ steps: 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-nolto" - agents: - robobun: "true" - os: "windows" - arch: "x64" - command: - - "node .\\scripts\\runner.node.mjs --step windows-x64-build-bun-nolto" - - - key: "windows-x64-test-bun-smoke" - label: ":windows: x64 - test-bun (smoke)" - if: "build.branch != 'main'" - parallelism: 1 soft_fail: - exit_status: 1 retry: @@ -1378,7 +693,7 @@ steps: os: "windows" arch: "x64" command: - - "node .\\scripts\\runner.node.mjs --step windows-x64-build-bun --smoke 0.05" + - "node .\\scripts\\runner.node.mjs --step windows-x64-build-bun" # Windows x64-baseline - key: "windows-x64-baseline" @@ -1393,9 +708,10 @@ steps: artifact_paths: - "build\\bun-deps\\*.lib" env: - CPU_TARGET: "nehalem" SCCACHE_DIR: "$$HOME\\.cache\\sccache" ZIG_LOCAL_CACHE_DIR: "$$HOME\\.cache\\zig-cache" + SCCACHE_IGNORE_SERVER_IO_ERROR: "1" + USE_BASELINE_BUILD: "1" command: - ".\\scripts\\all-dependencies.ps1" @@ -1405,14 +721,8 @@ steps: queue: "build-darwin" os: "darwin" # cross-compile on Linux or Darwin arch: "aarch64" - artifact_paths: - - "build/bun-zig.o" - env: - CPU_TARGET: "nehalem" - SCCACHE_DIR: "$$HOME\\.cache\\sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME\\.cache\\zig-cache" command: - - "./scripts/build-bun-zig.sh windows x64" + - "./.buildkite/scripts/build-zig.sh windows x64" - key: "windows-x64-baseline-build-cpp" label: ":windows: x64-baseline - build-cpp" @@ -1421,35 +731,16 @@ steps: os: "windows" arch: "x64" artifact_paths: - - "build\\bun-cpp-objects.a" + # HACK: See scripts/build-bun-cpp.ps1 + # - "build\\bun-cpp-objects.a" + - "build\\bun-cpp-objects.a.*" env: - CPU_TARGET: "nehalem" SCCACHE_DIR: "$$HOME\\.cache\\sccache" ZIG_LOCAL_CACHE_DIR: "$$HOME\\.cache\\zig-cache" + SCCACHE_IGNORE_SERVER_IO_ERROR: "1" + USE_BASELINE_BUILD: "1" command: - - ".\\scripts\\build-bun-cpp.ps1 -Baseline $$True" - - - key: "windows-x64-baseline-build-bun-nolto" - label: ":windows: x64-baseline - build-bun (no-lto)" - if: "build.branch != 'main'" - depends_on: - - "windows-x64-baseline-build-deps" - - "windows-x64-baseline-build-zig" - - "windows-x64-baseline-build-cpp" - agents: - queue: "build-windows" - os: "windows" - arch: "x64" - artifact_paths: - - "bun-windows-x64-baseline-nolto.zip" - - "bun-windows-x64-baseline-nolto-profile.zip" - - "features.json" - env: - CPU_TARGET: "nehalem" - SCCACHE_DIR: "$$HOME\\.cache\\sccache" - ZIG_LOCAL_CACHE_DIR: "$$HOME\\.cache\\zig-cache" - command: - - ".\\scripts\\buildkite-link-bun.ps1 -Baseline $$True -Fast $$True" + - ".\\scripts\\build-bun-cpp.ps1" - key: "windows-x64-baseline-build-bun" label: ":windows: x64-baseline - build-bun" @@ -1466,9 +757,10 @@ steps: - "bun-windows-x64-baseline-profile.zip" - "features.json" env: - CPU_TARGET: "nehalem" SCCACHE_DIR: "$$HOME\\.cache\\sccache" ZIG_LOCAL_CACHE_DIR: "$$HOME\\.cache\\zig-cache" + SCCACHE_IGNORE_SERVER_IO_ERROR: "1" + USE_BASELINE_BUILD: "1" command: - ".\\scripts\\buildkite-link-bun.ps1 -Baseline $$True" @@ -1476,31 +768,6 @@ steps: 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-nolto" - agents: - robobun: "true" - os: "windows" - arch: "x64" - command: - - "node .\\scripts\\runner.node.mjs --step windows-x64-baseline-build-bun-nolto" - - - key: "windows-x64-baseline-test-bun-smoke" - label: ":windows: x64-baseline - test-bun (smoke)" - if: "build.branch != 'main'" - parallelism: 1 soft_fail: - exit_status: 1 retry: @@ -1520,4 +787,4 @@ steps: os: "windows" arch: "x64" command: - - "node .\\scripts\\runner.node.mjs --step windows-x64-baseline-build-bun --smoke 0.05" + - "node .\\scripts\\runner.node.mjs --step windows-x64-baseline-build-bun" diff --git a/.buildkite/scripts/build-bun.sh b/.buildkite/scripts/build-bun.sh new file mode 100755 index 0000000000..59363a39fd --- /dev/null +++ b/.buildkite/scripts/build-bun.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +set -eo pipefail +source "$(dirname "$0")/env.sh" + +function run_command() { + set -x + "$@" + { set +x; } 2>/dev/null +} + +cwd="$(pwd)" + +mkdir -p build +source "$(dirname "$0")/download-artifact.sh" "build/bun-deps/**" --step "$BUILDKITE_GROUP_KEY-build-deps" +source "$(dirname "$0")/download-artifact.sh" "build/bun-zig.o" --step "$BUILDKITE_GROUP_KEY-build-zig" +source "$(dirname "$0")/download-artifact.sh" "build/bun-cpp-objects.a" --step "$BUILDKITE_GROUP_KEY-build-cpp" --split +cd build + +run_command cmake .. "${CMAKE_FLAGS[@]}" \ + -GNinja \ + -DBUN_LINK_ONLY="1" \ + -DNO_CONFIGURE_DEPENDS="1" \ + -DBUN_ZIG_OBJ_DIR="$cwd/build" \ + -DBUN_CPP_ARCHIVE="$cwd/build/bun-cpp-objects.a" \ + -DBUN_DEPS_OUT_DIR="$cwd/build/bun-deps" \ + -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \ + -DCPU_TARGET="$CPU_TARGET" \ + -DUSE_LTO="$USE_LTO" \ + -DUSE_DEBUG_JSC="$USE_DEBUG_JSC" \ + -DCANARY="$CANARY" \ + -DGIT_SHA="$GIT_SHA" +run_command ninja -v -j "$CPUS" +run_command ls + +tag="bun-$BUILDKITE_GROUP_KEY" +if [ "$USE_LTO" == "OFF" ]; then + # Remove OS check when LTO is enabled on macOS again + if [[ "$tag" == *"darwin"* ]]; then + tag="$tag-nolto" + fi +fi + +for name in bun bun-profile; do + dir="$tag" + if [ "$name" == "bun-profile" ]; then + dir="$tag-profile" + fi + run_command chmod +x "$name" + run_command "./$name" --revision + run_command mkdir -p "$dir" + run_command mv "$name" "$dir/$name" + run_command zip -r "$dir.zip" "$dir" + source "$cwd/.buildkite/scripts/upload-artifact.sh" "$dir.zip" +done diff --git a/.buildkite/scripts/build-cpp.sh b/.buildkite/scripts/build-cpp.sh new file mode 100755 index 0000000000..f307918189 --- /dev/null +++ b/.buildkite/scripts/build-cpp.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +set -eo pipefail +source "$(dirname "$0")/env.sh" +source "$(realpath $(dirname "$0")/../../scripts/update-submodules.sh)" +{ set +x; } 2>/dev/null + +function run_command() { + set -x + "$@" + { set +x; } 2>/dev/null +} + +mkdir -p build +cd build +mkdir -p tmp_modules tmp_functions js codegen + +run_command cmake .. "${CMAKE_FLAGS[@]}" \ + -GNinja \ + -DBUN_CPP_ONLY="1" \ + -DNO_CONFIGURE_DEPENDS="1" \ + -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \ + -DCPU_TARGET="$CPU_TARGET" \ + -DUSE_LTO="$USE_LTO" \ + -DUSE_DEBUG_JSC="$USE_DEBUG_JSC" \ + -DCANARY="$CANARY" \ + -DGIT_SHA="$GIT_SHA" + +chmod +x compile-cpp-only.sh +source compile-cpp-only.sh -v -j "$CPUS" +{ set +x; } 2>/dev/null + +cd .. +source "$(dirname "$0")/upload-artifact.sh" "build/bun-cpp-objects.a" --split diff --git a/.buildkite/scripts/build-deps.ps1 b/.buildkite/scripts/build-deps.ps1 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/.buildkite/scripts/build-deps.sh b/.buildkite/scripts/build-deps.sh new file mode 100755 index 0000000000..e736fb43ff --- /dev/null +++ b/.buildkite/scripts/build-deps.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -eo pipefail +source "$(dirname "$0")/env.sh" +source "$(realpath $(dirname "$0")/../../scripts/all-dependencies.sh)" + +artifacts=( + libcrypto.a libssl.a libdecrepit.a + libcares.a + libarchive.a + liblolhtml.a + libmimalloc.a libmimalloc.o + libtcc.a + libz.a + libzstd.a + libdeflate.a + liblshpack.a +) + +for artifact in "${artifacts[@]}"; do + source "$(dirname "$0")/upload-artifact.sh" "build/bun-deps/$artifact" +done diff --git a/.buildkite/scripts/build-old-js.sh b/.buildkite/scripts/build-old-js.sh new file mode 100755 index 0000000000..92484aebe1 --- /dev/null +++ b/.buildkite/scripts/build-old-js.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +set -eo pipefail +source "$(dirname "$0")/env.sh" + +function assert_bun() { + if ! command -v bun &>/dev/null; then + echo "error: bun is not installed" 1>&2 + exit 1 + fi +} + +function assert_make() { + if ! command -v make &>/dev/null; then + echo "error: make is not installed" 1>&2 + exit 1 + fi +} + +function run_command() { + set -x + "$@" + { set +x; } 2>/dev/null +} + +function build_node_fallbacks() { + local cwd="src/node-fallbacks" + run_command bun install --cwd "$cwd" --frozen-lockfile + run_command bun run --cwd "$cwd" build +} + +function build_old_js() { + run_command bun install --frozen-lockfile + run_command make runtime_js fallback_decoder bun_error +} + +assert_bun +assert_make +build_node_fallbacks +build_old_js diff --git a/.buildkite/scripts/build-zig.sh b/.buildkite/scripts/build-zig.sh new file mode 100755 index 0000000000..e7a2614556 --- /dev/null +++ b/.buildkite/scripts/build-zig.sh @@ -0,0 +1,80 @@ +#!/bin/bash + +set -eo pipefail +source "$(dirname "$0")/env.sh" + +function assert_target() { + local arch="${2-$(uname -m)}" + case "$(echo "$arch" | tr '[:upper:]' '[:lower:]')" in + x64 | x86_64 | amd64) + export ZIG_ARCH="x86_64" + if [[ "$BUILDKITE_STEP_KEY" == *"baseline"* ]]; then + export ZIG_CPU_TARGET="nehalem" + else + export ZIG_CPU_TARGET="haswell" + fi + ;; + aarch64 | arm64) + export ZIG_ARCH="aarch64" + export ZIG_CPU_TARGET="native" + ;; + *) + echo "error: Unsupported architecture: $arch" 1>&2 + exit 1 + ;; + esac + local os="${1-$(uname -s)}" + case "$(echo "$os" | tr '[:upper:]' '[:lower:]')" in + linux) + export ZIG_TARGET="$ZIG_ARCH-linux-gnu" ;; + darwin) + export ZIG_TARGET="$ZIG_ARCH-macos-none" ;; + windows) + export ZIG_TARGET="$ZIG_ARCH-windows-msvc" ;; + *) + echo "error: Unsupported operating system: $os" 1>&2 + exit 1 + ;; + esac +} + +function run_command() { + set -x + "$@" + { set +x; } 2>/dev/null +} + +assert_target "$@" + +# Since the zig build depends on files from the zig submodule, +# make sure to update the submodule before building. +run_command git submodule update --init --recursive --progress --depth=1 --checkout src/deps/zig + +# TODO: Move these to be part of the CMake build +source "$(dirname "$0")/build-old-js.sh" + +cwd="$(pwd)" +mkdir -p build +cd build + +run_command cmake .. "${CMAKE_FLAGS[@]}" \ + -GNinja \ + -DNO_CONFIGURE_DEPENDS="1" \ + -DNO_CODEGEN="0" \ + -DWEBKIT_DIR="omit" \ + -DBUN_ZIG_OBJ_DIR="$cwd/build" \ + -DZIG_LIB_DIR="$cwd/src/deps/zig/lib" \ + -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \ + -DARCH="$ZIG_ARCH" \ + -DCPU_TARGET="$ZIG_CPU_TARGET" \ + -DZIG_TARGET="$ZIG_TARGET" \ + -DUSE_LTO="$USE_LTO" \ + -DUSE_DEBUG_JSC="$USE_DEBUG_JSC" \ + -DCANARY="$CANARY" \ + -DGIT_SHA="$GIT_SHA" + +export ONLY_ZIG="1" +run_command ninja "$cwd/build/bun-zig.o" -v -j "$CPUS" + +cd .. +source "$(dirname "$0")/upload-artifact.sh" "build/bun-zig.o" diff --git a/.buildkite/scripts/download-artifact.ps1 b/.buildkite/scripts/download-artifact.ps1 new file mode 100755 index 0000000000..0504474077 --- /dev/null +++ b/.buildkite/scripts/download-artifact.ps1 @@ -0,0 +1,47 @@ +param ( + [Parameter(Mandatory=$true)] + [string[]] $Paths, + [switch] $Split +) + +$ErrorActionPreference = "Stop" + +function Assert-Buildkite-Agent() { + if (-not (Get-Command "buildkite-agent" -ErrorAction SilentlyContinue)) { + Write-Error "Cannot find buildkite-agent, please install it: https://buildkite.com/docs/agent/v3/install" + exit 1 + } +} + +function Assert-Join-File() { + if (-not (Get-Command "Join-File" -ErrorAction SilentlyContinue)) { + Write-Error "Cannot find Join-File, please install it: https://www.powershellgallery.com/packages/FileSplitter/1.3" + exit 1 + } +} + +function Download-Buildkite-Artifact() { + param ( + [Parameter(Mandatory=$true)] + [string] $Path, + ) + if ($Split) { + & buildkite-agent artifact download "$Path.*" --debug --debug-http + Join-File -Path "$(Resolve-Path .)\$Path" -Verbose -DeletePartFiles + } else { + & buildkite-agent artifact download "$Path" --debug --debug-http + } + if (-not (Test-Path $Path)) { + Write-Error "Could not find artifact: $Path" + exit 1 + } +} + +Assert-Buildkite-Agent +if ($Split) { + Assert-Join-File +} + +foreach ($Path in $Paths) { + Download-Buildkite-Artifact $Path +} diff --git a/.buildkite/scripts/download-artifact.sh b/.buildkite/scripts/download-artifact.sh new file mode 100755 index 0000000000..5907561853 --- /dev/null +++ b/.buildkite/scripts/download-artifact.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +set -eo pipefail + +function assert_buildkite_agent() { + if ! command -v buildkite-agent &> /dev/null; then + echo "error: Cannot find buildkite-agent, please install it:" + echo "https://buildkite.com/docs/agent/v3/install" + exit 1 + fi +} + +function download_buildkite_artifact() { + local path="$1"; shift + local split="0" + local args=() + while true; do + if [ -z "$1" ]; then + break + fi + case "$1" in + --split) split="1"; shift ;; + *) args+=("$1"); shift ;; + esac + done + if [ "$split" == "1" ]; then + run_command buildkite-agent artifact download "$path.*" . "${args[@]}" + run_command cat $path.?? > "$path" + run_command rm -f $path.?? + else + run_command buildkite-agent artifact download "$path" . "${args[@]}" + fi + if [[ "$path" != *"*"* ]] && [ ! -f "$path" ]; then + echo "error: Could not find artifact: $path" + exit 1 + fi +} + +function run_command() { + set -x + "$@" + { set +x; } 2>/dev/null +} + +assert_buildkite_agent +download_buildkite_artifact "$@" diff --git a/.buildkite/scripts/env.sh b/.buildkite/scripts/env.sh new file mode 100755 index 0000000000..61b8382e35 --- /dev/null +++ b/.buildkite/scripts/env.sh @@ -0,0 +1,118 @@ +#!/bin/bash + +set -eo pipefail + +function assert_os() { + local os="$(uname -s)" + case "$os" in + Linux) + echo "linux" ;; + Darwin) + echo "darwin" ;; + *) + echo "error: Unsupported operating system: $os" 1>&2 + exit 1 + ;; + esac +} + +function assert_arch() { + local arch="$(uname -m)" + case "$arch" in + aarch64 | arm64) + echo "aarch64" ;; + x86_64 | amd64) + echo "x64" ;; + *) + echo "error: Unknown architecture: $arch" 1>&2 + exit 1 + ;; + esac +} + +function assert_build() { + if [ -z "$BUILDKITE_REPO" ]; then + echo "error: Cannot find repository for this build" + exit 1 + fi + if [ -z "$BUILDKITE_COMMIT" ]; then + echo "error: Cannot find commit for this build" + exit 1 + fi + if [ -z "$BUILDKITE_STEP_KEY" ]; then + echo "error: Cannot find step key for this build" + exit 1 + fi + if [ -n "$BUILDKITE_GROUP_KEY" ] && [[ "$BUILDKITE_STEP_KEY" != "$BUILDKITE_GROUP_KEY"* ]]; then + echo "error: Build step '$BUILDKITE_STEP_KEY' does not start with group key '$BUILDKITE_GROUP_KEY'" + exit 1 + fi + # Skip os and arch checks for Zig, since it's cross-compiled on macOS + if [[ "$BUILDKITE_STEP_KEY" != *"zig"* ]]; then + local os="$(assert_os)" + if [[ "$BUILDKITE_STEP_KEY" != *"$os"* ]]; then + echo "error: Build step '$BUILDKITE_STEP_KEY' does not match operating system '$os'" + exit 1 + fi + local arch="$(assert_arch)" + if [[ "$BUILDKITE_STEP_KEY" != *"$arch"* ]]; then + echo "error: Build step '$BUILDKITE_STEP_KEY' does not match architecture '$arch'" + exit 1 + fi + fi +} + +function assert_buildkite_agent() { + if ! command -v buildkite-agent &> /dev/null; then + echo "error: Cannot find buildkite-agent, please install it:" + echo "https://buildkite.com/docs/agent/v3/install" + exit 1 + fi +} + +function export_environment() { + source "$(realpath $(dirname "$0")/../../scripts/env.sh)" + { set +x; } 2>/dev/null + export GIT_SHA="$BUILDKITE_COMMIT" + export CCACHE_DIR="$HOME/.cache/ccache/$BUILDKITE_STEP_KEY" + export SCCACHE_DIR="$HOME/.cache/sccache/$BUILDKITE_STEP_KEY" + export ZIG_LOCAL_CACHE_DIR="$HOME/.cache/zig-cache/$BUILDKITE_STEP_KEY" + export BUN_DEPS_CACHE_DIR="$HOME/.cache/bun-deps/$BUILDKITE_STEP_KEY" + if [ "$(assert_arch)" == "aarch64" ]; then + export CPU_TARGET="native" + elif [[ "$BUILDKITE_STEP_KEY" == *"baseline"* ]]; then + export CPU_TARGET="nehalem" + else + export CPU_TARGET="haswell" + fi + if [[ "$BUILDKITE_STEP_KEY" == *"nolto"* ]]; then + export USE_LTO="OFF" + else + export USE_LTO="ON" + fi + if $(buildkite-agent meta-data exists release &> /dev/null); then + export CMAKE_BUILD_TYPE="$(buildkite-agent meta-data get release)" + else + export CMAKE_BUILD_TYPE="Release" + fi + if $(buildkite-agent meta-data exists canary &> /dev/null); then + export CANARY="$(buildkite-agent meta-data get canary)" + else + export CANARY="1" + fi + if $(buildkite-agent meta-data exists assertions &> /dev/null); then + export USE_DEBUG_JSC="$(buildkite-agent meta-data get assertions)" + else + export USE_DEBUG_JSC="OFF" + fi + if [ "$BUILDKITE_CLEAN_CHECKOUT" == "true" ]; then + rm -rf "$CCACHE_DIR" + rm -rf "$SCCACHE_DIR" + rm -rf "$ZIG_LOCAL_CACHE_DIR" + rm -rf "$BUN_DEPS_CACHE_DIR" + fi +} + +assert_build +assert_buildkite_agent +export_environment diff --git a/.buildkite/scripts/prepare-build.sh b/.buildkite/scripts/prepare-build.sh new file mode 100755 index 0000000000..faaa046811 --- /dev/null +++ b/.buildkite/scripts/prepare-build.sh @@ -0,0 +1,90 @@ +#!/bin/bash + +set -eo pipefail + +function assert_build() { + if [ -z "$BUILDKITE_REPO" ]; then + echo "error: Cannot find repository for this build" + exit 1 + fi + if [ -z "$BUILDKITE_COMMIT" ]; then + echo "error: Cannot find commit for this build" + exit 1 + fi +} + +function assert_buildkite_agent() { + if ! command -v buildkite-agent &> /dev/null; then + echo "error: Cannot find buildkite-agent, please install it:" + echo "https://buildkite.com/docs/agent/v3/install" + exit 1 + fi +} + +function assert_jq() { + assert_command "jq" "jq" "https://stedolan.github.io/jq/" +} + +function assert_curl() { + assert_command "curl" "curl" "https://curl.se/download.html" +} + +function assert_command() { + local command="$1" + local package="$2" + local help_url="$3" + if ! command -v "$command" &> /dev/null; then + echo "warning: $command is not installed, installing..." + if command -v brew &> /dev/null; then + HOMEBREW_NO_AUTO_UPDATE=1 brew install "$package" + else + echo "error: Cannot install $command, please install it" + if [ -n "$help_url" ]; then + echo "" + echo "hint: See $help_url for help" + fi + exit 1 + fi + fi +} + +function assert_canary() { + local canary="$(buildkite-agent meta-data get canary 2>/dev/null)" + if [ -z "$canary" ]; then + local repo=$(echo "$BUILDKITE_REPO" | sed -E 's#https://github.com/([^/]+)/([^/]+).git#\1/\2#g') + local tag="$(curl -sL "https://api.github.com/repos/$repo/releases/latest" | jq -r ".tag_name")" + if [ "$tag" == "null" ]; then + canary="1" + else + local revision=$(curl -sL "https://api.github.com/repos/$repo/compare/$tag...$BUILDKITE_COMMIT" | jq -r ".ahead_by") + if [ "$revision" == "null" ]; then + canary="1" + else + canary="$revision" + fi + fi + fi + run_command buildkite-agent meta-data set canary "$canary" +} + +function upload_buildkite_pipeline() { + local path="$1" + if [ ! -f "$path" ]; then + echo "error: Cannot find pipeline: $path" + exit 1 + fi + run_command buildkite-agent pipeline upload "$path" +} + +function run_command() { + set -x + "$@" + { set +x; } 2>/dev/null +} + +assert_build +assert_buildkite_agent +assert_jq +assert_curl +assert_canary +upload_buildkite_pipeline ".buildkite/ci.yml" diff --git a/.buildkite/scripts/upload-artifact.ps1 b/.buildkite/scripts/upload-artifact.ps1 new file mode 100755 index 0000000000..b7d79a410b --- /dev/null +++ b/.buildkite/scripts/upload-artifact.ps1 @@ -0,0 +1,47 @@ +param ( + [Parameter(Mandatory=$true)] + [string[]] $Paths, + [switch] $Split +) + +$ErrorActionPreference = "Stop" + +function Assert-Buildkite-Agent() { + if (-not (Get-Command "buildkite-agent" -ErrorAction SilentlyContinue)) { + Write-Error "Cannot find buildkite-agent, please install it: https://buildkite.com/docs/agent/v3/install" + exit 1 + } +} + +function Assert-Split-File() { + if (-not (Get-Command "Split-File" -ErrorAction SilentlyContinue)) { + Write-Error "Cannot find Split-File, please install it: https://www.powershellgallery.com/packages/FileSplitter/1.3" + exit 1 + } +} + +function Upload-Buildkite-Artifact() { + param ( + [Parameter(Mandatory=$true)] + [string] $Path, + ) + if (-not (Test-Path $Path)) { + Write-Error "Could not find artifact: $Path" + exit 1 + } + if ($Split) { + Remove-Item -Path "$Path.*" -Force + Split-File -Path (Resolve-Path $Path) -PartSizeBytes "50MB" -Verbose + $Path = "$Path.*" + } + & buildkite-agent artifact upload "$Path" --debug --debug-http +} + +Assert-Buildkite-Agent +if ($Split) { + Assert-Split-File +} + +foreach ($Path in $Paths) { + Upload-Buildkite-Artifact $Path +} diff --git a/.buildkite/scripts/upload-artifact.sh b/.buildkite/scripts/upload-artifact.sh new file mode 100755 index 0000000000..0284a93c79 --- /dev/null +++ b/.buildkite/scripts/upload-artifact.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +set -eo pipefail + +function assert_buildkite_agent() { + if ! command -v buildkite-agent &> /dev/null; then + echo "error: Cannot find buildkite-agent, please install it:" + echo "https://buildkite.com/docs/agent/v3/install" + exit 1 + fi +} + +function assert_split() { + if ! command -v split &> /dev/null; then + echo "error: Cannot find split, please install it:" + echo "https://www.gnu.org/software/coreutils/split" + exit 1 + fi +} + +function upload_buildkite_artifact() { + local path="$1"; shift + local split="0" + local args=() + while true; do + if [ -z "$1" ]; then + break + fi + case "$1" in + --split) split="1"; shift ;; + *) args+=("$1"); shift ;; + esac + done + if [ ! -f "$path" ]; then + echo "error: Could not find artifact: $path" + exit 1 + fi + if [ "$split" == "1" ]; then + run_command rm -f "$path."* + run_command split -b 50MB -d "$path" "$path." + run_command buildkite-agent artifact upload "$path.*" "${args[@]}" + else + run_command buildkite-agent artifact upload "$path" "${args[@]}" + fi +} + +function run_command() { + set -x + "$@" + { set +x; } 2>/dev/null +} + +assert_buildkite_agent +upload_buildkite_artifact "$@" diff --git a/.buildkite/scripts/upload-release.sh b/.buildkite/scripts/upload-release.sh index c1576bd620..b3d4c0a415 100755 --- a/.buildkite/scripts/upload-release.sh +++ b/.buildkite/scripts/upload-release.sh @@ -3,7 +3,15 @@ set -eo pipefail function assert_main() { - if [[ "$BUILDKITE_PULL_REQUEST_REPO" && "$BUILDKITE_REPO" != "$BUILDKITE_PULL_REQUEST_REPO" ]]; then + if [ -z "$BUILDKITE_REPO" ]; then + echo "error: Cannot find repository for this build" + exit 1 + fi + if [ -z "$BUILDKITE_COMMIT" ]; then + echo "error: Cannot find commit for this build" + exit 1 + fi + if [ -n "$BUILDKITE_PULL_REQUEST_REPO" ] && [ "$BUILDKITE_REPO" != "$BUILDKITE_PULL_REQUEST_REPO" ]; then echo "error: Cannot upload release from a fork" exit 1 fi @@ -25,70 +33,152 @@ function assert_buildkite_agent() { fi } -function assert_gh() { - if ! command -v gh &> /dev/null; then - echo "warning: gh is not installed, installing..." +function assert_github() { + assert_command "gh" "gh" "https://github.com/cli/cli#installation" + assert_buildkite_secret "GITHUB_TOKEN" + # gh expects the token in $GH_TOKEN + export GH_TOKEN="$GITHUB_TOKEN" +} + +function assert_aws() { + assert_command "aws" "awscli" "https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html" + for secret in AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_ENDPOINT AWS_BUCKET; do + assert_buildkite_secret "$secret" + done +} + +function assert_sentry() { + assert_command "sentry-cli" "getsentry/tools/sentry-cli" "https://docs.sentry.io/cli/installation/" + for secret in SENTRY_AUTH_TOKEN SENTRY_ORG SENTRY_PROJECT; do + assert_buildkite_secret "$secret" + done +} + +function run_command() { + set -x + "$@" + { set +x; } 2>/dev/null +} + +function assert_command() { + local command="$1" + local package="$2" + local help_url="$3" + if ! command -v "$command" &> /dev/null; then + echo "warning: $command is not installed, installing..." if command -v brew &> /dev/null; then - brew install gh + HOMEBREW_NO_AUTO_UPDATE=1 run_command brew install "$package" else - echo "error: Cannot install gh, please install it:" - echo "https://github.com/cli/cli#installation" + echo "error: Cannot install $command, please install it" + if [ -n "$help_url" ]; then + echo "" + echo "hint: See $help_url for help" + fi exit 1 fi fi } -function assert_gh_token() { - local token=$(buildkite-agent secret get GITHUB_TOKEN) - if [ -z "$token" ]; then - echo "error: Cannot find GITHUB_TOKEN secret" +function assert_buildkite_secret() { + local key="$1" + local value=$(buildkite-agent secret get "$key") + if [ -z "$value" ]; then + echo "error: Cannot find $key secret" echo "" - echo "hint: Create a secret named GITHUB_TOKEN with a GitHub access token:" + echo "hint: Create a secret named $key with a value:" echo "https://buildkite.com/docs/pipelines/buildkite-secrets" exit 1 fi - export GH_TOKEN="$token" + export "$key"="$value" } -function download_artifact() { - local name=$1 - buildkite-agent artifact download "$name" . - if [ ! -f "$name" ]; then - echo "error: Cannot find Buildkite artifact: $name" - exit 1 +function release_tag() { + local version="$1" + if [ "$version" == "canary" ]; then + echo "canary" + else + echo "bun-v$version" fi } -function upload_assets() { - local tag=$1 - local files=${@:2} - gh release upload "$tag" $files --clobber --repo "$BUILDKITE_REPO" +function create_sentry_release() { + local version="$1" + local release="$version" + if [ "$version" == "canary" ]; then + release="$BUILDKITE_COMMIT-canary" + fi + run_command sentry-cli releases new "$release" --finalize + run_command sentry-cli releases set-commits "$release" --auto --ignore-missing + if [ "$version" == "canary" ]; then + run_command sentry-cli deploys new --env="canary" --release="$release" + fi } -assert_main -assert_buildkite_agent -assert_gh -assert_gh_token +function download_buildkite_artifacts() { + local dir="$1" + local names="${@:2}" + for name in "${names[@]}"; do + run_command buildkite-agent artifact download "$name" "$dir" + if [ ! -f "$dir/$name" ]; then + echo "error: Cannot find Buildkite artifact: $name" + exit 1 + fi + done +} -declare artifacts=( - bun-darwin-aarch64.zip - bun-darwin-aarch64-profile.zip - bun-darwin-x64.zip - bun-darwin-x64-profile.zip - bun-linux-aarch64.zip - bun-linux-aarch64-profile.zip - bun-linux-x64.zip - bun-linux-x64-profile.zip - bun-linux-x64-baseline.zip - bun-linux-x64-baseline-profile.zip - bun-windows-x64.zip - bun-windows-x64-profile.zip - bun-windows-x64-baseline.zip - bun-windows-x64-baseline-profile.zip -) +function upload_github_assets() { + local version="$1" + local tag="$(release_tag "$version")" + local files="${@:2}" + for file in "${files[@]}"; do + run_command gh release upload "$tag" "$file" --clobber --repo "$BUILDKITE_REPO" + done + if [ "$version" == "canary" ]; then + run_command gh release edit "$tag" --repo "$BUILDKITE_REPO" \ + --notes "This canary release of Bun corresponds to the commit: $BUILDKITE_COMMIT" + fi +} -for artifact in "${artifacts[@]}"; do - download_artifact $artifact -done +function upload_s3_files() { + local folder="$1" + local files="${@:2}" + for file in "${files[@]}"; do + run_command aws --endpoint-url="$AWS_ENDPOINT" s3 cp "$file" "s3://$AWS_BUCKET/$folder/$file" + done +} -upload_assets "canary" "${artifacts[@]}" +function create_release() { + assert_main + assert_buildkite_agent + assert_github + assert_sentry + + local tag="$1" # 'canary' or 'x.y.z' + local artifacts=( + bun-darwin-aarch64.zip + bun-darwin-aarch64-profile.zip + bun-darwin-x64.zip + bun-darwin-x64-profile.zip + bun-linux-aarch64.zip + bun-linux-aarch64-profile.zip + bun-linux-x64.zip + bun-linux-x64-profile.zip + bun-linux-x64-baseline.zip + bun-linux-x64-baseline-profile.zip + bun-windows-x64.zip + bun-windows-x64-profile.zip + bun-windows-x64-baseline.zip + bun-windows-x64-baseline-profile.zip + ) + + for artifact in "${artifacts[@]}"; do + download_buildkite_artifact "$artifact" + done + + upload_github_assets "$tag" "${artifacts[@]}" + upload_s3_files "releases/$BUILDKITE_COMMIT" "${artifacts[@]}" + upload_s3_files "releases/$tag" "${artifacts[@]}" + create_sentry_release "$tag" +} + +create_release "canary" diff --git a/.github/workflows/build-darwin.yml b/.github/workflows/build-darwin.yml deleted file mode 100644 index b2bf1f12da..0000000000 --- a/.github/workflows/build-darwin.yml +++ /dev/null @@ -1,286 +0,0 @@ -name: Build Darwin - -permissions: - contents: read - actions: write - -on: - workflow_call: - inputs: - runs-on: - type: string - default: macos-13-large - tag: - type: string - required: true - arch: - type: string - required: true - cpu: - type: string - required: true - assertions: - type: boolean - canary: - type: boolean - no-cache: - type: boolean - -env: - LLVM_VERSION: 18 - BUN_VERSION: 1.1.8 - LC_CTYPE: "en_US.UTF-8" - LC_ALL: "en_US.UTF-8" - # LTO is disabled because we cannot use lld on macOS currently - BUN_ENABLE_LTO: "0" - -jobs: - build-submodules: - name: Build Submodules - runs-on: ${{ inputs.runs-on }} - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - sparse-checkout: | - .gitmodules - src/deps - scripts - - name: Hash Submodules - id: hash - run: | - print_versions() { - git submodule | grep -v WebKit - echo "LLVM_VERSION=${{ env.LLVM_VERSION }}" - cat $(echo scripts/build*.sh scripts/all-dependencies.sh | tr " " "\n" | sort) - } - echo "hash=$(print_versions | shasum)" >> $GITHUB_OUTPUT - - name: Install Dependencies - env: - HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1 - HOMEBREW_NO_AUTO_UPDATE: 1 - HOMEBREW_NO_INSTALL_CLEANUP: 1 - run: | - brew install \ - llvm@${{ env.LLVM_VERSION }} \ - ccache \ - rust \ - pkg-config \ - coreutils \ - libtool \ - cmake \ - libiconv \ - automake \ - openssl@1.1 \ - ninja \ - golang \ - gnu-sed --force --overwrite - echo "$(brew --prefix ccache)/bin" >> $GITHUB_PATH - echo "$(brew --prefix coreutils)/libexec/gnubin" >> $GITHUB_PATH - echo "$(brew --prefix llvm@$LLVM_VERSION)/bin" >> $GITHUB_PATH - brew link --overwrite llvm@$LLVM_VERSION - - name: Clone Submodules - run: | - ./scripts/update-submodules.sh - - name: Build Submodules - env: - CPU_TARGET: ${{ inputs.cpu }} - BUN_DEPS_OUT_DIR: ${{ runner.temp }}/bun-deps - run: | - mkdir -p $BUN_DEPS_OUT_DIR - ./scripts/all-dependencies.sh - - name: Upload bun-${{ inputs.tag }}-deps - uses: actions/upload-artifact@v4 - with: - name: bun-${{ inputs.tag }}-deps - path: ${{ runner.temp }}/bun-deps - if-no-files-found: error - build-cpp: - name: Build C++ - runs-on: ${{ inputs.runs-on }} - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: recursive - # TODO: Figure out how to cache homebrew dependencies - - name: Install Dependencies - env: - HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1 - HOMEBREW_NO_AUTO_UPDATE: 1 - HOMEBREW_NO_INSTALL_CLEANUP: 1 - run: | - brew install \ - llvm@${{ env.LLVM_VERSION }} \ - ccache \ - rust \ - pkg-config \ - coreutils \ - libtool \ - cmake \ - libiconv \ - automake \ - openssl@1.1 \ - ninja \ - golang \ - gnu-sed --force --overwrite - echo "$(brew --prefix ccache)/bin" >> $GITHUB_PATH - echo "$(brew --prefix coreutils)/libexec/gnubin" >> $GITHUB_PATH - echo "$(brew --prefix llvm@$LLVM_VERSION)/bin" >> $GITHUB_PATH - brew link --overwrite llvm@$LLVM_VERSION - - name: Setup Bun - uses: ./.github/actions/setup-bun - with: - bun-version: ${{ env.BUN_VERSION }} - - name: Compile - env: - CPU_TARGET: ${{ inputs.cpu }} - SOURCE_DIR: ${{ github.workspace }} - OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj - BUN_DEPS_OUT_DIR: ${{ runner.temp }}/bun-deps - CCACHE_DIR: ${{ runner.temp }}/ccache - run: | - mkdir -p $OBJ_DIR - cd $OBJ_DIR - cmake -S $SOURCE_DIR -B $OBJ_DIR \ - -G Ninja \ - -DCMAKE_BUILD_TYPE=Release \ - -DUSE_LTO=ON \ - -DBUN_CPP_ONLY=1 \ - -DNO_CONFIGURE_DEPENDS=1 - chmod +x compile-cpp-only.sh - ./compile-cpp-only.sh -v - - name: Upload bun-${{ inputs.tag }}-cpp - uses: actions/upload-artifact@v4 - with: - name: bun-${{ inputs.tag }}-cpp - path: ${{ runner.temp }}/bun-cpp-obj/bun-cpp-objects.a - if-no-files-found: error - build-zig: - name: Build Zig - uses: ./.github/workflows/build-zig.yml - with: - os: darwin - only-zig: true - tag: ${{ inputs.tag }} - arch: ${{ inputs.arch }} - cpu: ${{ inputs.cpu }} - assertions: ${{ inputs.assertions }} - canary: ${{ inputs.canary }} - no-cache: ${{ inputs.no-cache }} - link: - name: Link - runs-on: ${{ inputs.runs-on }} - needs: - - build-submodules - - build-cpp - - build-zig - steps: - - uses: actions/checkout@v4 - # TODO: Figure out how to cache homebrew dependencies - - name: Install Dependencies - env: - HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1 - HOMEBREW_NO_AUTO_UPDATE: 1 - HOMEBREW_NO_INSTALL_CLEANUP: 1 - run: | - brew install \ - llvm@${{ env.LLVM_VERSION }} \ - ccache \ - rust \ - pkg-config \ - coreutils \ - libtool \ - cmake \ - libiconv \ - automake \ - openssl@1.1 \ - ninja \ - golang \ - gnu-sed --force --overwrite - echo "$(brew --prefix ccache)/bin" >> $GITHUB_PATH - echo "$(brew --prefix coreutils)/libexec/gnubin" >> $GITHUB_PATH - echo "$(brew --prefix llvm@$LLVM_VERSION)/bin" >> $GITHUB_PATH - brew link --overwrite llvm@$LLVM_VERSION - - name: Setup Bun - uses: ./.github/actions/setup-bun - with: - bun-version: ${{ env.BUN_VERSION }} - - name: Download bun-${{ inputs.tag }}-deps - uses: actions/download-artifact@v4 - with: - name: bun-${{ inputs.tag }}-deps - path: ${{ runner.temp }}/bun-deps - - name: Download bun-${{ inputs.tag }}-cpp - uses: actions/download-artifact@v4 - with: - name: bun-${{ inputs.tag }}-cpp - path: ${{ runner.temp }}/bun-cpp-obj - - name: Download bun-${{ inputs.tag }}-zig - uses: actions/download-artifact@v4 - with: - name: bun-${{ inputs.tag }}-zig - path: ${{ runner.temp }}/release - - name: Link - env: - CPU_TARGET: ${{ inputs.cpu }} - run: | - SRC_DIR=$PWD - mkdir ${{ runner.temp }}/link-build - cd ${{ runner.temp }}/link-build - cmake $SRC_DIR \ - -G Ninja \ - -DCMAKE_BUILD_TYPE=Release \ - -DUSE_LTO=ON \ - -DBUN_LINK_ONLY=1 \ - -DBUN_ZIG_OBJ_DIR="${{ runner.temp }}/release" \ - -DBUN_CPP_ARCHIVE="${{ runner.temp }}/bun-cpp-obj/bun-cpp-objects.a" \ - -DBUN_DEPS_OUT_DIR="${{ runner.temp }}/bun-deps" \ - -DNO_CONFIGURE_DEPENDS=1 - ninja -v - - name: Prepare - run: | - cd ${{ runner.temp }}/link-build - chmod +x bun-profile bun - mkdir -p bun-${{ inputs.tag }}-profile/ bun-${{ inputs.tag }}/ - mv bun-profile bun-${{ inputs.tag }}-profile/bun-profile - if [ -f bun-profile.dSYM || -d bun-profile.dSYM ]; then - mv bun-profile.dSYM bun-${{ inputs.tag }}-profile/bun-profile.dSYM - fi - if [ -f bun.dSYM || -d bun.dSYM ]; then - mv bun.dSYM bun-${{ inputs.tag }}-profile/bun-profile.dSYM - fi - mv bun bun-${{ inputs.tag }}/bun - zip -r bun-${{ inputs.tag }}-profile.zip bun-${{ inputs.tag }}-profile - zip -r bun-${{ inputs.tag }}.zip bun-${{ inputs.tag }} - - name: Upload bun-${{ inputs.tag }} - uses: actions/upload-artifact@v4 - with: - name: bun-${{ inputs.tag }} - path: ${{ runner.temp }}/link-build/bun-${{ inputs.tag }}.zip - if-no-files-found: error - - name: Upload bun-${{ inputs.tag }}-profile - uses: actions/upload-artifact@v4 - with: - name: bun-${{ inputs.tag }}-profile - path: ${{ runner.temp }}/link-build/bun-${{ inputs.tag }}-profile.zip - if-no-files-found: error - on-failure: - if: ${{ github.repository_owner == 'oven-sh' && failure() }} - name: On Failure - needs: link - runs-on: ubuntu-latest - steps: - - name: Send Message - uses: sarisia/actions-status-discord@v1 - with: - webhook: ${{ secrets.DISCORD_WEBHOOK }} - nodetail: true - color: "#FF0000" - title: "" - description: | - ### ❌ [${{ github.event.pull_request.title }}](${{ github.event.pull_request.html_url }}) - - @${{ github.actor }}, the build for bun-${{ inputs.tag }} failed. - - **[View logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})** diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml deleted file mode 100644 index c1bde9271c..0000000000 --- a/.github/workflows/build-linux.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: Build Linux - -permissions: - contents: read - actions: write - -on: - workflow_call: - inputs: - runs-on: - type: string - required: true - tag: - type: string - required: true - arch: - type: string - required: true - cpu: - type: string - required: true - assertions: - type: boolean - zig-optimize: - type: string - canary: - type: boolean - no-cache: - type: boolean - -jobs: - build: - name: Build Linux - uses: ./.github/workflows/build-zig.yml - with: - os: linux - only-zig: false - runs-on: ${{ inputs.runs-on }} - tag: ${{ inputs.tag }} - arch: ${{ inputs.arch }} - cpu: ${{ inputs.cpu }} - assertions: ${{ inputs.assertions }} - zig-optimize: ${{ inputs.zig-optimize }} - canary: ${{ inputs.canary }} - no-cache: ${{ inputs.no-cache }} - on-failure: - if: ${{ github.repository_owner == 'oven-sh' && failure() }} - name: On Failure - needs: build - runs-on: ubuntu-latest - steps: - - name: Send Message - uses: sarisia/actions-status-discord@v1 - with: - webhook: ${{ secrets.DISCORD_WEBHOOK }} - nodetail: true - color: "#FF0000" - title: "" - description: | - ### ❌ [${{ github.event.pull_request.title }}](${{ github.event.pull_request.html_url }}) - - @${{ github.actor }}, the build for bun-${{ inputs.tag }} failed. - - **[View logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})** diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml deleted file mode 100644 index 3585a77f6b..0000000000 --- a/.github/workflows/build-windows.yml +++ /dev/null @@ -1,348 +0,0 @@ -name: Build Windows - -permissions: - contents: read - actions: write - -on: - workflow_call: - inputs: - runs-on: - type: string - default: windows - tag: - type: string - required: true - arch: - type: string - required: true - cpu: - type: string - required: true - assertions: - type: boolean - canary: - type: boolean - no-cache: - type: boolean - bun-version: - type: string - default: 1.1.7 - -env: - # Must specify exact version of LLVM for Windows - LLVM_VERSION: 18.1.8 - BUN_VERSION: ${{ inputs.bun-version }} - BUN_GARBAGE_COLLECTOR_LEVEL: 1 - BUN_FEATURE_FLAG_INTERNAL_FOR_TESTING: 1 - CI: true - USE_LTO: 1 - -jobs: - build-submodules: - name: Build Submodules - runs-on: ${{ inputs.runs-on }} - steps: - - name: Install Scoop - run: | - Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser - Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression - Join-Path (Resolve-Path ~).Path "scoop\shims" >> $Env:GITHUB_PATH - - name: Setup Git - run: | - git config --global core.autocrlf false - git config --global core.eol lf - - name: Checkout - uses: actions/checkout@v4 - with: - sparse-checkout: | - .gitmodules - src/deps - scripts - - name: Hash Submodules - id: hash - run: | - $data = "$(& { - git submodule | Where-Object { $_ -notmatch 'WebKit' } - echo "LLVM_VERSION=${{ env.LLVM_VERSION }}" - Get-Content -Path (Get-ChildItem -Path 'scripts/build*.ps1', 'scripts/all-dependencies.ps1', 'scripts/env.ps1' | Sort-Object -Property Name).FullName | Out-String - echo 1 - })" - $hash = ( -join ((New-Object -TypeName System.Security.Cryptography.SHA1CryptoServiceProvider).ComputeHash([System.Text.Encoding]::UTF8.GetBytes($data)) | ForEach-Object { $_.ToString("x2") } )).Substring(0, 10) - echo "hash=${hash}" >> $env:GITHUB_OUTPUT - - if: ${{ !inputs.no-cache }} - name: Restore Cache - id: cache - uses: actions/cache/restore@v4 - with: - path: bun-deps - key: bun-${{ inputs.tag }}-deps-${{ steps.hash.outputs.hash }} - - if: ${{ inputs.no-cache || !steps.cache.outputs.cache-hit }} - name: Install LLVM and Ninja - run: | - scoop install ninja - scoop install llvm@${{ env.LLVM_VERSION }} - scoop install nasm@2.16.01 - - if: ${{ inputs.no-cache || !steps.cache.outputs.cache-hit }} - name: Clone Submodules - run: | - .\scripts\update-submodules.ps1 - - if: ${{ inputs.no-cache || !steps.cache.outputs.cache-hit }} - name: Build Dependencies - env: - CPU_TARGET: ${{ inputs.cpu }} - CCACHE_DIR: ccache - USE_LTO: 1 - run: | - .\scripts\env.ps1 ${{ contains(inputs.tag, '-baseline') && '-Baseline' || '' }} - $env:BUN_DEPS_OUT_DIR = (mkdir -Force "./bun-deps") - .\scripts\all-dependencies.ps1 - - name: Save Cache - if: ${{ inputs.no-cache || !steps.cache.outputs.cache-hit }} - uses: actions/cache/save@v4 - with: - path: bun-deps - key: ${{ steps.cache.outputs.cache-primary-key }} - - name: Upload bun-${{ inputs.tag }}-deps - uses: actions/upload-artifact@v4 - with: - name: bun-${{ inputs.tag }}-deps - path: bun-deps - if-no-files-found: error - codegen: - name: Codegen - runs-on: ubuntu-latest - steps: - - name: Setup Git - run: | - git config --global core.autocrlf false - git config --global core.eol lf - - name: Checkout - uses: actions/checkout@v4 - - name: Setup Bun - uses: ./.github/actions/setup-bun - with: - bun-version: ${{ inputs.bun-version }} - - name: Codegen - run: | - ./scripts/cross-compile-codegen.sh win32 x64 - - if: ${{ inputs.canary }} - name: Calculate Revision - run: | - echo "canary_revision=$(GITHUB_TOKEN="${{ github.token }}" - bash ./scripts/calculate-canary-revision.sh --raw)" > build-codegen-win32-x64/.canary_revision - - name: Upload bun-${{ inputs.tag }}-codegen - uses: actions/upload-artifact@v4 - with: - name: bun-${{ inputs.tag }}-codegen - path: build-codegen-win32-x64 - if-no-files-found: error - build-cpp: - name: Build C++ - needs: codegen - runs-on: ${{ inputs.runs-on }} - steps: - - name: Install Scoop - run: | - Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser - Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression - Join-Path (Resolve-Path ~).Path "scoop\shims" >> $Env:GITHUB_PATH - - name: Setup Git - run: | - git config --global core.autocrlf false - git config --global core.eol lf - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: recursive - - name: Install LLVM and Ninja - run: | - scoop install ninja - scoop install llvm@${{ env.LLVM_VERSION }} - - name: Setup Bun - uses: ./.github/actions/setup-bun - with: - bun-version: ${{ inputs.bun-version }} - - if: ${{ !inputs.no-cache }} - name: Restore Cache - uses: actions/cache@v4 - with: - path: ccache - key: bun-${{ inputs.tag }}-cpp-${{ hashFiles('Dockerfile', 'Makefile', 'CMakeLists.txt', 'build.zig', 'scripts/**', 'src/**', 'packages/bun-usockets/src/**', 'packages/bun-uws/src/**') }} - restore-keys: | - bun-${{ inputs.tag }}-cpp- - - name: Download bun-${{ inputs.tag }}-codegen - uses: actions/download-artifact@v4 - with: - name: bun-${{ inputs.tag }}-codegen - path: build - - name: Compile - env: - CPU_TARGET: ${{ inputs.cpu }} - CCACHE_DIR: ccache - USE_LTO: 1 - run: | - # $CANARY_REVISION = if (Test-Path build/.canary_revision) { Get-Content build/.canary_revision } else { "0" } - $CANARY_REVISION = 0 - .\scripts\env.ps1 ${{ contains(inputs.tag, '-baseline') && '-Baseline' || '' }} - .\scripts\update-submodules.ps1 - .\scripts\build-libuv.ps1 -CloneOnly $True - cd build - cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release ` - -DNO_CODEGEN=1 ` - -DUSE_LTO=1 ` - -DNO_CONFIGURE_DEPENDS=1 ` - "-DCANARY=${CANARY_REVISION}" ` - -DBUN_CPP_ONLY=1 ${{ contains(inputs.tag, '-baseline') && '-DUSE_BASELINE_BUILD=1' || '' }} - if ($LASTEXITCODE -ne 0) { throw "CMake configuration failed" } - .\compile-cpp-only.ps1 -v - if ($LASTEXITCODE -ne 0) { throw "C++ compilation failed" } - - name: Upload bun-${{ inputs.tag }}-cpp - uses: actions/upload-artifact@v4 - with: - name: bun-${{ inputs.tag }}-cpp - path: build/bun-cpp-objects.a - if-no-files-found: error - build-zig: - name: Build Zig - uses: ./.github/workflows/build-zig.yml - with: - os: windows - zig-optimize: ReleaseSafe - only-zig: true - tag: ${{ inputs.tag }} - arch: ${{ inputs.arch }} - cpu: ${{ inputs.cpu }} - assertions: ${{ inputs.assertions }} - canary: ${{ inputs.canary }} - no-cache: ${{ inputs.no-cache }} - link: - name: Link - runs-on: ${{ inputs.runs-on }} - needs: - - build-submodules - - build-cpp - - build-zig - - codegen - steps: - - name: Install Scoop - run: | - Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser - Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression - Join-Path (Resolve-Path ~).Path "scoop\shims" >> $Env:GITHUB_PATH - - name: Setup Git - run: | - git config --global core.autocrlf false - git config --global core.eol lf - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: recursive - - name: Install Ninja - run: | - scoop install ninja - scoop install llvm@${{ env.LLVM_VERSION }} - - name: Setup Bun - uses: ./.github/actions/setup-bun - with: - bun-version: ${{ inputs.bun-version }} - - name: Download bun-${{ inputs.tag }}-deps - uses: actions/download-artifact@v4 - with: - name: bun-${{ inputs.tag }}-deps - path: bun-deps - - name: Download bun-${{ inputs.tag }}-cpp - uses: actions/download-artifact@v4 - with: - name: bun-${{ inputs.tag }}-cpp - path: bun-cpp - - name: Download bun-${{ inputs.tag }}-zig - uses: actions/download-artifact@v4 - with: - name: bun-${{ inputs.tag }}-zig - path: bun-zig - - name: Download bun-${{ inputs.tag }}-codegen - uses: actions/download-artifact@v4 - with: - name: bun-${{ inputs.tag }}-codegen - path: build - - if: ${{ !inputs.no-cache }} - name: Restore Cache - uses: actions/cache@v4 - with: - path: ccache - key: bun-${{ inputs.tag }}-cpp-${{ hashFiles('Dockerfile', 'Makefile', 'CMakeLists.txt', 'build.zig', 'scripts/**', 'src/**', 'packages/bun-usockets/src/**', 'packages/bun-uws/src/**') }} - restore-keys: | - bun-${{ inputs.tag }}-cpp- - - name: Link - env: - CPU_TARGET: ${{ inputs.cpu }} - CCACHE_DIR: ccache - run: | - .\scripts\update-submodules.ps1 - .\scripts\env.ps1 ${{ contains(inputs.tag, '-baseline') && '-Baseline' || '' }} - Set-Location build - # $CANARY_REVISION = if (Test-Path build/.canary_revision) { Get-Content build/.canary_revision } else { "0" } - $CANARY_REVISION = 0 - cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release ` - -DNO_CODEGEN=1 ` - -DNO_CONFIGURE_DEPENDS=1 ` - "-DCANARY=${CANARY_REVISION}" ` - -DBUN_LINK_ONLY=1 ` - -DUSE_LTO=1 ` - "-DBUN_DEPS_OUT_DIR=$(Resolve-Path ../bun-deps)" ` - "-DBUN_CPP_ARCHIVE=$(Resolve-Path ../bun-cpp/bun-cpp-objects.a)" ` - "-DBUN_ZIG_OBJ_DIR=$(Resolve-Path ../bun-zig)" ` - ${{ contains(inputs.tag, '-baseline') && '-DUSE_BASELINE_BUILD=1' || '' }} - if ($LASTEXITCODE -ne 0) { throw "CMake configuration failed" } - ninja -v - if ($LASTEXITCODE -ne 0) { throw "Link failed!" } - - name: Prepare - run: | - $Dist = mkdir -Force "bun-${{ inputs.tag }}" - cp -r build\bun.exe "$Dist\bun.exe" - Compress-Archive -Force "$Dist" "${Dist}.zip" - $Dist = "$Dist-profile" - MkDir -Force "$Dist" - cp -r build\bun.exe "$Dist\bun.exe" - cp -r build\bun.pdb "$Dist\bun.pdb" - Compress-Archive -Force "$Dist" "$Dist.zip" - .\build\bun.exe --print "JSON.stringify(require('bun:internal-for-testing').crash_handler.getFeatureData())" > .\features.json - - name: Upload bun-${{ inputs.tag }} - uses: actions/upload-artifact@v4 - with: - name: bun-${{ inputs.tag }} - path: bun-${{ inputs.tag }}.zip - if-no-files-found: error - - name: Upload bun-${{ inputs.tag }}-profile - uses: actions/upload-artifact@v4 - with: - name: bun-${{ inputs.tag }}-profile - path: bun-${{ inputs.tag }}-profile.zip - if-no-files-found: error - - name: Upload bun-feature-data - uses: actions/upload-artifact@v4 - with: - name: bun-feature-data - path: features.json - if-no-files-found: error - overwrite: true - on-failure: - if: ${{ github.repository_owner == 'oven-sh' && failure() }} - name: On Failure - needs: link - runs-on: ubuntu-latest - steps: - - name: Send Message - uses: sarisia/actions-status-discord@v1 - with: - webhook: ${{ secrets.DISCORD_WEBHOOK }} - nodetail: true - color: "#FF0000" - title: "" - description: | - ### ❌ [${{ github.event.pull_request.title }}](${{ github.event.pull_request.html_url }}) - - @${{ github.actor }}, the build for bun-${{ inputs.tag }} failed. - - **[View logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})** diff --git a/.github/workflows/build-zig.yml b/.github/workflows/build-zig.yml deleted file mode 100644 index eaea6bc1ef..0000000000 --- a/.github/workflows/build-zig.yml +++ /dev/null @@ -1,122 +0,0 @@ -name: Build Zig - -permissions: - contents: read - actions: write - -on: - workflow_call: - inputs: - runs-on: - type: string - default: ${{ github.repository_owner != 'oven-sh' && 'ubuntu-latest' || inputs.only-zig && 'namespace-profile-bun-ci-linux-x64' || inputs.arch == 'x64' && 'namespace-profile-bun-ci-linux-x64' || 'namespace-profile-bun-ci-linux-aarch64' }} - tag: - type: string - required: true - os: - type: string - required: true - arch: - type: string - required: true - cpu: - type: string - required: true - assertions: - type: boolean - default: false - zig-optimize: - type: string # 'ReleaseSafe' or 'ReleaseFast' - default: ReleaseFast - canary: - type: boolean - default: ${{ github.ref == 'refs/heads/main' }} - only-zig: - type: boolean - default: true - no-cache: - type: boolean - default: false - -jobs: - build-zig: - name: ${{ inputs.only-zig && 'Build Zig' || 'Build & Link' }} - runs-on: ${{ inputs.runs-on }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Calculate Cache Key - id: cache - run: | - echo "key=${{ hashFiles('Dockerfile', 'Makefile', 'CMakeLists.txt', 'build.zig', 'scripts/**', 'src/**', 'packages/bun-usockets/src/**', 'packages/bun-uws/src/**') }}-canary-${{inputs.canary}}" >> $GITHUB_OUTPUT - - if: ${{ !inputs.no-cache }} - name: Restore Cache - uses: actions/cache@v4 - with: - key: bun-${{ inputs.tag }}-docker-${{ steps.cache.outputs.key }} - restore-keys: | - bun-${{ inputs.tag }}-docker- - path: | - ${{ runner.temp }}/dockercache - - name: Setup Docker - uses: docker/setup-buildx-action@v3 - with: - install: true - platforms: | - linux/${{ runner.arch == 'X64' && 'amd64' || 'arm64' }} - - name: Build - uses: docker/build-push-action@v5 - with: - push: false - target: ${{ inputs.only-zig && 'build_release_obj' || 'artifact' }} - cache-from: | - type=local,src=${{ runner.temp }}/dockercache - cache-to: | - type=local,dest=${{ runner.temp }}/dockercache,mode=max - outputs: | - type=local,dest=${{ runner.temp }}/release - platforms: | - linux/${{ runner.arch == 'X64' && 'amd64' || 'arm64' }} - build-args: | - GIT_SHA=${{ github.event.workflow_run.head_sha || github.sha }} - TRIPLET=${{ inputs.os == 'darwin' && format('{0}-macos-none', inputs.arch == 'x64' && 'x86_64' || 'aarch64') || inputs.os == 'windows' && format('{0}-windows-msvc', inputs.arch == 'x64' && 'x86_64' || 'aarch64') || format('{0}-linux-gnu', inputs.arch == 'x64' && 'x86_64' || 'aarch64') }} - ARCH=${{ inputs.arch == 'x64' && 'x86_64' || 'aarch64' }} - BUILDARCH=${{ inputs.arch == 'x64' && 'amd64' || 'arm64' }} - BUILD_MACHINE_ARCH=${{ inputs.arch == 'x64' && 'x86_64' || 'aarch64' }} - CPU_TARGET=${{ inputs.arch == 'x64' && inputs.cpu || 'native' }} - ASSERTIONS=${{ inputs.assertions && 'ON' || 'OFF' }} - ZIG_OPTIMIZE=${{ inputs.zig-optimize }} - CANARY=${{ inputs.canary && '1' || '0' }} - - if: ${{ inputs.only-zig }} - name: Upload bun-${{ inputs.tag }}-zig - uses: actions/upload-artifact@v4 - with: - name: bun-${{ inputs.tag }}-zig - path: ${{ runner.temp }}/release/bun-zig.o - if-no-files-found: error - - if: ${{ !inputs.only-zig }} - name: Prepare - run: | - cd ${{ runner.temp }}/release - chmod +x bun-profile bun - mkdir bun-${{ inputs.tag }}-profile - mkdir bun-${{ inputs.tag }} - strip bun - mv bun-profile bun-${{ inputs.tag }}-profile/bun-profile - mv bun bun-${{ inputs.tag }}/bun - zip -r bun-${{ inputs.tag }}-profile.zip bun-${{ inputs.tag }}-profile - zip -r bun-${{ inputs.tag }}.zip bun-${{ inputs.tag }} - - if: ${{ !inputs.only-zig }} - name: Upload bun-${{ inputs.tag }} - uses: actions/upload-artifact@v4 - with: - name: bun-${{ inputs.tag }} - path: ${{ runner.temp }}/release/bun-${{ inputs.tag }}.zip - if-no-files-found: error - - if: ${{ !inputs.only-zig }} - name: Upload bun-${{ inputs.tag }}-profile - uses: actions/upload-artifact@v4 - with: - name: bun-${{ inputs.tag }}-profile - path: ${{ runner.temp }}/release/bun-${{ inputs.tag }}-profile.zip - if-no-files-found: error diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 203190c58f..0000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,245 +0,0 @@ -name: CI - -permissions: - contents: read - actions: write - -concurrency: - group: ${{ github.workflow }}-${{ github.event_name == 'workflow_dispatch' && inputs.run-id || github.ref }} - cancel-in-progress: true - -on: - workflow_dispatch: - inputs: - run-id: - type: string - description: The workflow ID to download artifacts (skips the build step) - pull_request: - paths-ignore: - - .vscode/**/* - - docs/**/* - - examples/**/* - push: - branches: - - main - paths-ignore: - - .vscode/**/* - - docs/**/* - - examples/**/* - -jobs: - format: - if: ${{ !inputs.run-id }} - name: Format - uses: ./.github/workflows/run-format.yml - secrets: inherit - with: - zig-version: 0.13.0 - permissions: - contents: write - lint: - if: ${{ !inputs.run-id }} - name: Lint - uses: ./.github/workflows/run-lint.yml - secrets: inherit - linux-x64: - if: ${{ !inputs.run-id }} - name: Build linux-x64 - uses: ./.github/workflows/build-linux.yml - secrets: inherit - with: - runs-on: ${{ github.repository_owner == 'oven-sh' && 'namespace-profile-bun-ci-linux-x64' || 'ubuntu-latest' }} - tag: linux-x64 - arch: x64 - cpu: haswell - canary: true - no-cache: true - linux-x64-baseline: - if: ${{ !inputs.run-id }} - name: Build linux-x64-baseline - uses: ./.github/workflows/build-linux.yml - secrets: inherit - with: - runs-on: ${{ github.repository_owner == 'oven-sh' && 'namespace-profile-bun-ci-linux-x64' || 'ubuntu-latest' }} - tag: linux-x64-baseline - arch: x64 - cpu: nehalem - canary: true - no-cache: true - linux-aarch64: - if: ${{ !inputs.run-id && github.repository_owner == 'oven-sh' }} - name: Build linux-aarch64 - uses: ./.github/workflows/build-linux.yml - secrets: inherit - with: - runs-on: namespace-profile-bun-ci-linux-aarch64 - tag: linux-aarch64 - arch: aarch64 - cpu: native - canary: true - no-cache: true - darwin-x64: - if: ${{ !inputs.run-id }} - name: Build darwin-x64 - uses: ./.github/workflows/build-darwin.yml - secrets: inherit - with: - runs-on: ${{ github.repository_owner == 'oven-sh' && 'macos-13-large' || 'macos-13' }} - tag: darwin-x64 - arch: x64 - cpu: haswell - canary: true - darwin-x64-baseline: - if: ${{ !inputs.run-id }} - name: Build darwin-x64-baseline - uses: ./.github/workflows/build-darwin.yml - secrets: inherit - with: - runs-on: ${{ github.repository_owner == 'oven-sh' && 'macos-13-large' || 'macos-13' }} - tag: darwin-x64-baseline - arch: x64 - cpu: nehalem - canary: true - darwin-aarch64: - if: ${{ !inputs.run-id }} - name: Build darwin-aarch64 - uses: ./.github/workflows/build-darwin.yml - secrets: inherit - with: - runs-on: ${{ github.repository_owner == 'oven-sh' && 'namespace-profile-bun-ci-darwin-aarch64' || 'macos-13' }} - tag: darwin-aarch64 - arch: aarch64 - cpu: native - canary: true - windows-x64: - if: ${{ !inputs.run-id }} - name: Build windows-x64 - uses: ./.github/workflows/build-windows.yml - secrets: inherit - with: - runs-on: windows - tag: windows-x64 - arch: x64 - cpu: haswell - canary: true - windows-x64-baseline: - if: ${{ !inputs.run-id }} - name: Build windows-x64-baseline - uses: ./.github/workflows/build-windows.yml - secrets: inherit - with: - runs-on: windows - tag: windows-x64-baseline - arch: x64 - cpu: nehalem - canary: true - linux-x64-test: - if: ${{ inputs.run-id || github.event_name == 'pull_request' }} - name: Test linux-x64 - needs: linux-x64 - uses: ./.github/workflows/run-test.yml - secrets: inherit - with: - run-id: ${{ inputs.run-id }} - pr-number: ${{ github.event.number }} - runs-on: ${{ github.repository_owner == 'oven-sh' && 'namespace-profile-bun-ci-linux-x64' || 'ubuntu-latest' }} - tag: linux-x64 - linux-x64-baseline-test: - if: ${{ inputs.run-id || github.event_name == 'pull_request' }} - name: Test linux-x64-baseline - needs: linux-x64-baseline - uses: ./.github/workflows/run-test.yml - secrets: inherit - with: - run-id: ${{ inputs.run-id }} - pr-number: ${{ github.event.number }} - runs-on: ${{ github.repository_owner == 'oven-sh' && 'namespace-profile-bun-ci-linux-x64' || 'ubuntu-latest' }} - tag: linux-x64-baseline - linux-aarch64-test: - if: ${{ inputs.run-id || github.event_name == 'pull_request' && github.repository_owner == 'oven-sh'}} - name: Test linux-aarch64 - needs: linux-aarch64 - uses: ./.github/workflows/run-test.yml - secrets: inherit - with: - run-id: ${{ inputs.run-id }} - pr-number: ${{ github.event.number }} - runs-on: namespace-profile-bun-ci-linux-aarch64 - tag: linux-aarch64 - darwin-x64-test: - if: ${{ inputs.run-id || github.event_name == 'pull_request' }} - name: Test darwin-x64 - needs: darwin-x64 - uses: ./.github/workflows/run-test.yml - secrets: inherit - with: - run-id: ${{ inputs.run-id }} - pr-number: ${{ github.event.number }} - runs-on: ${{ github.repository_owner == 'oven-sh' && 'macos-13-large' || 'macos-13' }} - tag: darwin-x64 - darwin-x64-baseline-test: - if: ${{ inputs.run-id || github.event_name == 'pull_request' }} - name: Test darwin-x64-baseline - needs: darwin-x64-baseline - uses: ./.github/workflows/run-test.yml - secrets: inherit - with: - run-id: ${{ inputs.run-id }} - pr-number: ${{ github.event.number }} - runs-on: ${{ github.repository_owner == 'oven-sh' && 'macos-13-large' || 'macos-13' }} - tag: darwin-x64-baseline - darwin-aarch64-test: - if: ${{ inputs.run-id || github.event_name == 'pull_request' }} - name: Test darwin-aarch64 - needs: darwin-aarch64 - uses: ./.github/workflows/run-test.yml - secrets: inherit - with: - run-id: ${{ inputs.run-id }} - pr-number: ${{ github.event.number }} - runs-on: ${{ github.repository_owner == 'oven-sh' && 'namespace-profile-bun-ci-darwin-aarch64' || 'macos-13' }} - tag: darwin-aarch64 - windows-x64-test: - if: ${{ inputs.run-id || github.event_name == 'pull_request' }} - name: Test windows-x64 - needs: windows-x64 - uses: ./.github/workflows/run-test.yml - secrets: inherit - with: - run-id: ${{ inputs.run-id }} - pr-number: ${{ github.event.number }} - runs-on: windows - tag: windows-x64 - windows-x64-baseline-test: - if: ${{ inputs.run-id || github.event_name == 'pull_request' }} - name: Test windows-x64-baseline - needs: windows-x64-baseline - uses: ./.github/workflows/run-test.yml - secrets: inherit - with: - run-id: ${{ inputs.run-id }} - pr-number: ${{ github.event.number }} - runs-on: windows - tag: windows-x64-baseline - cleanup: - if: ${{ always() }} - name: Cleanup - needs: - - linux-x64 - - linux-x64-baseline - - linux-aarch64 - - darwin-x64 - - darwin-x64-baseline - - darwin-aarch64 - - windows-x64 - - windows-x64-baseline - runs-on: ubuntu-latest - steps: - - name: Cleanup Artifacts - uses: geekyeggo/delete-artifact@v5 - with: - name: | - bun-*-cpp - bun-*-zig - bun-*-deps - bun-*-codegen diff --git a/.github/workflows/comment.yml b/.github/workflows/comment.yml deleted file mode 100644 index 3c798e8fcc..0000000000 --- a/.github/workflows/comment.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Comment - -permissions: - actions: read - pull-requests: write - -on: - workflow_run: - workflows: - - CI - types: - - completed - -jobs: - comment: - if: ${{ github.repository_owner == 'oven-sh' }} - name: Comment - runs-on: ubuntu-latest - steps: - - name: Download Tests - uses: actions/download-artifact@v4 - with: - path: bun - pattern: bun-*-tests - github-token: ${{ github.token }} - run-id: ${{ github.event.workflow_run.id }} - - name: Setup Environment - id: env - shell: bash - run: | - echo "pr-number=$(> $GITHUB_OUTPUT - - name: Generate Comment - run: | - cat bun/bun-*-tests/comment.md > comment.md - if [ -s comment.md ]; then - echo -e "❌ @${{ github.actor }}, your commit has failing tests :(\n\n$(cat comment.md)" > comment.md - else - echo -e "✅ @${{ github.actor }}, all tests passed!" > comment.md - fi - echo -e "\n**[View logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }})**" >> comment.md - echo -e "" >> comment.md - - name: Find Comment - id: comment - uses: peter-evans/find-comment@v3 - with: - issue-number: ${{ steps.env.outputs.pr-number }} - comment-author: github-actions[bot] - body-includes: - - name: Write Comment - uses: peter-evans/create-or-update-comment@v4 - with: - comment-id: ${{ steps.comment.outputs.comment-id }} - issue-number: ${{ steps.env.outputs.pr-number }} - body-path: comment.md - edit-mode: replace diff --git a/.github/workflows/create-release-build.yml b/.github/workflows/create-release-build.yml deleted file mode 100644 index 42adea0585..0000000000 --- a/.github/workflows/create-release-build.yml +++ /dev/null @@ -1,183 +0,0 @@ -name: Create Release Build -run-name: Compile Bun v${{ inputs.version }} by ${{ github.actor }} - -concurrency: - group: release - cancel-in-progress: true - -permissions: - contents: write - actions: write - -on: - workflow_dispatch: - inputs: - version: - type: string - required: true - description: "Release version. Example: 1.1.4. Exclude the 'v' prefix." - tag: - type: string - required: true - description: "GitHub tag to use" - clobber: - type: boolean - required: false - default: false - description: "Overwrite existing release artifacts?" - release: - types: - - created - -jobs: - notify-start: - if: ${{ github.repository_owner == 'oven-sh' }} - name: Notify Start - runs-on: ubuntu-latest - steps: - - name: Send Message - uses: sarisia/actions-status-discord@v1 - with: - webhook: ${{ secrets.DISCORD_WEBHOOK_PUBLIC }} - nodetail: true - color: "#1F6FEB" - title: "Bun v${{ inputs.version }} is compiling" - description: | - ### @${{ github.actor }} started compiling Bun v${{inputs.version}} - - name: Send Message - uses: sarisia/actions-status-discord@v1 - with: - webhook: ${{ secrets.BUN_DISCORD_GITHUB_CHANNEL_WEBHOOK }} - nodetail: true - color: "#1F6FEB" - title: "Bun v${{ inputs.version }} is compiling" - description: | - ### @${{ github.actor }} started compiling Bun v${{inputs.version}} - - **[View logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})** - linux-x64: - name: Build linux-x64 - uses: ./.github/workflows/build-linux.yml - secrets: inherit - with: - runs-on: ${{ github.repository_owner == 'oven-sh' && 'namespace-profile-bun-ci-linux-x64' || 'ubuntu-latest' }} - tag: linux-x64 - arch: x64 - cpu: haswell - canary: false - linux-x64-baseline: - name: Build linux-x64-baseline - uses: ./.github/workflows/build-linux.yml - secrets: inherit - with: - runs-on: ${{ github.repository_owner == 'oven-sh' && 'namespace-profile-bun-ci-linux-x64' || 'ubuntu-latest' }} - tag: linux-x64-baseline - arch: x64 - cpu: nehalem - canary: false - linux-aarch64: - name: Build linux-aarch64 - uses: ./.github/workflows/build-linux.yml - secrets: inherit - with: - runs-on: namespace-profile-bun-ci-linux-aarch64 - tag: linux-aarch64 - arch: aarch64 - cpu: native - canary: false - darwin-x64: - name: Build darwin-x64 - uses: ./.github/workflows/build-darwin.yml - secrets: inherit - with: - runs-on: ${{ github.repository_owner == 'oven-sh' && 'macos-13-large' || 'macos-13' }} - tag: darwin-x64 - arch: x64 - cpu: haswell - canary: false - darwin-x64-baseline: - name: Build darwin-x64-baseline - uses: ./.github/workflows/build-darwin.yml - secrets: inherit - with: - runs-on: ${{ github.repository_owner == 'oven-sh' && 'macos-13-large' || 'macos-13' }} - tag: darwin-x64-baseline - arch: x64 - cpu: nehalem - canary: false - darwin-aarch64: - name: Build darwin-aarch64 - uses: ./.github/workflows/build-darwin.yml - secrets: inherit - with: - runs-on: ${{ github.repository_owner == 'oven-sh' && 'namespace-profile-bun-ci-darwin-aarch64' || 'macos-13' }} - tag: darwin-aarch64 - arch: aarch64 - cpu: native - canary: false - windows-x64: - name: Build windows-x64 - uses: ./.github/workflows/build-windows.yml - secrets: inherit - with: - runs-on: windows - tag: windows-x64 - arch: x64 - cpu: haswell - canary: false - windows-x64-baseline: - name: Build windows-x64-baseline - uses: ./.github/workflows/build-windows.yml - secrets: inherit - with: - runs-on: windows - tag: windows-x64-baseline - arch: x64 - cpu: nehalem - canary: false - - upload-artifacts: - needs: - - linux-x64 - - linux-x64-baseline - - linux-aarch64 - - darwin-x64 - - darwin-x64-baseline - - darwin-aarch64 - - windows-x64 - - windows-x64-baseline - runs-on: ubuntu-latest - steps: - - name: Download Artifacts - uses: actions/download-artifact@v4 - with: - path: bun-releases - pattern: bun-* - merge-multiple: true - github-token: ${{ github.token }} - - name: Check for Artifacts - run: | - if [ ! -d "bun-releases" ] || [ -z "$(ls -A bun-releases)" ]; then - echo "Error: No artifacts were downloaded or 'bun-releases' directory does not exist." - exit 1 # Fail the job if the condition is met - else - echo "Artifacts downloaded successfully." - fi - - name: Send Message - uses: sarisia/actions-status-discord@v1 - with: - webhook: ${{ secrets.DISCORD_WEBHOOK }} - nodetail: true - color: "#FF0000" - title: "Bun v${{ inputs.version }} release artifacts uploaded" - - name: "Upload Artifacts" - env: - GH_TOKEN: ${{ github.token }} - run: | - # Unzip one level deep each artifact - cd bun-releases - for f in *.zip; do - unzip -o $f - done - cd .. - gh release upload --repo=${{ github.repository }} ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.event.release.id }} ${{ inputs.clobber && '--clobber' || '' }} bun-releases/*.zip diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5c31ba8589..cbe6b3e93a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,3 +1,6 @@ +# TODO: Move this to bash scripts intead of Github Actions +# so it can be run from Buildkite, see: .buildkite/scripts/release.sh + name: Release concurrency: release diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml deleted file mode 100644 index 6efe322a54..0000000000 --- a/.github/workflows/run-test.yml +++ /dev/null @@ -1,224 +0,0 @@ -name: Test - -permissions: - contents: read - actions: read - -on: - workflow_call: - inputs: - runs-on: - type: string - required: true - tag: - type: string - required: true - pr-number: - type: string - required: true - run-id: - type: string - default: ${{ github.run_id }} - -jobs: - test: - name: Tests - runs-on: ${{ inputs.runs-on }} - steps: - - if: ${{ runner.os == 'Windows' }} - name: Setup Git - run: | - git config --global core.autocrlf false - git config --global core.eol lf - - name: Checkout - uses: actions/checkout@v4 - with: - sparse-checkout: | - package.json - bun.lockb - test - packages/bun-internal-test - packages/bun-types - - name: Setup Environment - shell: bash - run: | - echo "${{ inputs.pr-number }}" > pr-number.txt - - name: Download Bun - uses: actions/download-artifact@v4 - with: - name: bun-${{ inputs.tag }} - path: bun - github-token: ${{ github.token }} - run-id: ${{ inputs.run-id || github.run_id }} - - name: Download pnpm - uses: pnpm/action-setup@v4 - with: - version: 8 - - if: ${{ runner.os != 'Windows' }} - name: Setup Bun - shell: bash - run: | - unzip bun/bun-*.zip - cd bun-* - pwd >> $GITHUB_PATH - - if: ${{ runner.os == 'Windows' }} - name: Setup Cygwin - uses: secondlife/setup-cygwin@v3 - with: - packages: bash - - if: ${{ runner.os == 'Windows' }} - name: Setup Bun (Windows) - run: | - unzip bun/bun-*.zip - cd bun-* - pwd >> $env:GITHUB_PATH - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - - name: Install Dependencies - timeout-minutes: 5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - bun install - - name: Install Dependencies (test) - timeout-minutes: 5 - run: | - bun install --cwd test - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Install Dependencies (runner) - timeout-minutes: 5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - bun install --cwd packages/bun-internal-test - - name: Run Tests - id: test - timeout-minutes: 90 - shell: bash - env: - IS_BUN_CI: 1 - TMPDIR: ${{ runner.temp }} - BUN_TAG: ${{ inputs.tag }} - BUN_FEATURE_FLAG_INTERNAL_FOR_TESTING: "true" - SMTP_SENDGRID_SENDER: ${{ secrets.SMTP_SENDGRID_SENDER }} - TLS_MONGODB_DATABASE_URL: ${{ secrets.TLS_MONGODB_DATABASE_URL }} - TLS_POSTGRES_DATABASE_URL: ${{ secrets.TLS_POSTGRES_DATABASE_URL }} - TEST_INFO_STRIPE: ${{ secrets.TEST_INFO_STRIPE }} - TEST_INFO_AZURE_SERVICE_BUS: ${{ secrets.TEST_INFO_AZURE_SERVICE_BUS }} - SHELLOPTS: igncr - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - node packages/bun-internal-test/src/runner.node.mjs $(which bun) - - if: ${{ always() }} - name: Upload Results - uses: actions/upload-artifact@v4 - with: - name: bun-${{ inputs.tag }}-tests - path: | - test-report.* - comment.md - pr-number.txt - if-no-files-found: error - overwrite: true - - if: ${{ always() && steps.test.outputs.failing_tests != '' && github.event.pull_request && github.repository_owner == 'oven-sh' }} - name: Send Message - uses: sarisia/actions-status-discord@v1 - with: - webhook: ${{ secrets.DISCORD_WEBHOOK }} - nodetail: true - color: "#FF0000" - title: "" - description: | - ### ❌ [${{ github.event.pull_request.title }}](${{ github.event.pull_request.html_url }}) - - @${{ github.actor }}, there are ${{ steps.test.outputs.failing_tests_count || 'some' }} failing tests on bun-${{ inputs.tag }}. - - ${{ steps.test.outputs.failing_tests }} - - **[View logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})** - - name: Fail - if: ${{ failure() || always() && steps.test.outputs.failing_tests != '' }} - run: | - echo "There are ${{ steps.test.outputs.failing_tests_count || 'some' }} failing tests on bun-${{ inputs.tag }}." - exit 1 - test-node: - name: Node.js Tests - # TODO: enable when we start paying attention to the results. In the meantime, this causes CI to queue jobs wasting developer time. - if: 0 - runs-on: ${{ inputs.runs-on }} - steps: - - if: ${{ runner.os == 'Windows' }} - name: Setup Git - run: | - git config --global core.autocrlf false - git config --global core.eol lf - - name: Checkout - uses: actions/checkout@v4 - with: - sparse-checkout: | - test/node.js - - name: Setup Environment - shell: bash - run: | - echo "${{ inputs.pr-number }}" > pr-number.txt - - name: Download Bun - uses: actions/download-artifact@v4 - with: - name: bun-${{ inputs.tag }} - path: bun - github-token: ${{ github.token }} - run-id: ${{ inputs.run-id || github.run_id }} - - if: ${{ runner.os != 'Windows' }} - name: Setup Bun - shell: bash - run: | - unzip bun/bun-*.zip - cd bun-* - pwd >> $GITHUB_PATH - - if: ${{ runner.os == 'Windows' }} - name: Setup Cygwin - uses: secondlife/setup-cygwin@v3 - with: - packages: bash - - if: ${{ runner.os == 'Windows' }} - name: Setup Bun (Windows) - run: | - unzip bun/bun-*.zip - cd bun-* - pwd >> $env:GITHUB_PATH - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - - name: Checkout Tests - shell: bash - working-directory: test/node.js - run: | - node runner.mjs --pull - - name: Install Dependencies - timeout-minutes: 5 - shell: bash - working-directory: test/node.js - run: | - bun install - - name: Run Tests - timeout-minutes: 10 # Increase when more tests are added - shell: bash - working-directory: test/node.js - env: - TMPDIR: ${{ runner.temp }} - BUN_GARBAGE_COLLECTOR_LEVEL: "0" - BUN_FEATURE_FLAG_INTERNAL_FOR_TESTING: "true" - run: | - node runner.mjs - - name: Upload Results - uses: actions/upload-artifact@v4 - with: - name: bun-${{ inputs.tag }}-node-tests - path: | - test/node.js/summary/*.json - if-no-files-found: error - overwrite: true diff --git a/.github/workflows/upload.yml b/.github/workflows/upload.yml deleted file mode 100644 index d111d17f6b..0000000000 --- a/.github/workflows/upload.yml +++ /dev/null @@ -1,94 +0,0 @@ -name: Upload Artifacts -run-name: Canary release ${{github.sha}} upload - -permissions: - contents: write - -on: - workflow_run: - workflows: - - CI - types: - - completed - branches: - - main - -jobs: - upload: - if: ${{ github.repository_owner == 'oven-sh' }} - name: Upload Artifacts - runs-on: ubuntu-latest - steps: - - name: Download Artifacts - uses: actions/download-artifact@v4 - with: - path: bun - pattern: bun-* - merge-multiple: true - github-token: ${{ github.token }} - run-id: ${{ github.event.workflow_run.id }} - - name: Check for Artifacts - run: | - if [ ! -d "bun" ] || [ -z "$(ls -A bun)" ]; then - echo "Error: No artifacts were downloaded or 'bun' directory does not exist." - exit 1 # Fail the job if the condition is met - else - echo "Artifacts downloaded successfully." - fi - - name: Upload to GitHub Releases - uses: ncipollo/release-action@v1 - with: - tag: canary - name: Canary (${{ github.sha }}) - prerelease: true - body: This canary release of Bun corresponds to the commit [${{ github.sha }}] - allowUpdates: true - replacesArtifacts: true - generateReleaseNotes: true - artifactErrorsFailBuild: true - artifacts: bun/**/bun-*.zip - token: ${{ github.token }} - - name: Upload to S3 (using SHA) - uses: shallwefootball/s3-upload-action@4350529f410221787ccf424e50133cbc1b52704e - with: - endpoint: ${{ secrets.AWS_ENDPOINT }} - aws_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}} - aws_bucket: ${{ secrets.AWS_BUCKET }} - source_dir: bun - destination_dir: releases/${{ github.event.workflow_run.head_sha || github.sha }}-canary - - name: Upload to S3 (using tag) - uses: shallwefootball/s3-upload-action@4350529f410221787ccf424e50133cbc1b52704e - with: - endpoint: ${{ secrets.AWS_ENDPOINT }} - aws_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}} - aws_bucket: ${{ secrets.AWS_BUCKET }} - source_dir: bun - destination_dir: releases/canary - - name: Announce on Discord - uses: sarisia/actions-status-discord@v1 - with: - webhook: ${{ secrets.BUN_DISCORD_GITHUB_CHANNEL_WEBHOOK }} - nodetail: true - color: "#1F6FEB" - title: "New Bun Canary available" - url: https://github.com/oven-sh/bun/commit/${{ github.sha }} - description: | - A new canary build of Bun has been automatically uploaded. To upgrade, run: - ```sh - bun upgrade --canary - # bun upgrade --stable <- to downgrade - ``` - # If notifying sentry fails, don't fail the rest of the build. - - name: Notify Sentry - uses: getsentry/action-release@v1.7.0 - env: - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - SENTRY_ORG: ${{ secrets.SENTRY_ORG }} - SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} - with: - ignore_missing: true - ignore_empty: true - version: ${{ github.event.workflow_run.head_sha || github.sha }}-canary - environment: canary diff --git a/scripts/all-dependencies.sh b/scripts/all-dependencies.sh index 50a22fe8f8..627339a077 100755 --- a/scripts/all-dependencies.sh +++ b/scripts/all-dependencies.sh @@ -36,9 +36,11 @@ fi dep() { local submodule="$1" local script="$2" - CACHE_KEY= if [ "$CACHE" == "1" ]; then - CACHE_KEY="$submodule/$(echo "$SUBMODULES" | grep "$submodule" | git hash-object --stdin)" + local hash="$(echo "$SUBMODULES" | grep "$submodule" | awk '{print $1}')" + local os="$(uname -s | tr '[:upper:]' '[:lower:]')" + local arch="$(uname -m)" + CACHE_KEY="$submodule/$hash-$os-$arch-$CPU_TARGET" fi if [ -z "$FORCE" ]; then HAS_ALL_DEPS=1 diff --git a/scripts/build-bun-cpp.ps1 b/scripts/build-bun-cpp.ps1 index ab79b7f1b3..adb1a57cf7 100755 --- a/scripts/build-bun-cpp.ps1 +++ b/scripts/build-bun-cpp.ps1 @@ -1,29 +1,29 @@ -param ( - [switch] $Baseline = $False, - [switch] $Fast = $False -) - $ErrorActionPreference = 'Stop' # Setting strict mode, similar to 'set -euo pipefail' in bash -$Tag = If ($Baseline) { "-Baseline" } Else { "" } -$UseBaselineBuild = If ($Baseline) { "ON" } Else { "OFF" } -$UseLto = If ($Fast) { "OFF" } Else { "ON" } - -# $CANARY_REVISION = if (Test-Path build/.canary_revision) { Get-Content build/.canary_revision } else { "0" } -$CANARY_REVISION = 0 -.\scripts\env.ps1 $Tag +.\scripts\env.ps1 .\scripts\update-submodules.ps1 .\scripts\build-libuv.ps1 -CloneOnly $True -cd build -cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release ` +# libdeflate.h is needed otherwise the build fails +git submodule update --init --recursive --progress --depth=1 --checkout src/deps/libdeflate + +cd build +cmake .. @CMAKE_FLAGS ` + -G Ninja ` + -DCMAKE_BUILD_TYPE=Release ` -DNO_CODEGEN=0 ` -DNO_CONFIGURE_DEPENDS=1 ` - "-DUSE_BASELINE_BUILD=${UseBaselineBuild}" ` - "-DUSE_LTO=${UseLto}" ` - "-DCANARY=${CANARY_REVISION}" ` - -DBUN_CPP_ONLY=1 $Flags + -DBUN_CPP_ONLY=1 if ($LASTEXITCODE -ne 0) { throw "CMake configuration failed" } -.\compile-cpp-only.ps1 -v -if ($LASTEXITCODE -ne 0) { throw "C++ compilation failed" } \ No newline at end of file +.\compile-cpp-only.ps1 -v -j $env:CPUS +if ($LASTEXITCODE -ne 0) { throw "C++ compilation failed" } + +# HACK: For some reason, the buildkite agent is hanging when uploading bun-cpp-objects.a +# Best guess is that there is an issue when uploading files larger than 500 MB +# +# For now, use FileSplitter to split the file into smaller chunks: +# https://www.powershellgallery.com/packages/FileSplitter/1.3 +if ($env:BUILDKITE) { + Split-File -Path (Resolve-Path "bun-cpp-objects.a") -PartSizeBytes "50MB" -Verbose +} diff --git a/scripts/build-bun-cpp.sh b/scripts/build-bun-cpp.sh deleted file mode 100755 index 631452d942..0000000000 --- a/scripts/build-bun-cpp.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env bash -set -exo pipefail -source $(dirname -- "${BASH_SOURCE[0]}")/env.sh - -export USE_LTO="${USE_LTO:-ON}" -case "$(uname -m)" in - aarch64|arm64) - export CPU_TARGET="${CPU_TARGET:-native}" - ;; - *) - export CPU_TARGET="${CPU_TARGET:-haswell}" - ;; -esac - -while [[ $# -gt 0 ]]; do - case "$1" in - --fast|--no-lto) - export USE_LTO="OFF" - shift - ;; - --baseline) - export CPU_TARGET="nehalem" - shift - ;; - --cpu) - export CPU_TARGET="$2" - shift - shift - ;; - *|-*|--*) - echo "Unknown option $1" - exit 1 - ;; - esac -done - -mkdir -p build -cd build -mkdir -p tmp_modules tmp_functions js codegen -cmake .. \ - -GNinja \ - -DCMAKE_BUILD_TYPE=Release \ - -DUSE_LTO=${USE_LTO} \ - -DCPU_TARGET=${CPU_TARGET} \ - -DBUN_CPP_ONLY=1 \ - -DNO_CONFIGURE_DEPENDS=1 -chmod +x ./compile-cpp-only.sh -bash ./compile-cpp-only.sh -v diff --git a/scripts/build-bun-zig.sh b/scripts/build-bun-zig.sh deleted file mode 100755 index 489c635d12..0000000000 --- a/scripts/build-bun-zig.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env bash -set -exo pipefail -source $(dirname -- "${BASH_SOURCE[0]}")/env.sh - -cwd=$(pwd) -zig= - -if [[ "$CI" ]]; then - # Since the zig build depends on files from the zig submodule, - # make sure to update the submodule before building. - git submodule update --init --recursive --progress --depth=1 --checkout src/deps/zig - - # Also update the correct version of zig in the submodule. - $(dirname -- "${BASH_SOURCE[0]}")/download-zig.sh -fi - -if [ -f "$cwd/.cache/zig/zig" ]; then - zig="$cwd/.cache/zig/zig" -else - zig=$(which zig) -fi - -ZIG_OPTIMIZE="${ZIG_OPTIMIZE:-ReleaseFast}" -CANARY="${CANARY:-0}" -GIT_SHA="${GIT_SHA:-$(git rev-parse HEAD)}" - -BUILD_MACHINE_ARCH="${BUILD_MACHINE_ARCH:-$(uname -m)}" -DOCKER_MACHINE_ARCH="" -if [[ "$BUILD_MACHINE_ARCH" == "x86_64" || "$BUILD_MACHINE_ARCH" == "amd64" ]]; then - BUILD_MACHINE_ARCH="x86_64" - DOCKER_MACHINE_ARCH="amd64" -elif [[ "$BUILD_MACHINE_ARCH" == "aarch64" || "$BUILD_MACHINE_ARCH" == "arm64" ]]; then - BUILD_MACHINE_ARCH="aarch64" - DOCKER_MACHINE_ARCH="arm64" -fi - -TARGET_OS="${1:-linux}" -TARGET_ARCH="${2:-x64}" -TARGET_CPU="${3:-${CPU_TARGET:-native}}" - -BUILDARCH="" -if [[ "$TARGET_ARCH" == "x64" || "$TARGET_ARCH" == "x86_64" || "$TARGET_ARCH" == "amd64" ]]; then - TARGET_ARCH="x86_64" - BUILDARCH="amd64" -elif [[ "$TARGET_ARCH" == "aarch64" || "$TARGET_ARCH" == "arm64" ]]; then - TARGET_ARCH="aarch64" - BUILDARCH="arm64" -fi - -TRIPLET="" -if [[ "$TARGET_OS" == "linux" ]]; then - TRIPLET="$TARGET_ARCH-linux-gnu" -elif [[ "$TARGET_OS" == "darwin" ]]; then - TRIPLET="$TARGET_ARCH-macos-none" -elif [[ "$TARGET_OS" == "windows" ]]; then - TRIPLET="$TARGET_ARCH-windows-msvc" -fi - -echo "--- Building identifier-cache" -$zig run src/js_lexer/identifier_data.zig - -echo "--- Building node-fallbacks" -cd src/node-fallbacks -bun install --frozen-lockfile -bun run build -cd "$cwd" - -echo "--- Building codegen" -bun install --frozen-lockfile -make runtime_js fallback_decoder bun_error - -echo "--- Building modules" -mkdir -p build -bun run src/codegen/bundle-modules.ts --debug=OFF build - -echo "--- Building zig" -cd build -cmake .. \ - -GNinja \ - -DCMAKE_BUILD_TYPE=Release \ - -DUSE_LTO=ON \ - -DZIG_OPTIMIZE="${ZIG_OPTIMIZE}" \ - -DGIT_SHA="${GIT_SHA}" \ - -DARCH="${TARGET_ARCH}" \ - -DBUILDARCH="${BUILDARCH}" \ - -DCPU_TARGET="${TARGET_CPU}" \ - -DZIG_TARGET="${TRIPLET}" \ - -DASSERTIONS="OFF" \ - -DWEBKIT_DIR="omit" \ - -DNO_CONFIGURE_DEPENDS=1 \ - -DNO_CODEGEN=1 \ - -DBUN_ZIG_OBJ_DIR="$cwd/build" \ - -DCANARY="$CANARY" \ - -DZIG_LIB_DIR=src/deps/zig/lib -ONLY_ZIG=1 ninja "$cwd/build/bun-zig.o" -v diff --git a/scripts/build-tinycc.ps1 b/scripts/build-tinycc.ps1 index 78a10f42e8..095fd97dd0 100755 --- a/scripts/build-tinycc.ps1 +++ b/scripts/build-tinycc.ps1 @@ -20,8 +20,6 @@ try { Run clang-cl -DTCC_TARGET_PE -DTCC_TARGET_X86_64 config.h -DC2STR -o c2str.exe conftest.c Run .\c2str.exe .\include\tccdefs.h tccdefs_.h - $Baseline = $env:BUN_DEV_ENV_SET -eq "Baseline=True" - Run clang-cl @($env:CFLAGS -split ' ') libtcc.c -o tcc.obj "-DTCC_TARGET_PE" "-DTCC_TARGET_X86_64" "-O2" "-W2" "-Zi" "-MD" "-GS-" "-c" "-MT" Run llvm-lib "tcc.obj" "-OUT:tcc.lib" diff --git a/scripts/buildkite-link-bun.ps1 b/scripts/buildkite-link-bun.ps1 index b56e0eefc1..caa7d98ce7 100755 --- a/scripts/buildkite-link-bun.ps1 +++ b/scripts/buildkite-link-bun.ps1 @@ -1,17 +1,13 @@ -param ( - [switch] $Baseline = $False, - [switch] $Fast = $False +param( + [switch]$Baseline = $false ) $ErrorActionPreference = 'Stop' # Setting strict mode, similar to 'set -euo pipefail' in bash $Target = If ($Baseline) { "windows-x64-baseline" } Else { "windows-x64" } $Tag = "bun-$Target" -$TagSuffix = If ($Baseline) { "-Baseline" } Else { "" } -$UseBaselineBuild = If ($Baseline) { "ON" } Else { "OFF" } -$UseLto = If ($Fast) { "OFF" } Else { "ON" } -.\scripts\env.ps1 $TagSuffix +.\scripts\env.ps1 mkdir -Force build buildkite-agent artifact download "**" build --step "${Target}-build-zig" @@ -21,29 +17,24 @@ mv -Force -ErrorAction SilentlyContinue build\build\bun-deps\* build\bun-deps mv -Force -ErrorAction SilentlyContinue build\build\* build Set-Location build -$CANARY_REVISION = 0 -cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release ` + +# HACK: See scripts/build-bun-cpp.ps1 +Join-File -Path "$(Resolve-Path .)\bun-cpp-objects.a" -Verbose -DeletePartFiles + +cmake .. @CMAKE_FLAGS ` + -G Ninja ` + -DCMAKE_BUILD_TYPE=Release ` -DNO_CODEGEN=1 ` -DNO_CONFIGURE_DEPENDS=1 ` - "-DCPU_TARGET=${CPU_TARGET}" ` - "-DCANARY=${CANARY_REVISION}" ` -DBUN_LINK_ONLY=1 ` - "-DUSE_BASELINE_BUILD=${UseBaselineBuild}" ` - "-DUSE_LTO=${UseLto}" ` "-DBUN_DEPS_OUT_DIR=$(Resolve-Path bun-deps)" ` "-DBUN_CPP_ARCHIVE=$(Resolve-Path bun-cpp-objects.a)" ` - "-DBUN_ZIG_OBJ_DIR=$(Resolve-Path .)" ` - "$Flags" + "-DBUN_ZIG_OBJ_DIR=$(Resolve-Path .)" if ($LASTEXITCODE -ne 0) { throw "CMake configuration failed" } -ninja -v +ninja -v -j $env:CPUS if ($LASTEXITCODE -ne 0) { throw "Link failed!" } -ls -if ($Fast) { - $Tag = "$Tag-nolto" -} - Set-Location .. $Dist = mkdir -Force "${Tag}" cp -r build\bun.exe "$Dist\bun.exe" diff --git a/scripts/buildkite-link-bun.sh b/scripts/buildkite-link-bun.sh deleted file mode 100755 index d0456e25ff..0000000000 --- a/scripts/buildkite-link-bun.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env bash -set -exo pipefail -source $(dirname -- "${BASH_SOURCE[0]}")/env.sh - -export USE_LTO="${USE_LTO:-ON}" -case "$(uname -m)" in - aarch64|arm64) - export CPU_TARGET="${CPU_TARGET:-native}" - ;; - *) - export CPU_TARGET="${CPU_TARGET:-haswell}" - ;; -esac - -export TAG="" -while [[ $# -gt 0 ]]; do - case "$1" in - --tag) - export TAG="$2" - shift - shift - ;; - --fast|--no-lto) - export USE_LTO="OFF" - shift - ;; - --baseline) - export CPU_TARGET="nehalem" - shift - ;; - --cpu) - export CPU_TARGET="$2" - shift - shift - ;; - *|-*|--*) - echo "Unknown option $1" - exit 1 - ;; - esac -done - -if [[ -z "$TAG" ]]; then - echo "--tag is required" - exit 1 -fi - -rm -rf release -mkdir -p release -buildkite-agent artifact download '**' release --step $TAG-build-deps -buildkite-agent artifact download '**' release --step $TAG-build-zig -buildkite-agent artifact download '**' release --step $TAG-build-cpp - -cd release -cmake .. \ - -GNinja \ - -DCMAKE_BUILD_TYPE=Release \ - -DCPU_TARGET=${CPU_TARGET} \ - -DUSE_LTO=${USE_LTO} \ - -DBUN_LINK_ONLY=1 \ - -DBUN_ZIG_OBJ_DIR="$(pwd)/build" \ - -DBUN_CPP_ARCHIVE="$(pwd)/build/bun-cpp-objects.a" \ - -DBUN_DEPS_OUT_DIR="$(pwd)/build/bun-deps" \ - -DNO_CONFIGURE_DEPENDS=1 -ninja -v - -if [[ "${USE_LTO}" == "OFF" ]]; then - TAG="${TAG}-nolto" -fi - -chmod +x bun-profile bun -mkdir -p bun-$TAG-profile/ bun-$TAG/ -mv bun-profile bun-$TAG-profile/bun-profile -mv bun bun-$TAG/bun -zip -r bun-$TAG-profile.zip bun-$TAG-profile -zip -r bun-$TAG.zip bun-$TAG - -cd .. -mv release/bun-$TAG.zip bun-$TAG.zip -mv release/bun-$TAG-profile.zip bun-$TAG-profile.zip diff --git a/scripts/env.ps1 b/scripts/env.ps1 index e9492abee4..02c63a68f3 100755 --- a/scripts/env.ps1 +++ b/scripts/env.ps1 @@ -1,11 +1,3 @@ -param( - [switch]$Baseline = $false -) - -if ($ENV:BUN_DEV_ENV_SET -eq "Baseline=True") { - $Baseline = $true -} - $ErrorActionPreference = 'Stop' # Setting strict mode, similar to 'set -euo pipefail' in bash # this is the environment script for building bun's dependencies @@ -38,13 +30,19 @@ if($Env:VSCMD_ARG_TGT_ARCH -eq "x86") { throw "Visual Studio environment is targetting 32 bit. This configuration is definetly a mistake." } -$ENV:BUN_DEV_ENV_SET = "Baseline=$Baseline"; - $BUN_BASE_DIR = if ($env:BUN_BASE_DIR) { $env:BUN_BASE_DIR } else { Join-Path $ScriptDir '..' } $BUN_DEPS_DIR = if ($env:BUN_DEPS_DIR) { $env:BUN_DEPS_DIR } else { Join-Path $BUN_BASE_DIR 'src\deps' } $BUN_DEPS_OUT_DIR = if ($env:BUN_DEPS_OUT_DIR) { $env:BUN_DEPS_OUT_DIR } else { Join-Path $BUN_BASE_DIR 'build\bun-deps' } $CPUS = if ($env:CPUS) { $env:CPUS } else { (Get-CimInstance -Class Win32_Processor).NumberOfCores } +$Lto = if ($env:USE_LTO) { $env:USE_LTO -eq "1" } else { True } +$Baseline = if ($env:USE_BASELINE_BUILD) { + $env:USE_BASELINE_BUILD -eq "1" +} elseif ($env:BUILDKITE_STEP_KEY -match "baseline") { + True +} else { + False +} $CC = "clang-cl" $CXX = "clang-cl" @@ -52,7 +50,7 @@ $CXX = "clang-cl" $CFLAGS = '/O2 /Z7 /MT /O2 /Ob2 /DNDEBUG /U_DLL' $CXXFLAGS = '/O2 /Z7 /MT /O2 /Ob2 /DNDEBUG /U_DLL' -if ($env:USE_LTO -eq "1") { +if ($Lto) { $CXXFLAGS += " -fuse-ld=lld -flto -Xclang -emit-llvm-bc" $CFLAGS += " -fuse-ld=lld -flto -Xclang -emit-llvm-bc" } @@ -63,6 +61,14 @@ $env:CPU_TARGET = $CPU_NAME $CFLAGS += " -march=${CPU_NAME}" $CXXFLAGS += " -march=${CPU_NAME}" +$Canary = If ($env:CANARY) { + $env:CANARY +} ElseIf ($env:BUILDKITE -eq "true") { + (buildkite-agent meta-data get canary) +} Else { + "1" +} + $CMAKE_FLAGS = @( "-GNinja", "-DCMAKE_BUILD_TYPE=Release", @@ -72,7 +78,8 @@ $CMAKE_FLAGS = @( "-DCMAKE_CXX_FLAGS=$CXXFLAGS", "-DCMAKE_C_FLAGS_RELEASE=$CFLAGS", "-DCMAKE_CXX_FLAGS_RELEASE=$CXXFLAGS", - "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded" + "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded", + "-DCANARY=$Canary" ) if (Get-Command llvm-lib -ErrorAction SilentlyContinue) { @@ -92,6 +99,10 @@ if ($Baseline) { $CMAKE_FLAGS += "-DUSE_BASELINE_BUILD=ON" } +if ($Lto) { + $CMAKE_FLAGS += "-DUSE_LTO=ON" +} + if (Get-Command sccache -ErrorAction SilentlyContinue) { # Continue with local compiler if sccache has an error $env:SCCACHE_IGNORE_SERVER_IO_ERROR = "1" diff --git a/scripts/env.sh b/scripts/env.sh index 6ff0e225af..617c1c75ed 100755 --- a/scripts/env.sh +++ b/scripts/env.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Hack for Buildkite sometimes not having the right path +# Hack for buildkite sometimes not having the right path if [[ "${CI:-}" == "1" || "${CI:-}" == "true" ]]; then if [ -f ~/.bashrc ]; then source ~/.bashrc diff --git a/scripts/experimental-build.mjs b/scripts/experimental-build.mjs index 33b26ab02f..0dcc53138c 100755 --- a/scripts/experimental-build.mjs +++ b/scripts/experimental-build.mjs @@ -6,16 +6,162 @@ import { copyFileSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdir import { basename, dirname, join } from "node:path"; import { tmpdir } from "node:os"; -const projectPath = dirname(import.meta.dirname); -const vendorPath = process.env.BUN_VENDOR_PATH || join(projectPath, "vendor"); - const isWindows = process.platform === "win32"; const isMacOS = process.platform === "darwin"; const isLinux = process.platform === "linux"; +const cwd = dirname(import.meta.dirname); const spawnSyncTimeout = 1000 * 60; const spawnTimeout = 1000 * 60 * 3; +/** + * @typedef {Object} S3UploadOptions + * @property {string} [bucket] + * @property {string} filename + * @property {string} content + * @property {Record} [headers] + */ + +/** + * @param {S3UploadOptions} options + */ +async function uploadFileToS3(options) { + const { AwsV4Signer } = await import("aws4fetch"); + + const { bucket, filename, content, ...extra } = options; + const baseUrl = getEnv(["S3_ENDPOINT", "S3_BASE_URL", "AWS_ENDPOINT"], "https://s3.amazonaws.com"); + const bucketUrl = new URL(bucket || getEnv(["S3_BUCKET", "AWS_BUCKET"]), baseUrl); + + const signer = new AwsV4Signer({ + accessKeyId: getSecret(["S3_ACCESS_KEY_ID", "AWS_ACCESS_KEY_ID"]), + secretAccessKey: getSecret(["S3_SECRET_ACCESS_KEY", "AWS_SECRET_ACCESS_KEY"]), + url: new URL(filename, bucketUrl), + method: "PUT", + body: content, + ...extra, + }); + + const { url, method, headers, body } = signer.sign(); + await fetchSafe(url, { + method, + headers, + body, + }); + + console.log("Uploaded file to S3:", { + url: `${bucketUrl}`, + filename, + }); +} + +/** + * @typedef {Object} SentryRelease + * @property {string} organizationId + * @property {string} projectId + * @property {string} version + * @property {string} [url] + * @property {string} [ref] + * @property {string} [dateReleased] + */ + +/** + * @param {SentryRelease} options + * @returns {Promise} + */ +async function createSentryRelease(options) { + const { organizationId, projectId, ...body } = options; + + const baseUrl = getEnv("SENTRY_BASE_URL", "https://sentry.io"); + const url = new URL(`api/0/organizations/${organizationId}/releases`, baseUrl); + const accessToken = getSecret(["SENTRY_AUTH_TOKEN", "SENTRY_TOKEN"]); + + const release = await fetchSafe(url, { + method: "POST", + headers: { + "Authorization": `Bearer ${accessToken}`, + "Content-Type": "application/json", + }, + body: JSON.stringify(body), + format: "json", + }); + + console.log("Created Sentry release:", release); +} + +/** + * @return {string} + */ +function getGithubToken() { + const token = getEnv("GITHUB_TOKEN", null); + if (token) { + return token; + } + + const gh = which("gh"); + if (gh) { + const { exitCode, stdout } = spawnSyncSafe(gh, ["auth", "token"]); + if (exitCode === 0) { + return stdout.trim(); + } + } + + throw new Error("Failed to get GitHub token (set GITHUB_TOKEN or run `gh auth login`)"); +} + +/** + * @param {string | string[]} name + * @return {string} + */ +function getSecret(name) { + return getEnv(name); +} + +/** + * @param {string | string[]} name + * @param {string | null} [defaultValue] + * @returns {string | undefined} + */ +function getEnv(name, defaultValue) { + let result = defaultValue; + + for (const key of typeof name === "string" ? [name] : name) { + const value = process.env[key]; + if (value) { + result = value; + break; + } + } + + if (result || result === null) { + return result; + } + + throw new Error(`Environment variable is required: ${name}`); +} + +/** + * @typedef {Object} SpawnOptions + * @property {boolean} [throwOnError] + * @property {string} [cwd] + * @property {string} [env] + * @property {string} [encoding] + * @property {number} [timeout] + */ + +/** + * @typedef {Object} SpawnResult + * @property {number | null} exitCode + * @property {number | null} signalCode + * @property {string} stdout + * @property {string} stderr + */ + +/** + * @param {string} command + * @param {string[]} [args] + * @param {SpawnOptions} [options] + * @returns {Promise} + */ async function spawnSafe(command, args, options = {}) { const result = new Promise((resolve, reject) => { let stdout = ""; @@ -60,6 +206,12 @@ async function spawnSafe(command, args, options = {}) { } } +/** + * @param {string} command + * @param {string[]} [args] + * @param {SpawnOptions} [options] + * @returns {SpawnResult} + */ function spawnSyncSafe(command, args, options = {}) { try { const { error, status, signal, stdout, stderr } = spawnSync(command, args, { @@ -86,6 +238,20 @@ function spawnSyncSafe(command, args, options = {}) { } } +/** + * @typedef {Object} FetchOptions + * @property {string} [method] + * @property {Record} [headers] + * @property {string | Uint8Array} [body] + * @property {"json" | "text" | "bytes"} [format] + * @property {boolean} [throwOnError] + */ + +/** + * @param {string | URL} url + * @param {FetchOptions} [options] + * @returns {Promise} + */ async function fetchSafe(url, options = {}) { let response; try { @@ -138,47 +304,6 @@ function which(command, path) { return result.trimEnd(); } -function getZigTarget(os = process.platform, arch = process.arch) { - if (arch === "x64") { - if (os === "linux") return "linux-x86_64"; - if (os === "darwin") return "macos-x86_64"; - if (os === "win32") return "windows-x86_64"; - } - if (arch === "arm64") { - if (os === "linux") return "linux-aarch64"; - if (os === "darwin") return "macos-aarch64"; - } - throw new Error(`Unsupported zig target: os=${os}, arch=${arch}`); -} - -function getRecommendedZigVersion() { - const scriptPath = join(projectPath, "build.zig"); - try { - const scriptContent = readFileSync(scriptPath, "utf-8"); - const match = scriptContent.match(/recommended_zig_version = "([^"]+)"/); - if (!match) { - throw new Error("File does not contain string: 'recommended_zig_version'"); - } - return match[1]; - } catch (cause) { - throw new Error("Failed to find recommended Zig version", { cause }); - } -} - -/** - * @returns {Promise} - */ -async function getLatestZigVersion() { - try { - const response = await fetchSafe("https://ziglang.org/download/index.json", { format: "json" }); - const { master } = response; - const { version } = master; - return version; - } catch (cause) { - throw new Error("Failed to get latest Zig version", { cause }); - } -} - /** * @param {string} execPath * @returns {string | undefined} @@ -191,110 +316,3 @@ function getVersion(execPath) { } return result.trim(); } - -/** - * @returns {string} - */ -function getTmpdir() { - if (isMacOS && existsSync("/tmp")) { - return "/tmp"; - } - return tmpdir(); -} - -/** - * @returns {string} - */ -function mkTmpdir() { - return mkdtempSync(join(getTmpdir(), "bun-")); -} - -/** - * @param {string} url - * @param {string} [path] - * @returns {Promise} - */ -async function downloadFile(url, path) { - const outPath = path || join(mkTmpdir(), basename(url)); - const bytes = await fetchSafe(url, { format: "bytes" }); - mkdirSync(dirname(outPath), { recursive: true }); - writeFileSync(outPath, bytes); - return outPath; -} - -/** - * @param {string} tarPath - * @param {string} [path] - * @returns {Promise} - */ -async function extractFile(tarPath, path) { - const outPath = path || join(mkTmpdir(), basename(tarPath)); - mkdirSync(outPath, { recursive: true }); - await spawnSafe("tar", ["-xf", tarPath, "-C", outPath, "--strip-components=1"]); - return outPath; -} - -const dependencies = [ - { - name: "zig", - version: getRecommendedZigVersion(), - download: downloadZig, - }, -]; - -async function getDependencyPath(name) { - let dependency; - for (const entry of dependencies) { - if (name === entry.name) { - dependency = entry; - break; - } - } - if (!dependency) { - throw new Error(`Unknown dependency: ${name}`); - } - const { version, download } = dependency; - mkdirSync(vendorPath, { recursive: true }); - for (const path of readdirSync(vendorPath)) { - if (!path.startsWith(name)) { - continue; - } - const dependencyPath = join(vendorPath, path); - const dependencyVersion = getVersion(dependencyPath); - if (dependencyVersion === version) { - return dependencyPath; - } - } - if (!download) { - throw new Error(`Dependency not found: ${name}`); - } - return await download(version); -} - -/** - * @param {string} [version] - */ -async function downloadZig(version) { - const target = getZigTarget(); - const expectedVersion = version || getRecommendedZigVersion(); - const url = `https://ziglang.org/builds/zig-${target}-${expectedVersion}.tar.xz`; - const tarPath = await downloadFile(url); - const extractedPath = await extractFile(tarPath); - const zigPath = join(extractedPath, exePath("zig")); - const actualVersion = getVersion(zigPath); - const outPath = join(vendorPath, exePath(`zig-${actualVersion}`)); - mkdirSync(dirname(outPath), { recursive: true }); - copyFileSync(zigPath, outPath); - return outPath; -} - -/** - * @param {string} path - * @returns {string} - */ -function exePath(path) { - return isWindows ? `${path}.exe` : path; -} - -const execPath = await getDependencyPath("zig"); -console.log(execPath); diff --git a/scripts/runner.node.mjs b/scripts/runner.node.mjs index 7d50b148cb..2523da8586 100755 --- a/scripts/runner.node.mjs +++ b/scripts/runner.node.mjs @@ -26,7 +26,7 @@ import { normalize as normalizeWindows } from "node:path/win32"; import { isIP } from "node:net"; import { parseArgs } from "node:util"; -const spawnTimeout = 30_000; +const spawnTimeout = 5_000; const testTimeout = 3 * 60_000; const integrationTimeout = 5 * 60_000; @@ -231,18 +231,20 @@ async function runTests() { */ /** - * @param {SpawnOptions} request + * @param {SpawnOptions} options * @returns {Promise} */ -async function spawnSafe({ - command, - args, - cwd, - env, - timeout = spawnTimeout, - stdout = process.stdout.write.bind(process.stdout), - stderr = process.stderr.write.bind(process.stderr), -}) { +async function spawnSafe(options) { + const { + command, + args, + cwd, + env, + timeout = spawnTimeout, + stdout = process.stdout.write.bind(process.stdout), + stderr = process.stderr.write.bind(process.stderr), + retries = 0, + } = options; let exitCode; let signalCode; let spawnError; @@ -318,6 +320,16 @@ async function spawnSafe({ resolve(); } }); + if (spawnError && retries < 5) { + const { code } = spawnError; + if (code === "EBUSY" || code === "UNKNOWN") { + await new Promise(resolve => setTimeout(resolve, 1000 * (retries + 1))); + return spawnSafe({ + ...options, + retries: retries + 1, + }); + } + } let error; if (exitCode === 0) { // ... @@ -1332,7 +1344,7 @@ function formatTestToMarkdown(result, concise) { let markdown = ""; for (const { testPath, ok, tests, error, stdoutPreview: stdout } of results) { - if (ok) { + if (ok || error === "SIGTERM") { continue; } diff --git a/test/cli/run/run-crash-handler.test.ts b/test/cli/run/run-crash-handler.test.ts index 0769129f8a..4923c6f06d 100644 --- a/test/cli/run/run-crash-handler.test.ts +++ b/test/cli/run/run-crash-handler.test.ts @@ -13,13 +13,11 @@ test.if(process.platform === "darwin")("macOS has the assumed image offset", () test("raise ignoring panic handler does not trigger the panic handler", async () => { let sent = false; - let onresolve = Promise.withResolvers(); using server = Bun.serve({ port: 0, fetch(request, server) { sent = true; - onresolve.resolve(); return new Response("OK"); }, }); @@ -34,11 +32,8 @@ test("raise ignoring panic handler does not trigger the panic handler", async () }, ]), }); - await proc.exited; - await Promise.race([onresolve.promise, Bun.sleep(1000)]); - - expect(proc.exitCode).not.toBe(0); + expect(proc.exited).resolves.not.toBe(0); expect(sent).toBe(false); }); @@ -46,7 +41,6 @@ describe("automatic crash reporter", () => { for (const approach of ["panic", "segfault", "outOfMemory"]) { test(`${approach} should report`, async () => { let sent = false; - let onresolve = Promise.withResolvers(); // Self host the crash report backend. using server = Bun.serve({ @@ -54,7 +48,6 @@ describe("automatic crash reporter", () => { fetch(request, server) { expect(request.url).toEndWith("/ack"); sent = true; - onresolve.resolve(); return new Response("OK"); }, }); @@ -72,15 +65,12 @@ describe("automatic crash reporter", () => { ]), stdio: ["ignore", "pipe", "pipe"], }); - await proc.exited; - - await Promise.race([onresolve.promise, Bun.sleep(1000)]); - + const exitCode = await proc.exited; const stderr = await Bun.readableStreamToText(proc.stderr); console.log(stderr); - expect(proc.exitCode).not.toBe(0); + expect(exitCode).not.toBe(0); expect(stderr).toContain(server.url.toString()); if (approach !== "outOfMemory") { expect(stderr).toContain("oh no: Bun has crashed. This indicates a bug in Bun, not your code"); diff --git a/test/js/bun/dns/resolve-dns.test.ts b/test/js/bun/dns/resolve-dns.test.ts index b237d43a3f..747a2aa3a2 100644 --- a/test/js/bun/dns/resolve-dns.test.ts +++ b/test/js/bun/dns/resolve-dns.test.ts @@ -107,7 +107,7 @@ describe("dns", () => { test.each(malformedHostnames)("'%s'", hostname => { // @ts-expect-error expect(dns.lookup(hostname, { backend })).rejects.toMatchObject({ - code: "DNS_ENOTFOUND", + code: expect.stringMatching(/^DNS_ENOTFOUND|DNS_ESERVFAIL|DNS_ENOTIMP$/), name: "DNSException", }); });